How to do it...

We are going to enable autosuspend and modify its autosuspend time for a USB device connected to your Linux box: 

  1. Log in to your Linux box (Raspberry Pi, Ubuntu, and Docker containers won't work).
  2. Switch to the root account:
$ sudo bash
#
  1. 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
  1. Enable autosuspend for one of the devices:
# echo auto > /sys/bus/usb/devices/1-1.2/power/control
  1. Read the autosuspend interval for the device:
# cat /sys/bus/usb/devices/1-1.2/power/autosuspend_delay_ms 
  1. Modify the autosuspend interval:
# echo 5000 > /sys/bus/usb/devices/1-1.2/power/autosuspend_delay_ms 
  1. 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. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.89.85