Using setDeviceSerialNumber()

Comments & issues
Post Reply
john14519
Phidgetsian
Posts: 6
Joined: Sat Jan 11, 2020 10:59 am
Contact:

Using setDeviceSerialNumber()

Post by john14519 »

This is some pared down code that basically turns on the Power Plug Phidget (Python).

def main():
#Create your Phidget channels

digitalOutput3 = DigitalOutput() # Power Plug Phidget, ID: PSU1000_0

<< other code re other Vints is omitted for clarity >>

digitalOutput3.setIsHubPortDevice(True)
digitalOutput3.setHubPort(3)

digitalOutput3.openWaitForAttachment(5000)

digitalOutput3.setDutyCycle(1)

time.sleep(1.0)

digitalOutput3.setDutyCycle(0)
digitalOutput3.close()

main()
======================= END OF CODE ===================

I had a long period where this code worked, until the following:
a. three months where I didn't use the phidgets,
b. numerous system updates,
c. some updates to the Phidget drivers.

Then the code did not seem to turn the relay driver on and off.

I now find that if I add this line:
digitalOutput3.setDeviceSerialNumber(538442)
things work as I expect.

I'll accept that I should have added setDeviceSerialNumber all along (I was using it for AnalogOutput on the same Vint, but for some reason I didn't have it on the digitalOutput. What was the reason this actually worked once?
I notice the web site example for Phidget PSU1000_0 does not have setDeviceSerialNumber as part of the sample code. How would it know *which* Vint you want?
Does the order that I connect a 2nd Vint to my laptop matter? Does the code find the right Vint sometimes but not others if you don't specify the SerialNumber?
thanks,
John
jdecoux
Labview Developer
Posts: 180
Joined: Mon Nov 13, 2017 10:20 am
Contact:

Re: Using setDeviceSerialNumber()

Post by jdecoux »

The order of devices connecting to an unspecified channel is not guaranteed. If you want to connect to a specific Phidget, you will need to be specific in your addressing parameters (e.g. setDeviceSerialNumber).

The only time you can reasonably expect to connect to the right device without specifying all of the addressing parameters is when there is only one of the given class of Phidget in your system that matches the given subset of parameters. (e.g. one Hub-Port-Device on Port 3, in your case)

This means your code as written should work as long as there is only one VINT Hub available to your system, but all bets are off once a second Hub is added.

I hope that helps clear some things up,
James
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests