Tried to find all attached devices using OnAttached event, but this code is crashed:
Code: Select all
import time
from Phidget22.Devices.Manager import Manager
from Phidget22.Phidget import Phidget
manager = Manager()
def attached(manager, sensor):
print "something attached: %s at channel: %s" % (str(manager), str(sensor))
print sensor.getDeviceSerialNumber()
def detached(manager, channel):
print "something detached: %s at channel: %s" % (str(manager), str(channel))
manager.setOnAttachHandler(attached)
manager.setOnDetachHandler(detached)
manager.open()
while True:
time.sleep(0.1)
With output:
something attached: <Phidget22.Devices.Manager.Manager instance at 0x7f85597cdfc8> at channel: <Phidget22.Phidget.Phidget instance at 0x7f85583de200>
Segmentation fault
Seems like second parameter passed to OnAttached handler not really correct. When I comment out "print sensor.getDeviceSerialNumber()" I see 20 strings printed at address of second object is the same for all records:
something attached: <Phidget22.Devices.Manager.Manager instance at 0x7f37a8262050> at channel: <Phidget22.Phidget.Phidget instance at 0x7f37a8262248>
something attached: <Phidget22.Devices.Manager.Manager instance at 0x7f37a8262050> at channel: <Phidget22.Phidget.Phidget instance at 0x7f37a8262248>
something attached: <Phidget22.Devices.Manager.Manager instance at 0x7f37a8262050> at channel: <Phidget22.Phidget.Phidget instance at 0x7f37a8262248>
something attached: <Phidget22.Devices.Manager.Manager instance at 0x7f37a8262050> at channel: <Phidget22.Phidget.Phidget instance at 0x7f37a8262248>
How then can I found out what was attached?