2017-10-07 97 views
0

我需要測試Epson POS打印機TM-U220PD。 我有它通過並行轉換器連接到我的筆記本電腦。 這是完全安裝,但是當我與Python escpos測試它顯示我以下錯誤:Errrno 32管道錯誤,escpos python2

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python2.7/dist-packages/escpos/escpos.py", line 437, in text 
    self._raw(txt.encode()) 
    File "/usr/local/lib/python2.7/dist-packages/escpos/printer.py", line 85, in _raw 
    self.device.write(self.out_ep, msg, self.timeout) 
    File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 948, in write 
    self.__get_timeout(timeout) 
    File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 824, in bulk_write 
    timeout) 
    File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 920, in __write 
    _check(retval) 
    File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 595, in _check 
    raise USBError(_strerror(ret), ret, _libusb_errno[ret]) 
usb.core.USBError: [Errno 32] Pipe error 

這是用來測試的代碼:

>>> from escpos.printer import Usb 
>>> p = Usb(0x067b, 0x2305) 
>>> p.open() 
>>> p.text() 

回答

0

這樣的USB到並行轉換器應該由你的系統安裝到文件系統中(我認爲你從一個* nix中判斷你的蹤跡)。 通常情況下這是類似/dev/usb/lp0

對於初次調試你可以嘗試只是寫這個「文件」:

echo "Test\n" > /dev/usb/lp0 

如果這個工程,你應該能夠成功地與打印:

from escpos.printer import File 
p = File(devfile='/dev/usb/lp0') 
p.text("some text\n")