Hello there,
I'm just updating over my old post, but clearer and with new information..
so here it goes
I'm porting a device from windows to linux (a custom device made from
micro-controller PIC 18F2550) here is the code running on the device:
https://docs.google.com/Doc?id=dfpfb3rg_129g425rzg8
And here is the lsusb -vv from the device:
https://docs.google.com/Doc?docid=0AWpXTkcnmmy9ZGZwZmIzcmdfMTI3ZnB4cnFnaGM&hl=en&authkey=CICHl_QP
The function of the device is simple: when you send it 3 bytes (for example
0x00 0x03 0x00 ) it reply you 5 bytes of information back
I tried to read it the device with this python code:
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()
dev.reset()
#communication code
msg = [0x02,0x03,0x00]
print dev.write(1, msg)
print dev.read(0x81, 5)
But I get :
Traceback (most recent call last):
File "prueba.py", line 27, in <module>
print dev.read(0x81, 5)
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*
Here is the output of the sniffer in linux:
e0d6bc00 2973571448 S Co:034:00 s 00 09 0001 0000 0000 0
e0d6bc00 2973572014 C Co:034:00 0 0
e0d6bc00 2973576064 S Co:001:00 s 23 03 0004 0003 0000 0
f70c9c80 2973586652 C Ii:001:01 0 1 = 08
f70c9c80 2973586663 S Ii:001:01 -115 2 <
e0d6bc00 2973640041 C Co:001:00 0 0
e2168e80 2973696046 S Ci:001:00 s a3 00 0000 0003 0004 4 <
e2168e80 2973696059 C Ci:001:00 0 4 = 03011000
e2168e80 2973752042 S Co:001:00 s 23 01 0014 0003 0000 0
e2168e80 2973752048 C Co:001:00 0 0
e2168e80 2973752068 S Ci:000:00 s 80 06 0100 0000 0040 64 <
e2168e80 2973753001 C Ci:000:00 0 18 = 12011001 00000040 d8042000 00010102
0001
e2168e80 2973753041 S Co:001:00 s 23 03 0004 0003 0000 0
f70c9c80 2973779666 C Ii:001:01 0 1 = 08
f70c9c80 2973779679 S Ii:001:01 -115 2 <
e2168e80 2973816044 C Co:001:00 0 0
cb1fea80 2973872047 S Ci:001:00 s a3 00 0000 0003 0004 4 <
cb1fea80 2973872060 C Ci:001:00 0 4 = 03011000
d0878900 2973928050 S Co:001:00 s 23 01 0014 0003 0000 0
d0878900 2973928061 C Co:001:00 0 0
d0878900 2973928067 S Co:000:00 s 00 05 0022 0000 0000 0
d0878900 2973928997 C Co:000:00 0 0
d0878900 2973948060 S Ci:034:00 s 80 06 0100 0000 0012 18 <
d0878900 2973948998 C Ci:034:00 0 18 = 12011001 00000040 d8042000 00010102
0001
d0878900 2973949047 S Ci:034:00 s 80 06 0200 0000 0029 41 <
d0878900 2973950990 C Ci:034:00 0 41 = 09022900 010100c0 32090400 00020300
00000921 00010001 22200007 05810308
d0878900 2973951033 S Co:034:00 s 00 09 0001 0000 0000 0
d0878900 2973952991 C Co:034:00 0 0
d0878c00 2973954730 S Io:034:01 -115 3 = *020300 <---- this is the
package with the info I send to the device*
d0878c00 2973955993 C Io:034:01 0 3 >
ec6fac00 2973957082 S Ii:034:01 -115 5 <
ec6fac00 2974957983 C Ii:034:01 -2 0
And here it is a sniffer of a succefull transaction over windows with the
Hidcomm libraries:
https://docs.google.com/Doc?docid=0AWpXTkcnmmy9ZGZwZmIzcmdfMTMwZnBudjlyaGY&hl=en&authkey=CKTd6osJ
As you may see, in windows it uses endpoint 0x81 to receive the information.
While in linux I get a timeout error.
Any clues of what could be happening ? anything could be helpful .. am I
doing something horribly wrong ? I'm actually quite newbie working with usb
protocol.
Thanks !! and sorry for reposting the same topic
Marcos.
------------------------------------------------------------------------------
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