summaryrefslogtreecommitdiff
path: root/tool/withstty
blob: 9f2356553bc466c9c56916f3a4ee3acef31e9d71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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"