Phidget manager not reentrant?

Supporting 10.7 and up
dkatz42
Phidgetly
Posts: 30
Joined: Mon Feb 07, 2011 1:14 am
Contact:

Phidget manager not reentrant?

Postby dkatz42 » Mon Feb 07, 2011 1:32 am

I'm building a Cocoa app to use as a front-end to an app on the SBC (long story, I'm insane.)

The first thing that the app does is to listen to Bonjour advertisements to find all of the servers on the network, and then opens Phidget Manager connections to each of them to find all of the devices on the network (I may end up with multiple SBCs; right now I'm testing with an SBC along with a LED controller plugged directly into another Mac).

My code calls CPhidgetManager_create multiple times in quick succession, with different handle pointers, and gets different handles back. However, I sometimes get extra attach callbacks, with the same module showing up as being attached to both managers. If I only open one manager at a time, I see the right thing (only the directly attached modules). I also checked the WebService dictionaries on each device, and they show the right things (only the directly attached devices). I considered reentrancy problems in my own code, but I have verified that the attach routine is being called too often, so it smells like a library issue.

Can you suggest anything I might be screwing up, or is the manager code not intended to work in this manner?

FWIW, I'm doing this on a two-core laptop, so I very well may be getting parallel execution.

Thanks in advance.

phidget.tiff
phidget.tiff (64.3 KiB) Viewed 1823 times

User avatar
Patrick
Lead Developer
Posts: 3078
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Phidget manager not reentrant?

Postby Patrick » Mon Feb 07, 2011 12:42 pm

Very interesting, I will have to look closely at the library.

Are you using the Bonjour API to manually listen for phidget_ws type services?

If you want to just list all phidgets on the network, on multiple computers, you should call CPhidgetManager_openRemote(phidm, NULL); - passing NULL for the serverID will have it listen to any serverID. This is how the Bonjour tab in the preference pane works.

-Patrick

dkatz42
Phidgetly
Posts: 30
Joined: Mon Feb 07, 2011 1:14 am
Contact:

Re: Phidget manager not reentrant?

Postby dkatz42 » Thu Feb 10, 2011 2:03 pm

Yep, I was using the Bonjour API to find each one, and then opening a separate manager for each. I'll try using NULL instead...

BTW, after I got past that problem (by only selecting one server) I started using the dictionary interface; my project involves having a Cocoa app on the Mac that lays out objects, then publishes them as key-value pairs for the code on the SBC to pick up and action. When I tried to blast dictionary entries, I started getting zillions of "socket closed" error callbacks. The first few entries would make it into the dictionary but then it would fail. I haven't taken the time to wade into this and sort it out yet, but I'm assuming that (a) this shouldn't happen, and (b) I should be able to pump arbitrary amounts of data via the dictionary calls at any rate, yes? (Presumably any backpressure from the data stream should result in the key add to block?)

I developed Cocoa wrappers around the dictionary stuff; I'll pull those out and build a simple test jig to try to narrow it down.

Thanks for being so responsive.

User avatar
Patrick
Lead Developer
Posts: 3078
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Phidget manager not reentrant?

Postby Patrick » Thu Feb 10, 2011 2:12 pm

Ok, I'll look at that issue as well.

-Patrick

dkatz42
Phidgetly
Posts: 30
Joined: Mon Feb 07, 2011 1:14 am
Contact:

Re: Phidget manager not reentrant?

Postby dkatz42 » Thu Feb 10, 2011 2:32 pm

Dang, that was fast. You guys rule. :D

--Dave

dkatz42
Phidgetly
Posts: 30
Joined: Mon Feb 07, 2011 1:14 am
Contact:

Re: Phidget manager not reentrant?

Postby dkatz42 » Mon Mar 07, 2011 3:59 pm

FYI, my issue with the dictionary (and getting errors back) seems to be an issue with my Cocoa app. When I wrote a wee C program that uses my wrapper functions, I can crank out a bunch of key/value pairs just fine. (But see the next item for where things go wrong...)


Return to “macOS”

Who is online

Users browsing this forum: No registered users and 1 guest