Created
December 9, 2018 17:02
-
-
Save newsch/6acaeaede8e8f0432c09e050dde4c412 to your computer and use it in GitHub Desktop.
This file contains 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
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