I ran PyUSB regression tests with Python 3 and it is a PyUSB bug. I suggest you to use python 2 while the bug is not fixed. Complete Python 3 support is planned for latter releases.
Wander 2010/9/27 Igor Mohor <igor.mo...@gmail.com>: > I tried but I get the same report: > > Traceback (most recent call last): > File "X:\epc601_demo_board\qt_creator\prvi\run_mojwidget.py", line 68, in > get_status > print("Received from USB: ", UsbConnection.epin.read(64, 100)) > File "C:\Python31\lib\site-packages\usb\core.py", line 273, in read > return self.device.read(self.bEndpointAddress, size, self.interface, > timeout) > File "C:\Python31\lib\site-packages\usb\core.py", line 624, in read > self.__get_timeout(timeout) > File "C:\Python31\lib\site-packages\usb\_debug.py", line 53, in do_trace > return f(*args, **named_args) > File "C:\Python31\lib\site-packages\usb\backend\libusb01.py", line 448, in > bulk_read > timeout) > File "C:\Python31\lib\site-packages\usb\backend\libusb01.py", line 524, in > __read > buffer = array.array('B', '\x00' * size) > TypeError: an integer is required > > You can see that there is 100 in the code. > > Any other ideas? > > Regards, > Igor > > > > > > On Mon, Sep 27, 2010 at 2:42 PM, Wander Lairson <wander.lair...@gmail.com> > wrote: >> >> It feels like some incompatibility bug with python 3. Try this: >> >> epin.read(64, 100) >> >> 2010/9/27 Igor Mohor <igor.mo...@gmail.com>: >> > Dear Gentleman, >> > >> > I need your help. I'm trying to read some data from the USB by using the >> > folowing code and I get the error. >> > >> > >> > PythonWin 3.1.2 (r312:79147, Mar 22 2010, 12:20:29) [MSC v.1500 32 bit >> > (Intel)] on win32. >> > Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' >> > for >> > further copyright information. >> >>>> import usb.core >> >>>> import usb.util >> >>>> dev =usb.core.find(idVendor=0x04d8, idProduct=0x0204) >> >>>> dev.set_configuration() >> >>>> interface = dev.get_interface_altsetting() >> >>>> ep = usb.util.find_descriptor(interface, >> > ... custom_match = \ >> > ... lambda e: \ >> > ... usb.util.endpoint_direction(e.bEndpointAddress) == \ >> > ... usb.util.ENDPOINT_OUT) >> >>>> epin = usb.util.find_descriptor( >> > ... interface, >> > ... custom_match = \ >> > ... lambda e: \ >> > ... usb.util.endpoint_direction(e.bEndpointAddress) == \ >> > ... usb.util.ENDPOINT_IN) >> >>>> ep.write([0x80]) >> > 1 >> >>>> ep.write([0x80]) >> > 1 >> >>>> ep.write([0x80]) >> > 1 >> >>>> ep.write([0x81]) >> > 1 >> >>>> epin.read(64) >> > Traceback (most recent call last): >> > File "<interactive input>", line 1, in <module> >> > File "C:\Python31\lib\site-packages\usb\core.py", line 273, in read >> > return self.device.read(self.bEndpointAddress, size, self.interface, >> > timeout) >> > File "C:\Python31\lib\site-packages\usb\core.py", line 624, in read >> > self.__get_timeout(timeout) >> > File "C:\Python31\lib\site-packages\usb\_debug.py", line 53, in >> > do_trace >> > return f(*args, **named_args) >> > File "C:\Python31\lib\site-packages\usb\backend\libusb01.py", line >> > 448, in >> > bulk_read >> > timeout) >> > File "C:\Python31\lib\site-packages\usb\backend\libusb01.py", line >> > 524, in >> > __read >> > buffer = array.array('B', '\x00' * size) >> > TypeError: an integer is required >> >>>> >> > >> > >> > When I execute the same code on the following system: >> > >> > Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit >> > (Intel)] >> > on win32 >> > Type "copyright", "credits" or "license()" for more information. >> > >> > I get the correct response which is: >> > >> >>>> epin.read(64) >> > array('B', [129, 1, 133, 74, 20, 208, 66, 49, 65, 160, 28, 16, 2, 88, >> > 146, >> > 82, 4, 0, 64, 8, 4, 131, 20, 108, 130, 30, 1, 37, 1, 84, 138, 23, 146, >> > 2, >> > 214, 0, 74, 96, 6, 76, 32, 220, 19, 68, 128, 200, 32, 6, 44, 148, 10, 9, >> > 22, >> > 128, 58, 96, 34, 132, 0, 2, 109, 0, 2, 50]) >> >>>> >> > >> > >> > >> > Can somebody help me to get the data also with version 3.1.2. >> > >> > Thanks and best regards, >> > Igor >> > >> > >> > >> > >> > >> > ------------------------------------------------------------------------------ >> > Start uncovering the many advantages of virtual appliances >> > and start using them to simplify application deployment and >> > accelerate your shift to cloud computing. >> > http://p.sf.net/sfu/novell-sfdev2dev >> > _______________________________________________ >> > pyusb-users mailing list >> > pyusb-users@lists.sourceforge.net >> > https://lists.sourceforge.net/lists/listinfo/pyusb-users >> > >> > >> >> >> >> -- >> Best Regards, >> Wander Lairson Costa >> >> >> ------------------------------------------------------------------------------ >> Start uncovering the many advantages of virtual appliances >> and start using them to simplify application deployment and >> accelerate your shift to cloud computing. >> http://p.sf.net/sfu/novell-sfdev2dev >> _______________________________________________ >> pyusb-users mailing list >> pyusb-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/pyusb-users > > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing. > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > pyusb-users mailing list > pyusb-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pyusb-users > > -- Best Regards, Wander Lairson Costa ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users