Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mtaylor:~ Matt$ cat usb-serial.sh
- #!/bin/sh
- # By Matt Taylor.
- DEV=`ls /dev/tty.usb*|head -n1`
- if [ -z $DEV ]; then
- echo "Error: USB to Serial device not found in /dev/tty.* - please make sure it's connected"
- exit
- else
- echo "Device found: $DEV"
- fi
- if [ `ps a | grep 'dev/tty.'| grep -v 'grep' | awk '{print$1}'|wc -l` -gt 0 ]; then
- read -p "Error: $DEV is currently in use, kill existing sessions? [y/n] " CHECK
- if [ $CHECK == "y" ]; then
- echo "Killing existing pids.."
- ps a | grep 'dev/tty.'| grep -v 'grep' | awk '{print$1}' | xargs kill -9
- screen -wipe
- else
- echo "Exiting"
- exit
- fi
- fi
- if [ -z $1 ]; then
- echo "Baud rates: 4800 9600 19200 38400 57600 115200 31250"
- read -p "What baud rate do you want to use? " BAUD
- else
- BAUD=$1
- fi
- screen -U $DEV $BAUD
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement