Skip to content

Instantly share code, notes, and snippets.

@jnelson
Last active August 29, 2015 13:59
Show Gist options
  • Select an option

  • Save jnelson/10923035 to your computer and use it in GitHub Desktop.

Select an option

Save jnelson/10923035 to your computer and use it in GitHub Desktop.

Revisions

  1. jnelson revised this gist Apr 16, 2014. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions ttyUSB_demystify.sh
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,7 @@ candidates=`ls /dev | grep ttyUSB`
    for targetDevice in $candidates
    do
    majMinDevNums=`cat /sys/class/tty/$targetDevice/dev`
    infoLink=`ls -l /sys/dev/char/$majMinDevNums | awk '{print $NF}'`
    infoLink=`echo $infoLink | grep -oP '../../\K.*'`
    infoLink=`ls -l /sys/dev/char/$majMinDevNums | awk '{print $NF}' | grep -oP '../../\K.*'`
    infoDir=`echo /sys/$infoLink | perl -pe "s|(.*)/[\d-:.]+/$targetDevice/.*|\1|"`

    busnum=`cat $infoDir/busnum` || continue
  2. jnelson created this gist Apr 16, 2014.
    17 changes: 17 additions & 0 deletions ttyUSB_demystify.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/bin/bash

    # Reminder: don't use this.

    candidates=`ls /dev | grep ttyUSB`
    for targetDevice in $candidates
    do
    majMinDevNums=`cat /sys/class/tty/$targetDevice/dev`
    infoLink=`ls -l /sys/dev/char/$majMinDevNums | awk '{print $NF}'`
    infoLink=`echo $infoLink | grep -oP '../../\K.*'`
    infoDir=`echo /sys/$infoLink | perl -pe "s|(.*)/[\d-:.]+/$targetDevice/.*|\1|"`

    busnum=`cat $infoDir/busnum` || continue
    devnum=`cat $infoDir/devnum` || continue

    echo $targetDevice $majMinDevNums `lsusb -s $busnum:$devnum`
    done