-
-
Save tmbdev/5772607 to your computer and use it in GitHub Desktop.
Use expect to connect to a serial port (e.g., for Arduino)
This file contains hidden or 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
#!/usr/bin/expect -f | |
# device | |
set modem /dev/ttyUSB0 | |
# keep it open | |
exec sh -c "sleep 3 < $modem" & | |
# serial port parameters | |
exec stty -F $modem 9600 raw -clocal -echo -istrip -hup | |
# connect | |
send_user "connecting to $modem, exit with ~.\n" | |
spawn -open [open $modem w+] | |
interact { | |
~. exit | |
~~ {send "\034"} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment