Skip to content

Instantly share code, notes, and snippets.

@nsnick
Created October 20, 2019 03:29
Show Gist options
  • Save nsnick/eb90ba6cd3893f0f10e9701a71640276 to your computer and use it in GitHub Desktop.
Save nsnick/eb90ba6cd3893f0f10e9701a71640276 to your computer and use it in GitHub Desktop.
Write a newline to ttyACM0 when it receives an http request on 8080
#!/bin/bash
# Craig Hesling <[email protected]>
NC=netcat
PORT=8080
SERIAL=/dev/ttyACM0
serial_setup() {
stty -F <$SERIAL 115200
}
serial_fire() {
echo > $SERIAL
}
# UNCOMMENT ME
#serial_setup
while true; do
$NC -l -p $PORT <<-EOF
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Server: netcat!
EOF
echo "FIREEEEE!"
# UNCOMMENT ME
#serial_fire
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment