Can't setChannel properly

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

Can't setChannel properly

Postby Kyle » Tue Jun 05, 2018 2:34 pm

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_Programming_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: 3067
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Can't setChannel properly

Postby Patrick » Tue Jun 05, 2018 3:11 pm

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

Postby Kyle » Tue Jun 05, 2018 3:18 pm

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


Return to “InterfaceKits”

Who is online

Users browsing this forum: No registered users and 0 guests