Hi!
I'm using Ubuntu 12.04 development machine, Epson LX-300. I have
followed the tutorial from Git, was able to find my printer but got
stuck with pipe error. I'm trying to print directly to printer.
Note: Made it to work once, then this error showed up. All had
encountered time out errors.
Code:
import usb.core
import usb.util
# actually this is not the whole history, keep reading
dev = usb.core.find(idVendor=0x067b, idProduct=0x2305)
# was it found?
if dev is None:
raise ValueError('Device not found')
else:
print "Printer here"
# set the active configuration. With no arguments, the first
# configuration will be the active one
dev.set_configuration()
print dev.set_configuration()
# get an endpoint instance
cfg = dev.get_active_configuration()
intf = cfg[(0,0)]
ep = usb.util.find_descriptor(
intf,
# match the first OUT endpoint
custom_match = \
lambda e: \
usb.util.endpoint_direction(e.bEndpointAddress) == \
usb.util.ENDPOINT_OUT)
assert ep is not None
#print ep
# write the data
ep.write('test')
Result:
Printer here
None
Traceback (most recent call last):
File "enumerate_usb_connected_printer.py", line 33, in <module>
ep.write('test')
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 287, in write
return self.device.write(self.bEndpointAddress, data,
self.interface, timeout)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 633, in write
self.__get_timeout(timeout)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py",
line 771, in bulk_write
timeout)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py",
line 872, in __write
_check(retval)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py",
line 571, in _check
raise USBError(_str_error[ret], ret, _libusb_errno[ret])
usb.core.USBError: [Errno 32] Pipe error
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
pyusb-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyusb-users