RawHID works after restart, not after programming/upload on macOS 10.12

200ok

New member
C host code (stripped down from example) + Arduino sketch

Works great on a fresh reboot, but

Once I upload any sketch (even just once) with Teensyduino, the C code seems to hang forever on "IOHIDDeviceSetReport()" – it never returns unless I restart the computer. (Rebooting must reset something?)

The JS code hangs in the same spot, probably because it's backed by hidapi which uses IOKit.

Source code, including Makefile updates for OSX 10.12: https://gist.github.com/lacyrhoades/4569ea18ef7f34c4d6e9c9d2a0153f60
 
I'd add you don't have to run the programmer, and the programmer isn't doing anything wrong. This is macOS bug as far as I can tell, because:

Programming the teensy causes this, but also just unplugging / re-plugging it will do it.

Simpler steps to reproduce:
1. Teensy running in rawhid mode
2. Write output report to device
3. rawhid_send() works, device responds to packets
4. Unplug and replug device, never responds again
5. Reboot computer and things work OK until unplug

If you plug in a USB camera on macOS, you have to kill the process "PTPCamera" before you can talk to it with PTP over USB. That's not what's happening here but I suspect given this behavior, that something "claims" the teensy HID when you plug it in while the OS is fully awake. If you just boot the computer when the teensy is plugged in already, it's in some kind of "unclaimed" state and so it doesn't stall out.
 
I had not tried that but I have now: "sudo killall hidd"

Still no change. Unplugging & replugging (or programming) the board means IOHIDDeviceSetReport hangs on future attempts.

Interestingly, at no point does "hidutil list" show ANYTHING about the Teensy.

"system_profiler SPUSBDataType" does usually show it as "Teensyduino RawHID" regardless of if IOHIDDeviceSetReport is stalling.

Also interesting is that the "auto" programming feature works the FIRST time after a reboot. After that I do have to manually hit the reset button.

This conflicts with my understanding since I've read elsewhere about auto mode: "But if your code disables the USB port, or disables interrupts, or enters a deep sleep mode which stop the CPU, Teensy can not respond to the USB-based reboot..." So why doesn't that apply when Teensy 3.2 first starts with the computer? Using rawhid I thought qualified me for the "code disables the USB port" part.

I wonder if spoofing some "known" Vendor/Product ID will let it work.
 
Last edited:
Back
Top