Timed Out exceptions attaching to Phidgets

Supporting 2.7 and 3.2+
aho
Fresh meat
Posts: 3
Joined: Mon May 07, 2018 7:25 pm
Contact:

Timed Out exceptions attaching to Phidgets

Postby aho » Tue May 29, 2018 3:30 pm

Hi. I'm trying to attach to Phidgets using Python3 library version: 'Phidget22 - Version 1.0.0 - Built May 2 2018 19:19:13'. I'm seeing random exception 3 (Timed Out) failures to connect to my Phidgets before eventually hitting a Segmentation Fault. My Phidgets are attached to a Raspberry Pi 3 B+ via a powered hub. Does the following snippet look correct?

Cheers!

Code: Select all

import datetime, time

import Phidget22.PhidgetException
import Phidget22.Devices.TemperatureSensor
import Phidget22.Devices.VoltageInput

conf = [ (295578, 0, Phidget22.Devices.TemperatureSensor.TemperatureSensor),
         (396610, 0, Phidget22.Devices.TemperatureSensor.TemperatureSensor),
         (396610, 1, Phidget22.Devices.TemperatureSensor.TemperatureSensor),
         (396610, 2, Phidget22.Devices.TemperatureSensor.TemperatureSensor),
         (396610, 3, Phidget22.Devices.TemperatureSensor.TemperatureSensor),
         (464464, 1, Phidget22.Devices.VoltageInput.VoltageInput) ]

for loop in range(1000):
    for (serial_number, channel, phidgetClass) in conf:
        phidget = phidgetClass()
        phidget.setDeviceSerialNumber(serial_number)
        phidget.setChannel(channel)
        phidget.setIsLocal(True)
        phidget.setIsRemote(False)
        try:
            phidget.openWaitForAttachment(500)
        except Phidget22.PhidgetException.PhidgetException as e:
            print(datetime.datetime.now(), loop, serial_number, channel, "open exception {}: {}".format(e.code, e.details))
            continue

        try:
            phidget.close()
        except Phidget22.PhidgetException.PhidgetException as e:
            print(datetime.datetime.now(), loop, serial_number, channel, "close exception {}: {}".format(e.code, e.details))
        time.sleep(0.1)
    if loop % 5 == 0:
        print(datetime.datetime.now(), loop)


Return to “Python”

Who is online

Users browsing this forum: No registered users and 2 guests