วันอังคารที่ 8 มีนาคม พ.ศ. 2554

DOS printing with USB printer

Most DOS programs use parallel port (LPT1:, LPT2: LPT3:) for printing only, can not support other port type as USB port (some new laser printers) or serial port (some model of POS printers). Although those printers can understand DOS printing commands.

In Windows we will make use of network redirector ability, capturing data from parallel port and send it to the network printer. A DOS program still prints to parallel port as usual, but all data will redirect to prefer network printer (include the network printer that directly connected at the machine).

There are 2 easy steps:
1. Setting the network printer by sharing the printer.
2. Capture parallel port and redirect to the network printer.

Setting the network printer.
If your computer has a valid network connection, simply share the printer. If your computer does not have any valid connection, you need to create a fake connection by adding loop back adapter.

Adding Microsoft loop back adapter
For standalone computer, Windows does not allow sharing the printer without a network connection. You can install the Loop Back Adapter to create network connection connects to itself.



> From Control Panel select "Add Hardware".
> Click Next at first page of wizard.
> Select "Yes", then click Next.
> Scroll down and select "Add a new hardware device" then click Next.
> Select "Install the hardware that I manually...", then click Next.
> Select "Network adapters" then click Next.
> Select "Microsoft" -> "Microsoft loop back adapter" then click Next.
> And Next, Next, ... until finish.

Don't forget to assign the IP address for loop back connection you created.
> In Control Panel select "Network Connections".
> Right click at the connection then select "Properties".
> Double click at "Internet protocol (TCP/IP)".
> Select choice "Use the following IP address".
> Fill a valid IP address number with sub net as 192.168.1.100 / 255.255.255.0

Sharing the printer
> In Control Panels select Printers and Faxes,
> then right click at the printer you want to share.
> Select Sharing in context menu.



> In printer properties page select Share this printer
> named your share printer for easy to remember.

Capture parallel port and redirect to the network printer.
Open Command Prompt window by doing this.
> From menu Start -> select Run -> type CMD in Open box.



In Command Prompt window
> Check the computer name by typing command
net view
> Check the printer name by typing
net view \\computername
> Redirect parellel port to network printer by typing
net use lpt1: \\computername\printername /persistence:yes

พิมพ์ DOS ด้วยเครื่องพิมพ์ USB

โปรแกรม DOS ส่วนใหญ่มักพิมพ์ออกทาง parallel port (LPT1:,LPT2:, LPT3:) ทำให้ไม่สามารถใช้กับเครื่องพิมพ์ที่เชื่อมต่อทางอื่น เช่น USB port (เครื่องพิมพ์ laser รุ่นใหม่ๆ)หรือ serial port (เครื่องพิมพ์สลิป POS - Point Of Sale) ถึงแม้ว่าเครื่องพิมพ์เหล่านั้น สามารถรับคำสั่งพิมพ์จาก DOS เหมือนกับเครื่องพิมพ์ parallel port ทั่วไป

ภายใต้ Windows เราสามารถใช้ประโยชน์จาก network redirector เพื่อดักข้อมูลที่ส่งพิมพ์ออกทาง parallel port ให้เปลี่ยนไปออกทาง network printer ที่เรากำหนด ด้วยวิธีนี้ ถึงแม้ว่า โปรแกรม DOS ยังคงส่งข้อมูลออกทาง parallel port เหมือนเดิม แต่ข้อมูลที่ส่งออกไป จะถูกเปลี่ยนทางให้ไปออกที่ network printer รวมถึง network printer
ต่อกับเครื่องคอมพิวเตอร์ตัวเองด้วย

ขั้นตอนการทำมี 2 ขั้นตอนง่าย ๆ ดังนี้
1. ตั้งเครื่องพิมพ์ที่ต่ออยู่ให้กลายเป็น network printer
2. ดักข้อมูลที่ออกทาง parallel port ให้ไปออกที่ network printer แทน

ตั้งเครื่องพิมพ์ให้กลายเป็น network printer
สำหรับ คอมพิวเตอร์ที่ไม่มีการเชื่อมต่อ network ไม่สามารถตั้ง network printer ได้ เนื่องจากไม่มี network connection เราต้องติดตั้ง Loop Back Adapter เพื่อสร้างการเชื่อมต่อ network ภายในเครื่องเดียวกันเอง เพื่อให้ Windows ยอมให้เราตั้ง network printer

ติดตั้ง Microsoft loop back adapter
ถ้า คอมพิวเตอร์ของคุณมี network connection อยู่แล้ว คุณเพียงสั่งแชร์เครื่องพิมพ์ แต่ถ้าคอมพิวเตอร์ของคุณไม่มี connection คุณต้องสร้าง connection หลอกขึ้นมา โดยติดตั้ง loop back adapter



> ใน Control Panel เลือก Add Hardware เลือก Next
> ที่หน้าแรกของ wizard เลือก Yes แล้ว กด Next
> เลื่อนลงมาที่รายการด้านล่าง เลือก "Add a new hardware device" แล้วกด Next
> เลือก "Install the hardware that I manually..." แล้วกด Next
> เลือก "Network adapters" แล้วกด Next
> เลือก "Microsoft" -> "Microsoft loop back adapter" แล้วกด Next
> กด Next ต่อไปเรื่อยๆ จนเสร็จ

กำหนด IP address สำหรับ loop back connction ที่คุณสร้างขึ้นมา
> ใน Control Panel เลือก "Network Connections"
> ใช้เมาส์ปุ่มขวาที่ชื่อ connection นั้น แล้วเลือก "Properties"
> ดับเบิลคลิกที่ "Internet protocol (TCP/IP)"
> เลือกหัวข้อ "Use the following IP address"
> ใส่หมายเลข IP adress และ sub net เช่น 192.168.1.100 / 255.255.255.0

การแชร์เครื่องพิมพ์
> ใน Control Panels เปิด Printers and Faxes
> แล้วกดเมาส์ปุ่มขวาตรงเครื่องพิมพ์ ที่คุณต้องการ เลือก Sharing จากเมนู



> ในหน้า Printer properties ให้เลือก Share this printer
> ตั้งชื่อเรียก network printer นั้น ให้จดจำได้ง่าย

ดักข้อมูลที่ parallel port ให้ไปออกที่ network printer แทน

เปิดหน้าต่าง Command Prompt ดังนี้
> จากเมนู Start -> เลือก Run -> พิมพ์ CMD ลงในกล่อง Open



ในหน้าต่าง Command Prompt
> ดูชื่อคอมพิวเตอร์ โดยใช้คำสั่ง
net view
> ดูชื่อเครื่องพิมพ์ โดยใช้คำสั่ง
net view \\ชื่อคอมพิวเตอร์
> เปลี่ยนทางข้อมูลของ parallel port ไปที่ network printer โดยใช้คำสั่ง
net use lpt1: \\ชื่อคอมพิวเตอร์\ชื่อเครื่องพิมพ์ /persistent:yes
บทความดีๆ จาก http://dos-accounting.blogspot.com/2007/11/dos-printing-with-usb-printer.html

ไม่มีความคิดเห็น:

แสดงความคิดเห็น