aboutsummaryrefslogtreecommitdiffstats
path: root/find-serial-port
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2019-06-13 18:00:42 -0400
committerBrian Cully <bjc@kublai.com>2019-06-22 16:18:03 -0400
commitfad3038b035db90c59f297891835d37fd97b79c5 (patch)
treee99ab8e4de5130dc9aca5ad35f3c6b8e0e82d263 /find-serial-port
downloadusb2btle-fad3038b035db90c59f297891835d37fd97b79c5.tar.gz
usb2btle-fad3038b035db90c59f297891835d37fd97b79c5.zip
Initial commit.
Diffstat (limited to 'find-serial-port')
-rwxr-xr-xfind-serial-port16
1 files changed, 16 insertions, 0 deletions
diff --git a/find-serial-port b/find-serial-port
new file mode 100755
index 0000000..62e2c0c
--- /dev/null
+++ b/find-serial-port
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+if [ $# -ne 2 ]; then
+ echo "Usage: $0 vid pid" >&2
+ exit 1
+fi
+
+prefix=/dev/serial/by-id
+
+for dev in `ls $prefix`; do
+ if [ `udevadm info -q property --name $prefix/$dev | egrep -i "ID_VENDOR_ID=($1)|ID_MODEL_ID=($2)" | wc -l` -eq 2 ]; then
+ echo `readlink -f $prefix/$dev`
+ exit 0
+ fi
+done
+exit 2