-
Notifications
You must be signed in to change notification settings - Fork 2
/
serfind
executable file
·29 lines (25 loc) · 816 Bytes
/
serfind
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# (c) 2020 Leif Sawyer
# License: GPL 3.0 (see https://github.com/akhepcat/)
# Permanent home: https://github.com/akhepcat/Miscellaneous/
# Direct download: https://raw.githubusercontent.com/akhepcat/Miscellaneous/master/serfind
#
python -m serial.tools.list_ports 2>&1| grep -q "No module"
if [ 1 -eq $? ]
then
python -m serial.tools.list_ports -v
else
for device in $(find /sys/devices -type d -iname ttyACM*)
do
acm=${device##*/}
dpath=${device/\/tty\/*/}
dpath=${dpath%/*}
vendor=$(cat ${dpath}/idVendor)
prod=$(cat ${dpath}/idProduct)
mfr=$(cat ${dpath}/manufacturer)
product=$(cat ${dpath}/product)
serial=$(cat ${dpath}/serial)
serial=${serial//_/}
printf "%4s:%4s %20.20s %20.20s %20.20s - %s\n" ${vendor} ${prod} "${mfr}" "${product}" "${serial}" ${acm}
done
fi