Created
June 16, 2020 16:38
-
-
Save kronoc/bf9bc69088857f05c5dde8cabd351c94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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