2014-07-16 6:05 GMT-03:00 Slavko Kocjancic <esla...@gmail.com>: > Hello... > > Attached is simple example. The problem is that it's works in linux but > not in windows. And I wan't to be portable. Can someone tell me what I > do wrong? > seems that <class 'usb.core.Device'> is handeled different in win (it > return long string?!) > > > > > #there is current only one device with correct vid/pid attached > import usb > def openUsb(vid,pid,name=''): > try: > devices = usb.core.find(idVendor=vid, idProduct=pid, find_all=True) > for dev in devices: > print type (dev) > print dev > if (usb.util.get_string(dev,256,2)==name): > dev.set_configuration() > return dev > except Exception as e: > print e > > > USBdev=openUsb(0x16d0,0x06ad,'Q_ANALISER') > if not USBdev: > print "Device not found" > exit(0) > print "Device found ",USBdev > > > ''' > ####OUTPUT on LINUX##### > <class 'usb.core.Device'> > <usb.core.Device object at 0x7ff2647f7290> > Device found <usb.core.Device object at 0x7ff2647f7290> > > > > ####OUTPUT on WINDOWS##### > <class 'usb.core.Device'> > DEVICE ID 16d0:06ad on Bus 000 Address 001 ================= > bLength : 0x12 (18 bytes) > bDescriptorType : 0x1 Device > bcdUSB : 0x110 USB 1.1 > bDeviceClass : 0x0 Specified at interface > bDeviceSubClass : 0x0 > bDeviceProtocol : 0x0 > bMaxPacketSize0 : 0x8 (8 bytes) > idVendor : 0x16d0 > idProduct : 0x06ad > bcdDevice : 0x1 Device 0.01 > iManufacturer : 0x1 CAA > iProduct : 0x2 Q_ANALISER > iSerialNumber : 0x0 > bNumConfigurations : 0x1 > CONFIGURATION 1: 400 mA ================================== > bLength : 0x9 (9 bytes) > bDescriptorType : 0x2 Configuration > wTotalLength : 0x1b (27 bytes) > bNumInterfaces : 0x1 > bConfigurationValue : 0x1 > iConfiguration : 0x0 > bmAttributes : 0xc0 Self Powered > bMaxPower : 0xc8 (400 mA) > INTERFACE 0: Human Interface Device ==================== > bLength : 0x9 (9 bytes) > bDescriptorType : 0x4 Interface > bInterfaceNumber : 0x0 > bAlternateSetting : 0x0 > bNumEndpoints : 0x0 > bInterfaceClass : 0x3 Human Interface Device > bInterfaceSubClass : 0x0 > bInterfaceProtocol : 0x0 > iInterface : 0x0 > Device not found > Press any key to continue . . . > >
Hi, It feels like you are using different git revisions for Windows and Linux, aren't you? -- Best Regards, Wander Lairson Costa ------------------------------------------------------------------------------ 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 pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users