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)