Page 1 of 1

Timed Out exceptions attaching to Phidgets

Posted: Tue May 29, 2018 3:30 pm
by aho
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)