From: Cameron D. <fo...@da...> - 2017-03-23 04:05:34
|
Two points: 1. the core read, write and ctrl_transfer operations have optional timeout args. (timeout=nnn) value in milliseconds 2. If the timeout is not simply because the you need a longer timeout, then you might benefit from something like I had to resort to: trap the USBErorr exception and check the error code. If it a timeout then you can try to reset/clean up or whatever is available with your device. Unfortunately, the timeout code varies with backend, so you need to knows what that is. If libusb0 then you might have more problems. Cameron. On 19-Mar-2017 09:43, Eddie A. Goble wrote: > Hello all: > > I am using a Raspberry PI 3 in attempts to control my Owi Robotic Arm > via USB with Python scripting. I am intermittently getting a "Operation > timed out" error which halts the code. 75% of the time the program runs > from start to finish with no problems. Any ideas on how I can mitigate > this? Is there a way to increase the timeout threshold? Many thanks in > advance. > > *Error:* > > Traceback (most recent call last): > > File "arm2.py", line 59, in <module> > > MoveArm("ShoulderUp",4.2) > > File "arm2.py", line 47, in MoveArm > > RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,3) > > File "build/bdist.linux-armv7l/egg/usb/core.py", line 711, in > ctrl_transfer > > File "build/bdist.linux-armv7l/egg/usb/backend/libusb1.py", line 836, > in ctrl_transfer > > File "build/bdist.linux-armv7l/egg/usb/backend/libusb1.py", line 571, > in _check > > usb.core.USBError: [Errno 110] Operation timed out > > > *From my Python script:* > > import usb.core, usb.util, time, sys > > RoboArm = usb.core.find(idVendor=0x1267, idProduct=0x000) > > if RoboArm is None: > > raise ValueError("Arm not found") > > Duration=1 > > def MoveArm(ArmCmd,Duration): > > if ArmCmd == "Base+": > > print "M5-%s : Rotate base clockwise" % Duration > > ArmCmd=[0,1,0] > > elif ArmCmd == "Base-": > > print "M5+%s : Rotate base counter clockwise" % Duration > > ArmCmd=[0,2,0] > > elif ArmCmd == "ShoulderDown": > > print "M4-%s : Shoulder down" % Duration > > ArmCmd=[64,0,0] > > elif ArmCmd == "ShoulderUp": > > print "M4+%s : Shoulder up" % Duration > > ArmCmd=[128,0,0] > > elif ArmCmd == "ElbowDown": > > print "M3-%s : Elbow down" % Duration > > ArmCmd=[16,0,0] > > elif ArmCmd == "ElbowUp": > > print "M3+%s : Elbow up" % Duration > > ArmCmd=[32,0,0] > > elif ArmCmd == "WristDown": > > print "M2-%s : Wrist down" % Duration > > ArmCmd=[4,0,0] > > elif ArmCmd == "WristUp": > > print "M2+%s : Wrist up" % Duration > > ArmCmd=[8,0,0] > > elif ArmCmd == "GripClose": > > print "M1-%s : Grip close" % Duration > > ArmCmd=[2,0,0] > > elif ArmCmd == "GripOpen": > > print "M1+%s : Grip open" % Duration > > ArmCmd=[1,0,0] > > elif ArmCmd == "LightOff": > > print "L1-%s : Light off" % Duration > > ArmCmd=[0,0,1] > > elif ArmCmd == "LightOn": > > print "L1+%s : Light on" % Duration > > ArmCmd=[0,0,0] > > else: > > print "Unknown command" > > sys.exit() > > > RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,3) > > time.sleep(Duration) > > ArmCmd=[0,0,0] > > RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,3) > > > #MoveArm("ShoulderUp",.1) > > #sys.exit() > > > MoveArm("Base+",7.7) > > MoveArm("ShoulderDown",4) > > MoveArm("ElbowDown",1) > > MoveArm("ElbowUp",1) > > MoveArm("ShoulderUp",4.2) > > MoveArm("Base-",8.4) > > sys.exit() > > Eddie A Goble > > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > > _______________________________________________ > pyusb-users mailing list > pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyusb-users > |