Skip to content

Make it possible to detect if connected PC is running or shut down (Controllers with USB, 32u4) #7363

Closed
@M-Reimer

Description

@M-Reimer

For some USB device projects it would be handy to know if the PC, my device is connected to, is still running or has been shut down. This has become a problem especially with "newer" motherboards, which now usually always have power on the USB power leads.

A common way to do this is to check if "SOF" events are still generated. Possible place to detect this would be:
https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/USBCore.cpp#L760
In another project (STM32 without Arduino libraries), I just used a timer interrupt counting up a variable. Then I reset this to zero every time a SOF event happens.
In my other code, I can now check the value of my variable. If it reaches a defined limit, the PC must have been shut down as the "resets to zero" no longer happen.

There may be simpler/better ways to do this in the Arduino core libraries and some API also has to be defined. Maybe you could consider adding such a feature. Would be very useful!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: HardwareRelated to the design of Arduino's hardware productsComponent: USB DeviceOpposed to USB Host. Related to the USB subsystem (SerialUSB, HID, ...)feature requestA request to make an enhancement (not a bug fix)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions