I see post after post after post asking how to sleep a USB port. What I don't see anywhere is direction on how to prevent such.
I have a C# program that operates a piece of hardware that is a literal black box. I have zero control over the physical internals. Unfortunately, if the USB port sleeps, even for the tiniest fraction of a second, the device loses its state and all current work is lost.
I need a way to make absolutely sure that the USB ports never ever ever sleep while my app is running. Even if no data has been sent to the port and even if the user doesn't touch the computer for days at a time.
A few things:
1: It's not necessary to keep the port wakelocked only while the application is running. Permanently disabling USB sleep would actually be preferred.
2: Disabling other power saving features in Windows is acceptable.
3: Simply asking customers to disable USB sleeping is not acceptable. Many are not tech savvy enough to follow written directions for such and we lack the manpower to walk hundreds and hundreds of users through it.
4: Using the computer for anything except our software technically violates the license. Our license also reserves us the right to alter the Windows configuration without user knowledge or consent. As such, disabling USB sleeping silently and transparently is strongly preferred.