Description
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!