Occasionally Host PC cannot attach to the Phidget VINT Hub

Comments & issues
tszajner
Fresh meat
Posts: 2
Joined: Thu Dec 06, 2018 3:44 pm
Contact:

Occasionally Host PC cannot attach to the Phidget VINT Hub

Postby tszajner » Tue Dec 18, 2018 3:15 pm

Hi,

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)



IMPORTANT you need to run the script in a loop from bash i.e. so that the library reloads (?) each time

Code: Select all

for i in {1..250}; do python3 phidgets_never_attaches.py ; done


When it fails, it outputs the following error to stdout/stderr

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


Attached are the debug logs when it works versus when it does not work. The main difference is that when it doesn't work, it uses the Interrupt OUT Endpoint, instead of the Control Endpoint

Thanks,
Tomasz
Attachments
bad.log
(41.42 KiB) Downloaded 61 times
good.log
(14.04 KiB) Downloaded 65 times

User avatar
Patrick
Lead Developer
Posts: 3056
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Occasionally Host PC cannot attach to the Phidget VINT Hub

Postby Patrick » Wed Dec 19, 2018 11:42 am

I've reproduced the error. Looking into it.

-Patrick

User avatar
Patrick
Lead Developer
Posts: 3056
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Occasionally Host PC cannot attach to the Phidget VINT Hub

Postby Patrick » Wed Dec 19, 2018 2:33 pm

This bug is fixed, and library released.

-Patrick

tszajner
Fresh meat
Posts: 2
Joined: Thu Dec 06, 2018 3:44 pm
Contact:

Re: Occasionally Host PC cannot attach to the Phidget VINT Hub

Postby tszajner » Mon Jan 14, 2019 2:39 pm

Thanks Patrick. I tested the new library and the issue has been fixed :D


Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest