I've noticed that on rare occasions (~1% of the time), the Phidget22 library cannot attach to my Phidget VINT Hub. Attached is the Python Script I run.
Code: Select all
import time
from Phidget22.Devices.DigitalOutput import DigitalOutput
from Phidget22.PhidgetException import PhidgetException
from Phidget22.Devices.Log import Log
from Phidget22.LogLevel import *
def ErrorEvent(e, eCode, description):
print("Error %i : %s" % (eCode, description))
def main(port1, port2):
ch1 = DigitalOutput()
ch2 = DigitalOutput()
ch1.setOnErrorHandler(ErrorEvent)
ch2.setOnErrorHandler(ErrorEvent)
ch1.setHubPort(port1)
ch2.setHubPort(port2)
ch1.setIsHubPortDevice(1)
ch2.setIsHubPortDevice(1)
try:
# Wait at most 10 seconds to attach the port, returns as soon as the port is found
ch1.openWaitForAttachment(10000)
ch2.openWaitForAttachment(10000)
except PhidgetException as err:
print("Caught exception {0} while attaching to Phidget, retrying once".format(err))
time.sleep(5)
# If openWaitForAttachment() fails, that means we encountered a bug with
# the Phidget USB driver
ch1.openWaitForAttachment(10000)
ch2.openWaitForAttachment(10000)
ch1.setState(1)
print("Success")
return
if __name__=="__main__":
timestamp = time.time()
logfile = "test_" + str(timestamp)
print(timestamp)
Log.enable(LogLevel.PHIDGET_LOG_VERBOSE, logfile)
main(3,4)
Code: Select all
for i in {1..250}; do python3 phidgets_never_attaches.py ; done
Code: Select all
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Error 5 : Local open failed with error: 0x1c - Unexpected Error
Thanks,
Tomasz