[Solved]Open hub vin error
Posted: Wed Dec 22, 2021 6:15 am
I have read different guides and I am struggling to get this working.
Basically I have SBC device and I have created a project which I want to access to my Digital input on Port 0.
I have this sensor connected: https://www.phidgets.com/?tier=3&catid= ... prodid=399
Using the web interface of the SBC, I can access the status and see it changing correctly, so I know that wiring and system is fully working.
Now I want to access to Digital Input on port 0 using Python, I have used the code generator on the website and set my serial number, hub port and IP of my server ( which is localhost anyway but I used the IP )
I read on other posts that if I am running a web interface on SBC, I need to use setIsRemote otherwise it wont be able to access the VIN Hub so I did so.
Output of the script:
Log file
Any clue?
Basically I have SBC device and I have created a project which I want to access to my Digital input on Port 0.
I have this sensor connected: https://www.phidgets.com/?tier=3&catid= ... prodid=399
Using the web interface of the SBC, I can access the status and see it changing correctly, so I know that wiring and system is fully working.
Now I want to access to Digital Input on port 0 using Python, I have used the code generator on the website and set my serial number, hub port and IP of my server ( which is localhost anyway but I used the IP )
I read on other posts that if I am running a web interface on SBC, I need to use setIsRemote otherwise it wont be able to access the VIN Hub so I did so.
Code: Select all
from Phidget22.Phidget import *
from Phidget22-Net import *
from Phidget22-Devices.Log import *
from Phidget22-LogLevel import *
from Phidget22-Devices.DigitalInput import *
import time
def onDigitalInput0_StateChange(self, state):
print("State: " + str(state))
def main():
Log.enable(LogLevel.PHIDGET_LOG_INFO, "phidgetlog.log")
Net.enableServerDiscovery(PhidgetServerType.PHIDGETSERVER_DEVICEREMOTE)
digitalInput0 = DigitalInput()
digitalInput0.setHubPort(0)
digitalInput0.setIsRemote(True)
digitalInput0.setDeviceSerialNumber(592908)
digitalInput0.setOnStateChangeHandler(onDigitalInput0_StateChange)
digitalInput0.openWaitForAttachment(20000)
time.sleep(5)
digitalInput0.close()
main()
root@phidgetsbc:/usr/userapps/framewalk# python3 s4-py
Traceback (most recent call last):
File "s4-py", line 29, in <module>
main()
File "s4-py", line 23, in main
digitalInput0.openWaitForAttachment(20000)
File "/usr/local/lib/python3.5/dist-packages/Phidget22/Phidget-py", line 574, in openWaitForAttachment
raise PhidgetException(result)
Phidget22.PhidgetException.PhidgetException: PhidgetException 0x03 (Timed Out)
No matching devices were found to open. Make sure your device is attached, and that your addressing parameters are specified correctly. If your Phidget has a plug or terminal block for external power, ensure it is plugged in and powered.
Make sure to enable server discovery, or add the server, and to set the server password if autentication is enabled.
Log file
There is no evidence that it cant access because it says it has done the handshake but I cant understand how to read the sensor state from python.# cat phidgetlog.log
2021-12-22T12:12:55 <Info> phidget22 :
****************************** Logging Enabled ******************************
* Phidget22 - Version 1.8 - Built Dec 2 2021 22:01:14 *
* Release 1.8 - Linux (32-bit) *
*******************************************************************************
2021-12-22T12:12:55 <Info> phidget22net[PhidgetNet_start()] : Starting Networking
2021-12-22T12:12:55 <Info> phidget22net[deviceServerListener()] : Discovered server 'srvframe' [srvframe] (interface 0x2)
2021-12-22T12:12:55 <Info> phidget22netctl[PhidgetNet_discoveredServer()] : Discovered Server: srvframe
2021-12-22T12:12:55 <Info> phidget22net[deviceServerListener()] : Discovered server 'srvframe' [srvframe] (interface 0x2)
2021-12-22T12:12:55 <Info> phidget22netctl[runNetworkControlEntry()] : network control entry thread started - srvframe: 0xb4cff470
2021-12-22T12:12:55 <Info> phidget22netctl[PhidgetNet_discoveredServer()] : Discovered Server: srvframe
2021-12-22T12:12:55 <Info> phidget22netctl[runNetworkControlEntry()] : network control entry srvframe not connected (failures=0)
2021-12-22T12:12:55 <Info> phidget22netctl[PhidgetNet_discoveredServer()] : network control entry for srvframe rediscovered
2021-12-22T12:12:55 <Info> phidget22netctl[runNetworkControlEntry()] : network control entry srvframe: connecting to srvframe (192.168.50.155:5661)
2021-12-22T12:12:55 <Info> phidget22[deviceAttach()] : (Attach) HUB0004 (6-Port PhidgetSBC VINT Hub Phidget) v203 S/N:592908
2021-12-22T12:12:55 <Info> phidget22[populateAttachedSPIDevices()] : Found SPI VINT Hub: 0x0001, 203, 592908
2021-12-22T12:12:55 <Info> phidget22usb[PhidgetUSBScanDevices()] : Initializing libusb
2021-12-22T12:12:55 <Info> phidget22net[clientConnect()] : Starting client connection to '192.168.50.155:5661'
2021-12-22T12:12:55 <Info> phidget22net[startClientConnection()] : server handshake 'phid22device' 2.3
2021-12-22T12:12:55 <Info> phidget22net[startClientConnection()] : connected to server 'srvframe'
2021-12-22T12:12:55 <Info> phidget22netctl[runNetworkControlEntry()] : network control entry srvframe connected to srvframe:5661
2021-12-22T12:12:55 <Info> phidget22[deviceAttach()] : (Attach) HUB0004 (6-Port PhidgetSBC VINT Hub Phidget) v203 S/N:592908 -> srvframe
2021-12-22T12:12:55 <Info> phidget22net[handleDeviceClientRequest()] : server netconnclient://192.168.50.155:5661 starting DATAGRAM as requested
2021-12-22T12:12:55 <Info> phidget22[deviceAttach()] : (Attach) Dictionary (Dictionary) v100 S/N:2 Label:Phidget22 Control -> srvframe
Any clue?