Better error if RCServo or DCMotor API Phidget opened elsewhere

What do you need Phidgets to do for you?
Rhybot
Phidgetly
Posts: 37
Joined: Wed Aug 14, 2019 4:58 pm
Contact:

Better error if RCServo or DCMotor API Phidget opened elsewhere

Postby Rhybot » Mon Jun 28, 2021 8:44 pm

If one does the following in Python with Phidget22==1.7.20210504:
1. Instantiate an RCServo or DCMotor API and connect to it via openWaitForAttachment at a particular address (serial number + port + channel combo)
2. Command the RCServo or DCMotor API to move around
3. Instantiate an RCServo or DCMotor API later on, and attempt to connect to it at the same address: the attachment fails with no special details or error code

Can you add a new error code/description for a duplicate connection attempt?

User avatar
mparadis
Site Admin
Posts: 852
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Better error if RCServo or DCMotor API Phidget opened elsewhere

Postby mparadis » Wed Jun 30, 2021 9:16 am

Did you set an error handler? There's already EPHIDGET_BUSY (Error 0x09) for this. This is what it looks like when you print the error string:

Code: Select all

Code: EEPHIDGET_BUSY
Description: Local device: <TMP1200 (RTD Phidget) v108 -> HUB0000 Port:0 S/N:561013> open failed because device is in use. Check that the Phidget is not already open in another program, such as the Phidget Control Panel, or another program you are developing.


Also if you're catching exceptions in your code, the Timeout exception will tell you if a matching device exists but is busy:

Code: Select all

Traceback (most recent call last):
  File "error.py", line 28, in <module>
    main()
  File "error.py", line 19, in main
    temperatureSensor0.openWaitForAttachment(5000)
  File "C:\Python27\lib\site-packages\Phidget22\Phidget.py", line 551, in openWaitForAttachment
    raise PhidgetException(result)
Phidget22.PhidgetException.PhidgetException: PhidgetException 0x03 (Timed Out)
Local device: <TMP1200 (RTD Phidget) v108 -> HUB0000 Port:0 S/N:561013> open failed because device is in use. Check that the Phidget is not already open in another program, such as the Phidget Control Panel, or another program you are developing.


Return to “Phidgets”

Who is online

Users browsing this forum: No registered users and 1 guest