Question

We are trying to communicate with a USB HIDDevice. This device is working fine in windows, where we can send a report and get a report back using WriteFile() and ReadFile().

On the Mac, we are trying to interface with the device using setReoprt() and getReport(). But getReport() is not returning any data, but an error.

What is the wrong in the application?

Was it helpful?

Solution

In order to make use of asynchronous behavior, the event source obtained using getAsyncEventSource must be added to a run loop.

The above note is part of the comment of setReport. U might need to learn the runloop mechanism of Runloop in Mac OS first.

Since it's impossible to explain the mechanism here. The following functions and orders might help u coding when u get familiar with RunLoop.(Try to search "CFRunLoop" in google)

CFRunLoopGetCurrent();
CFRunLoopRun();
CFRunLoopAddSource(CFRunLoopRef rl, CFRunLoopSourceRef source, CFStringRef mode);
CFRunLoopStop(CFRunLoopRef rl);(i usually call this function in the callback method)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top