Created
January 30, 2020 14:59
-
-
Save waveform80/bfd5808e131e58fb26ce13ffc6555397 to your computer and use it in GitHub Desktop.
a brutally simple serial term
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/bash | |
# Derived from https://unix.stackexchange.com/a/311680/295309 | |
if [[ $# -lt 1 ]]; then | |
echo "Usage:" | |
echo " $0 <serial-port> [ <speed> [ <stty-options> ...] ]" | |
echo " Example: $0 /dev/ttyS0 115200" | |
echo " Use ^Q to quit" | |
exit 1 | |
fi | |
set -e | |
orig_settings=$(stty -g) | |
trap 'set +e; kill "$catpid"; stty "$orig_settings"' EXIT | |
port="$1"; shift | |
stty -F "$port" raw -echo "$@" | |
# Pass thru *everything* except Ctrl+Q (which sends SIGINT to this) | |
stty raw -echo isig intr ^Q quit undef susp undef | |
cat "$port" & catpid=$! | |
cat >"$port" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment