Sensor only works once.

Supporting 2.7 and 3.2+
Post Reply
dirkiepower
Fresh meat
Posts: 3
Joined: Tue Jul 05, 2022 1:10 am
Contact:

Sensor only works once.

Post by dirkiepower »

We use the Nvidia Jetson Orin with Ubuntu 20.04.4 LTS.

After a reboot I can succesfully establish a connection with the HumiditySensor using the following script.

Code: Select all

from Phidget22.Devices.HumiditySensor import *

Phidget.resetLibrary()

#serial: 627720
def onHumiditySensor0_Attach(self):
    print(f"Attach HumiditySensor! {self.getHubPort()}")

hum = HumiditySensor()
hum.setOnAttachHandler(onHumiditySensor0_Attach)
hum.openWaitForAttachment(10000)
hum.close()
after that when I restart the script, I get TimeOut errors. So it works only once. (after a reboot).
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Sensor only works once.

Post by mparadis »

Phidget channels can only be opened in one program or process at any given time, so it seems like for some reason your python script is still running after it closes. You can test this by using the ps command before and after running the python script for the first time.
dirkiepower
Fresh meat
Posts: 3
Joined: Tue Jul 05, 2022 1:10 am
Contact:

Re: Sensor only works once.

Post by dirkiepower »

mparadis wrote: Tue Jul 05, 2022 8:33 am Phidget channels can only be opened in one program or process at any given time, so it seems like for some reason your python script is still running after it closes. You can test this by using the ps command before and after running the python script for the first time.
Tested this, and this is not the case.
dirkiepower
Fresh meat
Posts: 3
Joined: Tue Jul 05, 2022 1:10 am
Contact:

Re: Sensor only works once.

Post by dirkiepower »

For everyone encountering this issue:

Solution:
Reset usb phidgets device by calling the python script from the following link: https://askubuntu.com/a/988297

Phidgets are working as expecting now.

(My platform is Jetson Orin Jetpack 5 Ubuntu 20.04.4 LTS)
User avatar
Patrick
Lead Developer
Posts: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Sensor only works once.

Post by Patrick »

You shouldn't need to call resetLibrary() - this is only useful for runtimes that don't unload the phidget22 library between runs, like Unity editor, Labview, etc.

If you enable library logging, it will probably give some clues as to what's going on.

-Patrick
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest