is_usb_data_connected 389 B

1234567891011121314151617181920
  1. #!/bin/sh
  2. # Uncomment the following line to get debug info
  3. #set -x
  4. # Get USB state
  5. usb_present=$(cat /sys/class/power_supply/axp20x-usb/present)
  6. # Get udc state
  7. udc_state=$(cat /sys/class/udc/musb-hdrc.1.auto/state)
  8. if [[ x"$udc_state" == "xconfigured" -a "$usb_present" == "1" ]]; then
  9. # Connected succesfully to a host
  10. echo "yes"
  11. exit 0
  12. else
  13. echo "no"
  14. exit 1
  15. fi