We are going to enable autosuspend and modify its autosuspend time for a USB device connected to your Linux box:
- Log in to your Linux box (Raspberry Pi, Ubuntu, and Docker containers won't work).
- Switch to the root account:
$ sudo bash
#
- Get the current autosuspend status for all USB devices that are connected:
# for f in /sys/bus/usb/devices/*/power/control; do echo "$f"; cat $f; done
- Enable autosuspend for one of the devices:
# echo auto > /sys/bus/usb/devices/1-1.2/power/control
- Read the autosuspend interval for the device:
# cat /sys/bus/usb/devices/1-1.2/power/autosuspend_delay_ms
- Modify the autosuspend interval:
# echo 5000 > /sys/bus/usb/devices/1-1.2/power/autosuspend_delay_ms
- Check the current power mode of the device:
# cat /sys/bus/usb/devices/1-1.2/power/runtime_status
The same operations can be programmed in C++ using the standard file API.