Can't setChannel properly

Technical Discussions on any InterfaceKits
Post Reply
Kyle
Phidgetsian
Posts: 13
Joined: Tue Jun 05, 2018 2:26 pm
Contact:

Can't setChannel properly

Post by Kyle »

I want to use Phidgets interface kit 1019 to read data from multiple analog inputs. However, I can read only from the default channel which is channel 0. below is my code as an example. I'm using Python. I printed out the ch1 before and after setChannel(1), but all of them gave me 0. Shouldn't I got 1 after setting channel to 1?

Hope anyone can help me address this problem.
BTW, I followed the steps here:
https://www.phidgets.com/docs/Phidget_P ... ing_Basics

ch1.openWaitForAttachment(5000)
ch1.setOnAttachHandler(onAttachHandler)
ch1.setDeviceSerialNumber(483362)
rospy.loginfo(ch1.getChannel())
ch1.setChannel(1)
rospy.loginfo(ch1.getChannel())
ch1.open()
User avatar
Patrick
Lead Developer
Posts: 634
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Can't setChannel properly

Post by Patrick »

Make sure you set the channel and serial number before calling open. Also, you are calling open twice - only call it once, after setting up serial, handlers, etc..

-Patrick
Kyle
Phidgetsian
Posts: 13
Joined: Tue Jun 05, 2018 2:26 pm
Contact:

Re: Can't setChannel properly

Post by Kyle »

Thank you Patrick, I didn't realize openWaitForAttachment also open the channel. It worked! Thanks for your quick reply again!
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests