From 08acaf69dddd69ae4dba9d25de9d3cd72b9bb260 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sun, 29 May 2022 16:35:22 -0700 Subject: Move stty setup/teardown to separate script; add hconnect script. --- tool/connect | 31 +------------------------------ tool/hconnect | 3 +++ tool/withstty | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 30 deletions(-) create mode 100755 tool/hconnect create mode 100755 tool/withstty (limited to 'tool') diff --git a/tool/connect b/tool/connect index 76ae0e7..3bbd3b7 100755 --- a/tool/connect +++ b/tool/connect @@ -1,32 +1,3 @@ #!/bin/bash -set -eu - -OLD_SETTINGS="$(stty -g -F /dev/ttyUSB0)" - -stty -F /dev/ttyUSB0 \ - 1000000 \ - -drain \ - -clocal \ - cread \ - crtscts \ - cs8 \ - cstopb \ - -hup \ - parenb \ - parodd \ - -cmspar \ - -igncr \ - ignpar \ - -parmrk \ - inpck \ - -istrip \ - -ixany \ - -ixoff \ - -ixon \ - -echo \ - -icanon - -con /dev/ttyUSB0 || true - -stty -drain "$OLD_SETTINGS" -F /dev/ttyUSB0 2> /dev/null +exec tool/withstty con /dev/ttyUSB0 diff --git a/tool/hconnect b/tool/hconnect new file mode 100755 index 0000000..7c823c7 --- /dev/null +++ b/tool/hconnect @@ -0,0 +1,3 @@ +#!/bin/bash + +exec tool/withstty hcon /dev/ttyUSB0 diff --git a/tool/withstty b/tool/withstty new file mode 100755 index 0000000..9f23565 --- /dev/null +++ b/tool/withstty @@ -0,0 +1,38 @@ +#!/bin/bash + +set -eu + +OLD_SETTINGS="$(stty -g -F /dev/ttyUSB0)" + +stty -F /dev/ttyUSB0 \ + 1000000 \ + -drain \ + -clocal \ + cread \ + crtscts \ + cs8 \ + cstopb \ + -hup \ + parenb \ + parodd \ + -cmspar \ + -igncr \ + ignpar \ + -parmrk \ + inpck \ + -istrip \ + -ixany \ + -ixoff \ + -ixon \ + -echo \ + -icanon \ + -onlcr + +set +e +"$@" +ERROR="$?" +set -e + +stty -drain "$OLD_SETTINGS" -F /dev/ttyUSB0 2> /dev/null + +exit "$ERROR" -- cgit v1.2.3