Skip to content

Instantly share code, notes, and snippets.

@newsch
Created December 9, 2018 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save newsch/6acaeaede8e8f0432c09e050dde4c412 to your computer and use it in GitHub Desktop.
Save newsch/6acaeaede8e8f0432c09e050dde4c412 to your computer and use it in GitHub Desktop.
import serial
import time
DEVICE_PATH = '/dev/ttyACM0'
BAUD_RATE = 115200
s = serial.Serial(DEVICE_PATH, BAUD_RATE)
while True:
if s.in_waiting > 0: # when new serial info is waiting
cmd = s.read(1)
if cmd == b'p':
# keep old file, print new file
elif cmd == b'd'
# delete last file
else:
print('Unknown serial command: {!r}'.format(cmd))
time.sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment