Spied on the USB bus, I see that reader.open() does not actually open the
port though it seem to pass a handle object to readerHandler . There are no
messages passed and no activity on the bus.

On debugging the code, I see that reader.open() just returns DeviceHandle
object without any call to open the port. Is this intended?

-------------------------------------code
debug--------------------------------------------------------
C:\Python26>python.exe -m pdb code.py
-> import usb
(Pdb) l
  1  -> import usb
  2
  3     buses = usb.busses()
  4
  5     for bus in buses:
  6        for device in bus.devices:
  7            if device.idVendor == 0x10C4 and device.idProduct == 0x81f2:
  8                reader = device
  9
 10     readerHandler = reader.open()
 11
(Pdb) b 10
Breakpoint 1 at code.py:10
(Pdb) c
-> readerHandler = reader.open()
(Pdb) s
--Call--
> c:\python26\lib\site-packages\usb\legacy.py(311)open()
-> def open(self):
(Pdb) s
> c:\python26\lib\site-packages\usb\legacy.py(316)open()
-> return DeviceHandle(self.dev)
(Pdb) s
--Call--
> c:\python26\lib\site-packages\usb\legacy.py(132)__init__()
-> def __init__(self, dev):
(Pdb) l
127                                         ),
128                                         lambda i: i.alternateSetting)
129                             ]
130
131     class DeviceHandle(object):
132  ->     def __init__(self, dev):
133             self.dev = dev
134             self.__claimed_interface = -1
(Pdb) n
> c:\python26\lib\site-packages\usb\legacy.py(133)__init__()
-> self.dev = dev
(Pdb) n
> c:\python26\lib\site-packages\usb\legacy.py(134)__init__()
-> self.__claimed_interface = -1
(Pdb) n
--Return--
> c:\python26\lib\site-packages\usb\legacy.py(134)__init__()->None
-> self.__claimed_interface = -1
(Pdb) n
--Return--
>
c:\python26\lib\site-packages\usb\legacy.py(316)open()-><usb.leg...010320F0>
-> return DeviceHandle(self.dev)
(Pdb) l
311         def open(self):
312             r"""Open the device for use.
313
314             Return a DeviceHandle object
315             """
316  ->         return DeviceHandle(self.dev)
317
318     class Bus(object):
319         r"""Bus object."""
320         def __init__(self):
321             self.dirname = ''
(Pdb) p self.dev
<usb.core.Device object at 0x010AE570>
(Pdb)
-----------------------------------------code
debug------------------------------------------
On Tue, Jan 18, 2011 at 1:10 AM, Emmanuel Blot <eblot...@gmail.com> wrote:

> On Mon, Jan 17, 2011 at 4:31 PM, Sridev Nair <sksridevn...@gmail.com>
> wrote:
> > Some issue related to port opening & response capture which I am unable
> to
> > figure out.
>
> I think at this point, it would be helpful to spy on the USB bus to
> see what's going on with the driver that works, and compare it with
> the command you send using pyusb.
>
> Cheers,
> Manu
>
>
> ------------------------------------------------------------------------------
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand
> malware threats, the impact they can have on your business, and how you
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to