out-of-order, but trying again to send this... -Sarah
--- On Fri, 2/25/11, Sarah Messer <ikust...@yahoo.com> wrote: From: Sarah Messer <ikust...@yahoo.com> Subject: Fw: Re: [pyusb-users] TypeError with legacy DeviceHandle.claimInterface(Interface) To: wander.lair...@gmail.com Date: Friday, February 25, 2011, 2:39 PM I tried reply-to-list, but I'm not sure if it went through.... -Sarah --- On Fri, 2/25/11, Sarah Messer <ikust...@yahoo.com> wrote: From: Sarah Messer <ikust...@yahoo.com> Subject: Re: [pyusb-users] TypeError with legacy DeviceHandle.claimInterface(Interface) To: pyusb-users@lists.sourceforge.net Date: Friday, February 25, 2011, 12:42 PM Thanks for the patch, Wander. I'm reporting a partial success. your patch fixes the claimInterface() call My code then crashes on the first attempt to write to a bulk-out endpoint on the device. Using my original claim-by-interface code with your patched usb/legacy.py gives the following output. (The first few lines are my own error/warning messages; the ultimate errors are further down in the Traceback): ------CODE OUTPUT----- Computing message header sending to address 0:7-6 with 4.000000-second timeout: ['\x01', '\x01', '\xfe', '\x00', '\x07', '\x00', '\x00', '\x00', '\x01', '\x00', '\x00', '\x00', 'l', 'o', 'c', ' ', 'a', 'l', 'l', '\x00'] Exception in thread OperateScope15: Traceback (most recent call last): File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner self.run() File "/usr/lib/python2.6/threading.py", line 484, in run self.__target(*self.__args, **self.__kwargs) File "./acquisition/ACQutil.py", line 390, in Operate self.Arm() File "./acquisition/ACQutil.py", line 420, in Arm self.Scope.arm(self.run._TrigStr) File "./acquisition/scope.py", line 504, in arm self.reset() File "./acquisition/scope.py", line 539, in reset self.write('loc all') #lock all File "./acquisition/scope.py", line 1036, in write self.hand.bulkWrite(self.bo.address,sending,scopetimeout*1000) File "/usr/local/lib/python2.6/site-packages/usb/legacy.py", line 148, in bulkWrite return self.dev.write(endpoint, buffer, self.__claimed_interface, timeout) File "/usr/local/lib/python2.6/site-packages/usb/core.py", line 601, in write _interop.as_array(data), File "/usr/local/lib/python2.6/site-packages/usb/_interop.py", line 134, in as_array return array.array('u', data) TypeError: array item must be unicode character ------/END CODE OUTPUT-------------- I'm also attaching the method which generated the above output: ----------CODE SNIPPET---------- def write(self, message): '''Sends a command to the USB scope and does not expect a response. declaration: write(self, message) message - the string to be sent to the scope.''' self.runlog.log(3,'Computing message header') msgID=chr(0x01) #DEV_DEP_MSG_OUT (cmd to Bulk-Out Endpoint) bTagInv=chr((~self.bTag)&(0xff)) #bitwise inverse(bTag) msg=list(message) msglen=len(msg) if msglen== 0: self.runlog.log(-1,'null message not allowed') #spec allows much longer lengths, but these #aren't yet implemented if msglen>255: self.runlog.log(-1,'message too long') #pad to a length with a multiple of 4 bytes if msglen%4 == 1 : msg.extend([chr(0x00),chr(0x00),chr(0x00)]) elif msglen%4 == 2 : msg.extend([chr(0x00),chr(0x00)]) elif msglen%4 == 3 : msg.extend([chr(0x00)]) #Force conversions to single-byte elements, #since Python prefers to use 16-bit integers #internally #self.runlog.log(3,'compiling full message') sending=[msgID,chr(self.bTag),bTagInv,NULL] sending.extend(Num2List(msglen)) sending.extend([chr(0x01),NULL,NULL,NULL]) sending.extend(msg) self.runlog.log(3,'sending to address %s-%d with %f-second timeout: %s'%(self.id[2], self.bo.address, scopetimeout, sending)) self.hand.bulkWrite(self.bo.address,sending,scopetimeout*1000) self.runlog.log(3,'message sent') self.bTag+=1 if self.bTag>255: self.bTag=0x01 ------------/END CODE SNIPPET----------- I also tried a work-around with the unpatched pyusb 1.0 and an integer (0) in place of the Interface in the call to claimInterface(). That yielded analogous results, although instead of a TypeError, I think I got a SegmentationFault. I'm going to branch my code into 1.0-friendly and 0.1-friendly versions. If you want to fire patches at me as you have time, I'll try running them through the 0.1-friendly code. In the meantime, I'll try to learn 1.0. What I've seen of 1.0 so far looks like it's much nicer than 0.1, but I'm still trying to learn how it goes. There also seems to be some changes since http://pyusb.sourceforge.net/docs/1.0/tutorial.html was written: Manually stepping through the sample code, I get AttributeError: 'Device' object has no attribute 'get_interface_altsetting' Thanks for putting all this together! As a general comment, I've just discovered "pydoc -w usb"... which makes me giddy. Giddy, I tell you. -Sarah --- On Wed, 2/23/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: pyusb-users@lists.sourceforge.net Date: Wednesday, February 23, 2011, 3:39 PM Please, find attached a little patch that should fix your problem. I could not test it because my dev machine died a month ago. Please, report if it worked thus I can commit it. Wander 2011/2/23 Sarah Messer <ikust...@yahoo.com> of course, as soon as I hit "send", i find this: http://pyusb.sourceforge.net/docs/1.0/tutorial.html ... -Sarah --- On Wed, 2/23/11, Sarah Messer <ikust...@yahoo.com> wrote: From: Sarah Messer <ikust...@yahoo.com> Subject: [pyusb-users] TypeError with legacy DeviceHandle.claimInterface(Interface) To: pyusb-users@lists.sourceforge.net Date: Wednesday, February 23, 2011, 2:55 PM Hello, I've recently updated my OS (to openSuSe 11.3), after changing my motherboard (long story). Probably more relevant is the fact that at the same time I'm going from pyusb 0.1ish to pyusb-1.0.0-a1 Code that had been working well is now going through the compatibility/legacy layer, which seems to _almost_ work. The issue appears when I claim the USB interface. Here's the tail of the traceback: File "./acquisition/scope.py", line 975, in _foundrightscope self.hand.claimInterface(self.face) File "/usr/local/lib/python2.6/site-packages/usb/legacy.py", line 225, in claimInterface util.claim_interface(self.dev, interface) File "/usr/local/lib/python2.6/site-packages/usb/util.py", line 191, in claim_interface device._ctx.managed_claim_interface(device, interface) File "/usr/local/lib/python2.6/site-packages/usb/core.py", line 112, in managed_claim_interface self.backend.claim_interface(self.handle, i) File "/usr/local/lib/python2.6/site-packages/usb/_debug.py", line 52, in do_trace return f(*args, **named_args) File "/usr/local/lib/python2.6/site-packages/usb/backend/libusb10.py", line 471, in claim_interface _check(_lib.libusb_claim_interface(dev_handle, intf)) ArgumentError: argument 2: <type 'exceptions.TypeError'>: wrong type "self.hand" is of type <class 'usb.legacy.DeviceHandle'> (It came from a call to "dev.open()", where "dev" is of type <class 'usb.legacy.Device'>.) "self.face" is of type <class 'usb.legacy.Interface'> The wiki page that I used to use for reference (http://wiki.erazor-zone.de/wiki:projects:python:pyusb:pydoc) doesn't appear to talk about conversion or use of the new & improved pyusb... Could someone tell me where to go for conversion / interface docs? I'd like to do as little code conversion as possible, but I'm not sure where to start. Thanks -Sarah -----Inline Attachment Follows----- ------------------------------------------------------------------------------ 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 -----Inline Attachment Follows----- _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users ------------------------------------------------------------------------------ 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 -----Inline Attachment Follows----- ------------------------------------------------------------------------------ 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 -----Inline Attachment Follows----- _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users
------------------------------------------------------------------------------ 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