Skip to content

Instantly share code, notes, and snippets.

@kronoc
Created June 16, 2020 16:38
Show Gist options
  • Save kronoc/bf9bc69088857f05c5dde8cabd351c94 to your computer and use it in GitHub Desktop.
Save kronoc/bf9bc69088857f05c5dde8cabd351c94 to your computer and use it in GitHub Desktop.
#!/bin/sh
# connect.sh
# Usage:
# $ connect.sh <device> <port speed>
# Example: connect.sh /dev/ttyS0 9600
# Set up device
stty -F /dev/ttyS0 4800
# Let cat read the device $1 in the background
cat /dev/ttyS0 stdout &
# Capture PID of background process so it is possible to terminate it when done
bgPid=$!
# Read commands from user, send them to device $1
echo -n "PC;" >/dev/ttyS0
sleep 1
# Terminate background read process
kill $bgPid
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment