diff options
author | Brian Cully <bjc@kublai.com> | 2019-06-24 21:14:32 -0400 |
---|---|---|
committer | Brian Cully <bjc@kublai.com> | 2019-07-23 19:55:18 -0400 |
commit | 63d4ce8154eb8f6feb67986e98ea9b5007632460 (patch) | |
tree | 187e66104eb7c848dcf73a5ee067c5f27235360a /app/find-serial-port | |
download | samd21-demo-63d4ce8154eb8f6feb67986e98ea9b5007632460.tar.gz samd21-demo-63d4ce8154eb8f6feb67986e98ea9b5007632460.zip |
Initial commit.
Diffstat (limited to 'app/find-serial-port')
-rwxr-xr-x | app/find-serial-port | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/find-serial-port b/app/find-serial-port new file mode 100755 index 0000000..62e2c0c --- /dev/null +++ b/app/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 |