Created
November 20, 2018 08:17
-
-
Save apherio/973ea7c80674516e38b3eae16b1d6e69 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, time | |
ser = serial.Serial() | |
ser.port = '/dev/ttyACM1' | |
#ser.port = 'COM10' | |
ser.baudrate = 115200 | |
ser.bytesize = serial.EIGHTBITS | |
ser.parity =serial.PARITY_NONE | |
ser.stopbits = serial.STOPBITS_ONE | |
ser.timeout = 1 | |
ser.open() | |
ser.write(b'\r\r') | |
time.sleep(1) | |
ser.write(b'lep\r') | |
ser.close() | |
while True: | |
try: | |
ser.open() | |
value=ser.readline() | |
ser.close() | |
print(value) | |
except KeyboardInterrupt: | |
ser.flushInput() | |
ser.flushOutput() | |
ser.close() | |
print("Connection closed") | |
break | |
except Exception as e: | |
ser.close() | |
print(e) | |
print("") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment