-Sarah
--- On Mon, 2/28/11, Sarah Messer <ikust...@yahoo.com> wrote: From: Sarah Messer <ikust...@yahoo.com> Subject: Re: [pyusb-users] TypeError with legacy DeviceHandle.claimInterface(Interface) To: "wander.lairson" <wander.lair...@gmail.com> Date: Monday, February 28, 2011, 2:02 PM I'm sorry, Wander - I seem to be missing some things which are obvious to you. Which buffer has heterogeneous data? If I use locstr='\x01\x01\xfe\x00\x07\x00\x00\x00\x01\x00\x00\x00loc all\x00\x00\x00' for x in range(len(locstr)): type(locstr[x]) each element of the string is reported to be of type 'str'. Ditto for locstr=['\x01', '\x01', '\xfe', '\x00', '\x07', '\x00', '\x00', '\x00', '\x01', '\x00', '\x00', '\x00', 'l', 'o', 'c', ' ', 'a', 'l', 'l', '\x00', '\x00', '\x00'] The hex codes are non-printable ASCII characters, but it seems they should still be valid characters / unit-length strings. If I need to manually convert the input string to an array of short ints or some such, I can do that - just tell me what I should be going for. The examples look like straight ASCII character strings. I take it that it's libusb 1.0 which handles the bTag etc.? [libusb0.1+pyusb0.4] certainly didn't do it, and the debug messages from pyusb1.0 look like the data's passed to the libusb without any padding or computation of these fields, e.g.: >>> locunistr=u'\x01\x01\xfe\x00\x07\x00\x00\x00\x01\x00\x00\x00loc >>> all\x00\x00\x00' >>> bo.write(locunistr,timeout=4000) 2011-02-28 14:01:06,129 DEBUG:usb.backend.libusb10:_LibUSB.get_configuration_descriptor(<usb.backend.libusb10._Device object at 0x82552cc>, 0) 2011-02-28 14:01:06,129 DEBUG:usb.backend.libusb10:_LibUSB.get_interface_descriptor(<usb.backend.libusb10._Device object at 0x82552cc>, 0, 0, 0) 2011-02-28 14:01:06,130 DEBUG:usb.backend.libusb10:_LibUSB.get_configuration_descriptor(<usb.backend.libusb10._Device object at 0x82552cc>, 0) 2011-02-28 14:01:06,130 DEBUG:usb.backend.libusb10:_LibUSB.bulk_write(c_void_p(136900144), 6, 0, array('u', u'\x01\x01\xfe\x00\x07\x00\x00\x00\x01\x00\x00\x00loc all\x00\x00\x00'), 4000) i.e. the string that I passed in is the same one that pyusb 1.0 hands to array() (bo is the bulk-out Endpoint) Thanks again... -Sarah --- On Mon, 2/28/11, wander.lairson <wander.lair...@gmail.com> wrote: From: wander.lairson <wander.lair...@gmail.com> Subject: Re: [pyusb-users] TypeError with legacy DeviceHandle.claimInterface(Interface) To: "Sarah Messer" <ikust...@yahoo.com> Date: Monday, February 28, 2011, 1:23 PM 2011/2/28 Sarah Messer <ikust...@yahoo.com> Some of the errors I'm running into seem to be related to unicode vs. ASCII conversions. Should I be passing data as a unicode string? array of length-1 unicode characters? array of length-1 ASCII characters? or an ASCII string? (I'm having trouble with all of them, but under pyusb 0.4, both ASCII strings and an array of length-1 ASCII characters worked.) Also, does pyusb 1.0 automatically put in the padding & formatting called for by the USB spec? (i.e. the fields "msgID", "bTag", bTag's inverse, length of message, and the padding which makes the overall length a multiple of 4 bytes long) I was manually computing all these in pyusb 0.4, but the examples for pyusb 1.0 doesn't show such constructions. (I've tried both variants without luck....) This kind of stuff is actually managed by low level driver. The exception is related to unicode because the code to manage buffer convertion is being reported by the fall through case in that it assumes data is unicode. The real problem is the non-homogeneous data types in the buffer.
------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users