Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

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

  1. #1
    Junior Member
    Join Date
    Aug 2017

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

    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:

  2. #2
    Junior Member
    Join Date
    Aug 2017
    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.

  3. #3
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Colmar, France
    Have you tried to kill the HID demon (hidd) ?

  4. #4
    Junior Member
    Join Date
    Aug 2017
    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 by 200ok; 08-04-2017 at 02:44 AM. Reason: Typo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts