getAttachedDevices in Phidget22

Supporting 2.7 and 3.2+
Post Reply
atthe
Phidgetsian
Posts: 7
Joined: Tue Feb 02, 2010 3:26 pm
Contact:

getAttachedDevices in Phidget22

Post by atthe »

Hello,

this is not really Python question but rather Phidget22 API, but I use python for coding so question is here. I used to get list of Phidgets devices with Manager's getAttachedDevices() function and can't see how to do that now with new API. Please advice correct way.

Thank you.
atthe
Phidgetsian
Posts: 7
Joined: Tue Feb 02, 2010 3:26 pm
Contact:

Re: getAttachedDevices in Phidget22

Post by atthe »

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?
atthe
Phidgetsian
Posts: 7
Joined: Tue Feb 02, 2010 3:26 pm
Contact:

Re: getAttachedDevices in Phidget22

Post by atthe »

ok, found that 'Segmentation Fault' is absent on older Debian platform and present only on Ubuntu 16.04 - probably my fault with compilation (not sure how I was able to miss something with ./configure; make). And listening of all 'attached' events after starting of Manager seems can provide all information about present devices.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests