shithub: riscv

ref: 94e7de15311c12c6fba68cc3ccffdc16945eb9fb
dir: /sys/src/cmd/usb/probe/

View raw version
#!/bin/rc
# usb/probe [-h] - list all usb devices, including hubs
rfork e
test -e /dev/usb || bind -a '#u' /dev || {
	echo no '#u/usb' >[1=2]
	exit nousb
}

filter = cat
if (~ $1 -h)
	filter = (grep -v ' (root)?hub ')

awk 'BEGIN	{ ep = "" }
$1 ~ /ep[0-9]+\.0/ && $2 == "enabled" && $NF ~ /busy|idle/ {
	ep=$1
	next
}
{
	if(ep != ""){
		printf "%s %s\n", ep, $0
		ep = ""
	}
}
' /dev/usb/ctl | $filter

exit ''