Skip to content

Instantly share code, notes, and snippets.

@BbsonLin
Created January 7, 2019 14:34
Show Gist options
  • Save BbsonLin/bddb808906e4fa3c527d8f15bec1f2f6 to your computer and use it in GitHub Desktop.
Save BbsonLin/bddb808906e4fa3c527d8f15bec1f2f6 to your computer and use it in GitHub Desktop.
import serial
import threading
import sys
import signal
import time
def quit(signum, frame):
print('')
print('stop fuction')
sys.exit()
if __name__ == "__main__":
ser = serial.Serial('/dev/ttymxc1', 9600, timeout=10)
signal.signal(signal.SIGINT, quit)
signal.signal(signal.SIGTERM, quit)
while True:
ser.write(b'~\xa0\x1f\x00\xbf~')
resp = ser.read(16)
print(resp)
time.sleep(3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment