evantahler / nodePhidgets

Node.js JavaScript library to interface with the Phidgets line of hardware boards.
Other
30 stars 8 forks source link

Won't connect to multiple boards #5

Closed gruppler closed 9 years ago

gruppler commented 9 years ago

This works great when I'm using only one board. However, I can't get it to connect to multiple boards. I can see all the boards in the Phidget Control Panel, and I've tried stopping and restarting both the webservice and the node app.

It seems to connect only to the board that was last attached. If I unplug the board that the node app currently sees, it will then connect to the other board, but when I plug the original in again, the node app doesn't reconnect to it. In other words, it will only connect to one board at a time, and that board is the one that was last plugged in.

evantahler commented 9 years ago

Are you saying that you have many boards connected to a single computer (or SBC) which is running one instance of the phidget web service? After you get the connected event, can you confirm that you see all the ids of the boards on the object?

gruppler commented 9 years ago

I have two boards connected to the same computer, running a single instance of the Phidget web service. Neither is an SBC.

My initialization code is copied straight from the example in the readme.

After I get a connect event, I see exactly one board ID. If I print out phidgets.ids at each input event, I can confirm that the module is seeing only one board.

If I unplug that board and plug it in again, the node module then connects to the other board (but doesn't trigger a 'state' event). I can then see both board IDs in phidgets.ids, but the original board no longer triggers any events.

If I then unplug and reattach whatever board is triggering input events, it stops working and the other board starts working. I've tried going back and forth, and this happens without fail.

Any ideas?

gruppler commented 9 years ago

[state] connecting
listening on *:80
[ 136718 ]                    // phidgets.ids
[136718] 15 = 1
[ 136718 ]
[136718] 14 = 1
[ 136718 ]
[136718] 13 = 1
[ 136718 ]
[136718] 12 = 1
[ 136718 ]
[136718] 11 = 1
[ 136718 ]
[136718] 10 = 1
[ 136718 ]
[136718] 9 = 1
[ 136718 ]
[136718] 8 = 1
[ 136718 ]
[136718] 7 = 1
[ 136718 ]
[136718] 6 = 1
[ 136718 ]
[136718] 5 = 1
[ 136718 ]
[136718] 4 = 1
[ 136718 ]
[136718] 3 = 1
[ 136718 ]
[136718] 2 = 1
[ 136718 ]
[136718] 1 = 0
[ 136718 ]
[136718] 0 = 1
[state] connected
connected to PhidgetBoards:
[ 136718 ]
a user connected              // socket.io debug message
[ 136718 ]
[136718] 9 = 1
[ 136718 ]
[136718] 8 = 1
[ 136718 ]
[136718] 7 = 1
[ 136718 ]
[136718] 6 = 1
[ 136718 ]
[136718] 5 = 1
[ 136718 ]
[136718] 4 = 1
[ 136718 ]
[136718] 3 = 1
[ 136718 ]
[136718] 2 = 1
[ 136718 ]
[136718] 15 = 1
[ 136718 ]
[136718] 14 = 1
[ 136718 ]
[136718] 13 = 1
[ 136718 ]
[136718] 12 = 1
[ 136718 ]
[136718] 11 = 1
[ 136718 ]
[136718] 10 = 1
[ 136718 ]
[136718] 1 = 0
[ 136718 ]
[136718] 0 = 1
[ 136718, 171961 ]            // I just unplugged and reattached board 136718
[171961] 7 = 0
[ 136718, 171961 ]
[171961] 6 = 0
[ 136718, 171961 ]
[171961] 5 = 0
[ 136718, 171961 ]
[171961] 4 = 0
[ 136718, 171961 ]
[171961] 3 = 0
[ 136718, 171961 ]
[171961] 2 = 0
[ 136718, 171961 ]
[171961] 1 = 1
[ 136718, 171961 ]            // I start turning knobs on both boards,
[171961] 0 = 1                // but 136718 doesn't respond
[ 136718, 171961 ]
[171961] 1 = 0
[ 136718, 171961 ]
[171961] 0 = 0
[ 136718, 171961 ]
[171961] 1 = 1
[ 136718, 171961 ]
[171961] 0 = 1
[ 136718, 171961 ]
[171961] 0 = 0
[ 136718, 171961 ]
[171961] 1 = 0
gruppler commented 9 years ago

I also noticed that in the list of attached devices (in the General tab of the Phidget Control Panel), the first device in the list is the one that works. If I unplug that device and plug it in again, it appears at the bottom of the list.

So, another way to describe the behavior is that it seems only the first board in that list is accessible via the web service. I plan to investigate whether this is a problem with your module or with the Phidget Control Panel.

asida18 commented 9 years ago

@gruppler https://github.com/RIAEvangelist/nodePhidgetAPI npm install phidgetsapi

This one works well for me!

evantahler commented 9 years ago

We just had a major refactor thanks to https://github.com/evantahler/nodePhidgets/pull/8. The API is changed siginifangly now, but this should be solved.