Long time since I worked with USB printers, but if I remember right,
status commands are issued from control endpoint. You might want to
give a look at the Printer Class specification [1].

[1] http://www.usb.org/developers/devclass_docs/usbprint11a021811.pdf

2012/12/19 Marco <mdmart...@gmail.com>:
> Hi
>
> I have a parallel receipt printer (Epson Tm88III )
> http://nicholas.piasecki.name/blog/wp-content/uploads/2009/12/ESC-POS-Programming-Guide.pdf
> connected to usb using an USB/parallel adapter.
>
> I need to read the printer status but when i try to send the comand to the
> interface i get an timeout.
> I trying to use the bidireccional Interface, am i rigth?
> the command i have to send to printer is 0x10 0x40
> The source is
>
> import usb.core
> import usb.util
> dev = usb.core.find(idVendor=0x067b, idProduct=0x2305)
>
> if dev.is_kernel_driver_active(0):
>     dev.detach_kernel_driver(0)
>     dev.detach_kernel_driver(1)
>
> dev.set_configuration()
>
> # get an endpoint instance
> cfg = dev.get_active_configuration()
>
> interface_number = cfg[(0,0)].bInterfaceNumber
>
> print "\ninterface_number %s"%interface_number
>
> alternate_settting = usb.control.get_interface(dev,interface_number)
>
> intf = usb.util.find_descriptor(
> cfg, bInterfaceNumber = interface_number,
> bAlternateSetting = 1
> )
> 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
> )
> epin = usb.util.find_descriptor(
> intf,
> # match the first OUT endpoint
> custom_match = \
> lambda e: \
> usb.util.endpoint_direction(e.bEndpointAddress) == \
> usb.util.ENDPOINT_IN
> )
>
> #print (ep.bEndpointAddress)
> #print (epin.bEndpointAddress)
>
>
> comand='\x10'+'\x04'+'\x30'
> ep.write(comand)
>
> print "\ndata1"
>
> print epin.read(1)
>
>
>
>
>
> the lsusb -v |more is
>
> Bus 007 Device 002: ID 067b:2305 Prolific Technology, Inc. PL2305 Parallel 
> Port
> Device Descriptor:
>   bLength                18
>   bDescriptorType         1
>   bcdUSB               1.00
>   bDeviceClass            0 (Defined at Interface level)
>   bDeviceSubClass         0
>   bDeviceProtocol         0
>   bMaxPacketSize0         8
>   idVendor           0x067b Prolific Technology, Inc.
>   idProduct          0x2305 PL2305 Parallel Port
>   bcdDevice            2.02
>   iManufacturer           1 Prolific Technology Inc.
>   iProduct                2 IEEE-1284 Controller
>   iSerial                 0
>   bNumConfigurations      1
>   Configuration Descriptor:
>     bLength                 9
>     bDescriptorType         2
>     wTotalLength           78
>     bNumInterfaces          1
>     bConfigurationValue     1
>     iConfiguration          0
>     bmAttributes         0xa0
>       (Bus Powered)
>       Remote Wakeup
>     MaxPower              100mA
>     Interface Descriptor:
>       bLength                 9
>       bDescriptorType         4
>       bInterfaceNumber        0
>       bAlternateSetting       0
>       bNumEndpoints           1
>       bInterfaceClass         7 Printer
>       bInterfaceSubClass      1 Printer
>       bInterfaceProtocol      1 Unidirectional
>       iInterface              0
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x01  EP 1 OUT
>         bmAttributes            2
>           Transfer Type            Bulk
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval               0
>     Interface Descriptor:
>       bLength                 9
>       bDescriptorType         4
>       bInterfaceNumber        0
>       bAlternateSetting       1
>       bNumEndpoints           2
>       bInterfaceClass         7 Printer
>       bInterfaceSubClass      1 Printer
>       bInterfaceProtocol      2 Bidirectional
>       iInterface              0
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x01  EP 1 OUT
>         bmAttributes            2
>           Transfer Type            Bulk
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval               0
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x82  EP 2 IN
>         bmAttributes            2
>           Transfer Type            Bulk
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval               0
>   Interface Descriptor:
>       bLength                 9
>       bDescriptorType         4
>       bInterfaceNumber        0
>       bAlternateSetting       2
>       bNumEndpoints           3
>       bInterfaceClass       255 Vendor Specific Class
>       bInterfaceSubClass      0
>       bInterfaceProtocol    255
>       iInterface              0
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x01  EP 1 OUT
>         bmAttributes            2
>           Transfer Type            Bulk
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval               0
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x82  EP 2 IN
>         bmAttributes            2
>           Transfer Type            Bulk
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0040  1x 64 bytes
>         bInterval               0
>       Endpoint Descriptor:
>         bLength                 7
>         bDescriptorType         5
>         bEndpointAddress     0x83  EP 3 IN
>         bmAttributes            3
>           Transfer Type            Interrupt
>           Synch Type               None
>           Usage Type               Data
>         wMaxPacketSize     0x0004  1x 4 bytes
>         bInterval               1
> Device Status:     0x0000
>   (Bus Powered)
>
>
>
>
>
>
>
> Thanks in advance
>
>
> ------------------------------------------------------------------------------
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> Remotely access PCs and mobile devices and provide instant support
> Improve your efficiency, and focus on delivering more value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d
> _______________________________________________
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users



-- 
Best Regards,
Wander Lairson Costa

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to