Hi lil' update,
I found out how to sniff it with sudo cat /sys/kernel/debug/usb/usbmon/2u :
https://docs.google.com/Doc?id=dfpfb3rg_128f855msfs&authkey=COzv2oUI
<https://docs.google.com/Doc?id=dfpfb3rg_128f855msfs&authkey=COzv2oUI>that's
the output but it's really difficult to read, I tried with this tutorial
http://www.mjmwired.net/kernel/Documentation/usb/usbmon.txt didn't found
anything odd unless it uses different endpoints.
Any ideas ?
Thanks
On Wed, Dec 15, 2010 at 11:47 AM, Marcos Wolff <wmar...@gmail.com> wrote:
> Hey Santiago,
>
> I've tried sending control messages but either the devices does not use it
> or I cannot construct them correctly, for example, here I've tried to send a
> GET_REPORT (the one that keyboard and mises use to communicate according to
> HID especification) message:
>
> # 0x91 and 0x01 for a GET_REPORT control message
> dev.ctrl_transfer(0x91, 0x01,0,0,data)
>
> also tried with other control messages, but everything return a pipe error
> like before.
>
> I found an implementation of a credit card reader in python 1.0 here
> http://www.micahcarrick.com/credit-card-reader-pyusb.html it seems pritty
> simple. I don't know why I cannot make it work :(.
>
> Although with the instruction:
>
> dev.write(1,data)
>
> the devices seems to be processing the information, I just cannot harvest
> the response for some reason.
>
> right now I got stuck sending data to the device but with response full of
> zeros, as it is shown in the link below:
>
> https://docs.google.com/Doc?id=dfpfb3rg_126jsh78vfv&authkey=CIPQmpoB
>
> here is the output of the lsusb -vv command:
>
> https://docs.google.com/Doc?id=dfpfb3rg_127fpxrqghc&authkey=CICHl_QP
>
> Thanks for keep throwing ideas !
> Marcos
>
>
> On Tue, Dec 14, 2010 at 6:37 PM, Santiago Palomino Sanchez-Manjavacas <
> sps...@gmail.com> wrote:
>
>> It was a long time since I worked with the usb, but I recall the endpoints
>> are unidirectional. I think trying to read from an output shall return some
>> kind of error. You can try to find out which of the two operations (r/w) is
>> working first. You can try to find out if the device accepts the writes by
>> sending commands whose consequences can be observed by looking at the usb
>> device.
>>
>> I also remember having to deal with the control endpoints before using the
>> regular endpoints. That was done in the following way when I used a device
>> running the porus stack:
>>
>> porusBLKI(self.devh,bc)
>> print "Waiting for BITX (or IDLE).."
>> while porusSTAT(self.devh)==3: pass
>> print "Got BITX, now receiving .."
>> rndbuf=self.rxChain(1) *<=== This is just doing a read, but I
>> sent a control message to the device first.*
>>
>>
>> def porusBLKO(devh,length):
>> devh.controlMsg(0x41,4,[],length)
>>
>> def porusBLKI(devh,length):
>> devh.controlMsg(0x41,3,[],length)
>>
>> def porusTMOI(devh,length,c):
>> devh.controlMsg(0x41,7,[c],length)
>>
>>
>> def porusSTAT(devh):
>> buf=devh.controlMsg(0xC1, 5, 1)[0]
>> if buf<0: buf+=256
>> return buf
>>
>> I do not know if all devices require control messages before accessing the
>> endpoints, but that device did.
>>
>> Good luck with it.
>>
>>
>>
>> On Tue, Dec 14, 2010 at 20:31, Marcos Wolff <wmar...@gmail.com> wrote:
>>
>>> update:
>>>
>>> If I use the same endpoint for reading and writing it works but returns
>>> just 0s :(
>>>
>>> #prueba.py
>>> import usb.core
>>> dev = usb.core.find(idVendor=1240,idProduct=32)
>>> if dev is None:
>>> raise ValueError('Device not found')
>>> interface = dev.get_interface_altsetting()
>>> if dev.is_kernel_driver_active(interface.bInterfaceNumber) is True:
>>> dev.detach_kernel_driver(interface.bInterfaceNumber)
>>> dev.set_configuration()
>>> msg = '\x02\x03\x00'
>>> dev.write(1, msg, 0)
>>> ret = dev.read(1, len(msg), 0)
>>> print ret
>>>
>>>
>>> msg: [1, 3, 0]
>>> ret: array('B', [0, 0, 0, 0, 0])
>>>
>>>
>>>
>>> On Tue, Dec 14, 2010 at 4:06 PM, Marcos Wolff <wmar...@gmail.com> wrote:
>>>
>>>> Hi again,
>>>>
>>>> Did a little more research. I found out the console command lsusb -vv to
>>>> analyze the device, runned it, got this:
>>>>
>>>> Bus 002 Device 030: ID 04d8:0020 Microchip Technology, Inc.
>>>> Device Descriptor:
>>>> bLength 18
>>>> bDescriptorType 1
>>>> bcdUSB 1.10
>>>> bDeviceClass 0 (Defined at Interface level)
>>>> bDeviceSubClass 0
>>>> bDeviceProtocol 0
>>>> bMaxPacketSize0 64
>>>> idVendor 0x04d8 Microchip Technology, Inc.
>>>> idProduct 0x0020
>>>> bcdDevice 1.00
>>>> iManufacturer 1 DZE
>>>> iProduct 2 CDI TEST v1.0
>>>> iSerial 0
>>>> bNumConfigurations 1
>>>> Configuration Descriptor:
>>>> bLength 9
>>>> bDescriptorType 2
>>>> wTotalLength 41
>>>> bNumInterfaces 1
>>>> bConfigurationValue 1
>>>> iConfiguration 0
>>>> bmAttributes 0xc0
>>>> Self Powered
>>>> MaxPower 100mA
>>>> Interface Descriptor:
>>>> bLength 9
>>>> bDescriptorType 4
>>>> bInterfaceNumber 0
>>>> bAlternateSetting 0
>>>> bNumEndpoints 2
>>>> bInterfaceClass 3 Human Interface Device
>>>> bInterfaceSubClass 0 No Subclass
>>>> bInterfaceProtocol 0 None
>>>> iInterface 0
>>>> HID Device Descriptor:
>>>> bLength 9
>>>> bDescriptorType 33
>>>> bcdHID 1.00
>>>> bCountryCode 0 Not supported
>>>> bNumDescriptors 1
>>>> bDescriptorType 34 Report
>>>> wDescriptorLength 32
>>>> Report Descriptors:
>>>> ** UNAVAILABLE **
>>>> Endpoint Descriptor:
>>>> bLength 7
>>>> bDescriptorType 5
>>>> * bEndpointAddress 0x81 EP 1 IN*
>>>> bmAttributes 3
>>>> Transfer Type Interrupt
>>>> Synch Type None
>>>> Usage Type Data
>>>> wMaxPacketSize 0x0008 1x 8 bytes
>>>> bInterval 1
>>>> Endpoint Descriptor:
>>>> bLength 7
>>>> bDescriptorType 5
>>>> * bEndpointAddress 0x01 EP 1 OUT*
>>>> bmAttributes 3
>>>> Transfer Type Interrupt
>>>> Synch Type None
>>>> Usage Type Data
>>>> wMaxPacketSize 0x0008 1x 8 bytes
>>>> bInterval 10
>>>> Device Status: 0x0001
>>>> Self Powered
>>>>
>>>> -----------------------------
>>>>
>>>> so I modified the script to use those endpoints:
>>>>
>>>> #prueba.py
>>>>
>>>> import usb.core
>>>>
>>>> dev = usb.core.find(idVendor=1240,idProduct=32)
>>>> if dev is None:
>>>> raise ValueError('Device not found')
>>>>
>>>> interface = dev.get_interface_altsetting()
>>>> if dev.is_kernel_driver_active(interface.bInterfaceNumber) is True:
>>>> dev.detach_kernel_driver(interface.bInterfaceNumber)
>>>>
>>>> dev.set_configuration()
>>>>
>>>> msg = '\x02\x03\x00'
>>>> dev.write(1, msg, 0)
>>>> ret = dev.read(0x81, len(msg), 0)
>>>> print ret
>>>>
>>>> Now the device start blinking its leds like it's working but I get:
>>>>
>>>> Traceback (most recent call last):
>>>> File "prueba.py", line 27, in <module>
>>>> ret = dev.read(0x81, len(msg), 0)
>>>> File "/home/administrador/pyusb-1.0.0-a0/usb/core.py", line 624, in
>>>> read
>>>> self.__get_timeout(timeout)
>>>> File "/home/administrador/pyusb-1.0.0-a0/usb/_debug.py", line 53, in
>>>> do_trace
>>>> return f(*args, **named_args)
>>>> File "/home/administrador/pyusb-1.0.0-a0/usb/backend/libusb10.py",
>>>> line 501, in intr_read
>>>> timeout)
>>>> File "/home/administrador/pyusb-1.0.0-a0/usb/backend/libusb10.py",
>>>> line 581, in __read
>>>> timeout))
>>>> File "/home/administrador/pyusb-1.0.0-a0/usb/backend/libusb10.py",
>>>> line 353, in _check
>>>> raise USBError(_str_error[retval.value])
>>>> *usb.core.USBError: Operation timed out*
>>>>
>>>> Tried changing the timeout value and didn't work :(.
>>>>
>>>> Any ideas ?
>>>>
>>>> Thanks !
>>>>
>>>> On Tue, Dec 14, 2010 at 3:32 PM, Marcos Wolff <wmar...@gmail.com>wrote:
>>>>
>>>>> Follow-up: Santiago:
>>>>>
>>>>> Also found the method doesn't exists in pyusb 1.0 apparently it manages
>>>>> interface claiming automatically.
>>>>>
>>>>> source:
>>>>> http://www.mail-archive.com/pyusb-users@lists.sourceforge.net/msg00374.html
>>>>>
>>>>> On Tue, Dec 14, 2010 at 3:30 PM, Marcos Wolff <wmar...@gmail.com>wrote:
>>>>>
>>>>>> Hi Santiago,
>>>>>>
>>>>>> Following this tutorial it doesn't seem to be needed:
>>>>>>
>>>>>> http://pyusb.sourceforge.net/docs/1.0/tutorial.htm#talk-to-me-honey
>>>>>>
>>>>>> Anyway I've tried (kind of desperate here) and didn't work :(
>>>>>>
>>>>>> thank for the quick answer !
>>>>>>
>>>>>>
>>>>>> On Tue, Dec 14, 2010 at 3:18 PM, Santiago Palomino Sanchez-Manjavacas
>>>>>> <sps...@gmail.com> wrote:
>>>>>>
>>>>>>> missing claimInterface() before using the control endpoint?
>>>>>>>
>>>>>>> Just a guess
>>>>>>>
>>>>>>> On Tue, Dec 14, 2010 at 18:54, Marcos Wolff <wmar...@gmail.com>wrote:
>>>>>>>
>>>>>>>> Hi everyone,
>>>>>>>>
>>>>>>>> I'm having trouble comunicating with a custom made (from a PIC
>>>>>>>> 18f4550 micro-controller) HID device. Nowadays is used with windows
>>>>>>>> and the
>>>>>>>> default HID driver in vb6 but I would like to port it to linux (ubuntu
>>>>>>>> 10.10) and pyusb (1.0a).
>>>>>>>>
>>>>>>>> The device is simple, when it receives 3 bytes via HID it responses
>>>>>>>> 3 bytes back with data. The people who made it told me that everything
>>>>>>>> is
>>>>>>>> handled via end point 0 and default config).
>>>>>>>>
>>>>>>>> As I want to port it to linux I read this tutorial
>>>>>>>> http://pyusb.sourceforge.net/docs/1.0/tutorial.html and tried to
>>>>>>>> communicate via default config endpoint configuration:
>>>>>>>>
>>>>>>>> #prueba.py
>>>>>>>>
>>>>>>>> import usb.core
>>>>>>>>
>>>>>>>> #busco dispositivo
>>>>>>>> dev = usb.core.find(idVendor=1240,idProduct=32)
>>>>>>>> if dev is None:
>>>>>>>> raise ValueError('Device not found')
>>>>>>>>
>>>>>>>> interface = dev.get_interface_altsetting()
>>>>>>>> if dev.is_kernel_driver_active(interface.bInterfaceNumber) is True:
>>>>>>>> dev.detach_kernel_driver(interface.bInterfaceNumber)
>>>>>>>>
>>>>>>>>
>>>>>>>> dev.set_configuration()
>>>>>>>>
>>>>>>>> #mensaje de 3 bytes
>>>>>>>> msg = '\x02\x03\x00'
>>>>>>>>
>>>>>>>> #bmRequestType y bRequest as said in
>>>>>>>> http://www.jungo.com/st/support/documentation/windriver/811/wdusb_man_mhtml/node55.html#usb_standard_dev_req_codes
>>>>>>>>
>>>>>>>>
>>>>>>>> dev.ctrl_transfer(0x40, 0x02, 0, 0, msg)
>>>>>>>>
>>>>>>>>
>>>>>>>> and I get this error which I don't fully understand:
>>>>>>>>
>>>>>>>> Traceback (most recent call last):
>>>>>>>> File "ejemplo.py", line 39, in <module>
>>>>>>>> print dev.ctrl_transfer(0x40, 0x02, 0, 0, msg)
>>>>>>>> File "/home/administrador/pyusb-1.0.0-a0/usb/core.py", line 668,
>>>>>>>> in ctrl_transfer
>>>>>>>> self.__get_timeout(timeout)
>>>>>>>> File "/home/administrador/pyusb-1.0.0-a0/usb/_debug.py", line 53,
>>>>>>>> in do_trace
>>>>>>>> return f(*args, **named_args)
>>>>>>>> File "/home/administrador/pyusb-1.0.0-a0/usb/backend/libusb10.py",
>>>>>>>> line 538, in ctrl_transfer
>>>>>>>> timeout))
>>>>>>>> File "/home/administrador/pyusb-1.0.0-a0/usb/backend/libusb10.py",
>>>>>>>> line 353, in _check
>>>>>>>> raise USBError(_str_error[retval.value])
>>>>>>>> *usb.core.USBError: Pipe error*
>>>>>>>>
>>>>>>>> Could someone guide me ? help me see what I'm doing wrong ?
>>>>>>>>
>>>>>>>> Thanks in advance !
>>>>>>>> Marcos.
>>>>>>>>
>>>>>>>>
>>>>>>>> PD: I tried to sniff usb ports with this tutorial
>>>>>>>> http://biot.com/blog/usb-sniffing-on-linux but nothing seems to be
>>>>>>>> happening excepto when I reset the device.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> Lotusphere 2011
>>>>>>>> Register now for Lotusphere 2011 and learn how
>>>>>>>> to connect the dots, take your collaborative environment
>>>>>>>> to the next level, and enter the era of Social Business.
>>>>>>>> http://p.sf.net/sfu/lotusphere-d2d
>>>>>>>> _______________________________________________
>>>>>>>> pyusb-users mailing list
>>>>>>>> pyusb-users@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Lotusphere 2011
>>>>>>> Register now for Lotusphere 2011 and learn how
>>>>>>> to connect the dots, take your collaborative environment
>>>>>>> to the next level, and enter the era of Social Business.
>>>>>>> http://p.sf.net/sfu/lotusphere-d2d
>>>>>>> _______________________________________________
>>>>>>> pyusb-users mailing list
>>>>>>> pyusb-users@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Lotusphere 2011
>>> Register now for Lotusphere 2011 and learn how
>>> to connect the dots, take your collaborative environment
>>> to the next level, and enter the era of Social Business.
>>> http://p.sf.net/sfu/lotusphere-d2d
>>> _______________________________________________
>>> pyusb-users mailing list
>>> pyusb-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Lotusphere 2011
>> Register now for Lotusphere 2011 and learn how
>> to connect the dots, take your collaborative environment
>> to the next level, and enter the era of Social Business.
>> http://p.sf.net/sfu/lotusphere-d2d
>> _______________________________________________
>> pyusb-users mailing list
>> pyusb-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>>
>>
>
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users