rawhid_send on MacOS 10.11 working on teensy2++, not on teensy2

heimi

Active member
I am using the file usb_rawhid.c with teensy2++ in my projects for years in various projects with MacOS, now in a CNC-application with Xcode7/MacOS 10.11.
Now trying to work with a teensy2 because of its smaller footprint, I am no more able to send records.
In the file hid.c the function
int rawhid_send(int num, void *buf, int len, int timeout)
{
//fprintf(stderr,"rawhid_send num: %d\n",num);
hid_t *hid;
int result=-100;
hid = get_hid(num);
if (!hid || !hid->open) return -1;
#if 1
#warning "Send timeout not implemented on MACOSX"
IOReturn ret = IOHIDDeviceSetReport(hid->ref, kIOHIDReportTypeOutput, 0, buf, len);
result = (ret == kIOReturnSuccess) ? len : -1;
//fprintf(stderr,"rawhid_send B result: %d\n",result);
#endif
#if 0
// No matter what I tried this never actually sends an output
// report and output_callback never gets called. Why??
// Did I miss something? This is exactly the same params as
// the sync call that works. Is it an Apple bug?
// (submitted to Apple on 22-sep-2009, problem ID 7245050)
//
fprintf(stderr,"rawhid_send C\n");
IOHIDDeviceScheduleWithRunLoop(hid->ref, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
// should already be scheduled with run loop by attach_callback,
// sadly this doesn't make any difference either way
//
IOHIDDeviceSetReportWithCallback(hid->ref, kIOHIDReportTypeOutput,
0, buf, len, (double)timeout / 1000.0, output_callback, &result);
while (1)
{
//fprintf(stderr,"enter run loop (send)\n");
CFRunLoopRun();
// fprintf(stderr,"leave run loop (send)\n");
if (result > -100) break;
if (!hid->open)
{
result = -1;
break;
}
}
#endif
//fprintf(stderr,"rawhid_send end result: %d\n",result);
return result;
}
gives me an error in the line
IOReturn ret = IOHIDDeviceSetReport(...
Checked with the debugger, I can see that the device is enumerated. I can read data from it.

The call of the function is
char* sendbuffer;
sendbuffer=malloc(32);
sendbuffer[16]=0xE0;
sendbuffer[20]=pwm;
int senderfolg= rawhid_send(0, sendbuffer, 32, 50);
sendbuffer[16]=0x00;
free(sendbuffer);

The same project built for teensy2++ works as expected.
Are there differences in any settings between the two devices?


log entry in the console for that issue:

Startup:
18.09.2016 15:29:44.351 Digital_Power_Interface[67620]: USBOpen: found rawhid device hid_usbstatus: 1

Sending a request: Spinning wheel.
After hanging: no entry until attempt to close the application:
18.09.2016 15:30:00.632 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-350.0.21.9
[67621]: Got a 'k' packet, killing the inferior process.
18.09.2016 15:30:00.632 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-350.0.21.9
[67621]: Sending ptrace PT_KILL to terminate inferior process.
18.09.2016 15:30:00.632 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-350.0.21.9
[67621]: 1 +0.000000 sec [10825/0307]: error: :trace (request = PT_THUPDATE, pid = 0x10824, tid = 0x1603, signal = 0) err = Resource busy (0x00000010)
18.09.2016 15:30:00.635 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-350.0.21.9
[67621]: 2 +0.002175 sec [10825/0307]: error: ::task_threads ( task = 0x1103, thread_list => 0x0, thread_list_count => 0 ) err = (os/kern) failure (0x00000005)
18.09.2016 15:30:00.635 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-350.0.21.9
[67621]: 3 +0.000198 sec [10825/0307]: error: ::task_info ( target_task = 0x1103, flavor = TASK_BASIC_INFO, task_info_out => 0x7fff5e952ca0, task_info_outCnt => 10 ) err = (os/kern) invalid argument (0x00000004)
18.09.2016 15:30:00.646 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-350.0.21.9
[67621]: Waited 10 ms for process to be reaped (state = Exited)
18.09.2016 15:30:00.646 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-350.0.21.9
[67621]: 4 +0.011456 sec [10825/1003]: error: ::read ( 3, 0x700000080a40, 1024 ) => -1 err = Bad file descriptor (0x00000009)
 
Back
Top