Page 1 of 1

Sensor only works once.

Posted: Tue Jul 05, 2022 1:33 am
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).

Re: Sensor only works once.

Posted: Tue Jul 05, 2022 8:33 am
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.

Re: Sensor only works once.

Posted: Thu Jul 07, 2022 2:12 am
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.

Re: Sensor only works once.

Posted: Tue Jul 12, 2022 7:31 am
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)

Re: Sensor only works once.

Posted: Wed Jul 13, 2022 10:50 am
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