probe 411 B

1234567891011121314151617181920212223242526
  1. #!/bin/rc
  2. # usb/probe [-h] - list all usb devices, including hubs
  3. rfork e
  4. test -e /dev/usb || bind -a '#u' /dev || {
  5. echo no '#u/usb' >[1=2]
  6. exit nousb
  7. }
  8. filter = cat
  9. if (~ $1 -h)
  10. filter = (grep -v ' (root)?hub ')
  11. awk 'BEGIN { ep = "" }
  12. $1 ~ /ep[0-9]+\.0/ && $2 == "enabled" && $NF ~ /busy|idle/ {
  13. ep=$1
  14. next
  15. }
  16. {
  17. if(ep != ""){
  18. printf "%s %s\n", ep, $0
  19. ep = ""
  20. }
  21. }
  22. ' /dev/usb/ctl | $filter
  23. exit ''