It is unclear from the documentation how the phidget22 library handles synchronization between a main loop and the phidget operations. Does the library use a separate thread or multiple threads? If so, how do I synchronize my main loop with the library to avoid race conditions (i.e. what are the design rules and api related to locking). If not a thread, when are phidget operations such as attach and detach called?
One other issue is that sometimes my calls to setdutycycle fail with the error code "unexpected". This doesn't seem to invoke the detach but subsequent calls to setdutycycle also fail and forcing an attach seems to cause a bunch of detach/attach cycles that eventually look like they cause massive failure. The error handler also does not seem to be called.