-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyTouch.py
More file actions
27 lines (24 loc) · 732 Bytes
/
Copy pathpyTouch.py
File metadata and controls
27 lines (24 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import serial
from time import sleep
def TouchSerialPort(port, baudrate):
print("Forcing reset using %dbps open/close on port %s" % (baudrate, port))
try:
print("define")
s = serial.Serial(
port=port,
baudrate = baudrate
#parity=0,
#stopbits=1,
#bytesize=8,
#timeout=1
)
print("DTR")
s.setDTR(False)
print("postDTR")
s.close()
except: # pylint: disable=bare-except
print("Could not touch")
pass
sleep(0.4) # DO NOT REMOVE THAT (required by SAM-BA based boards)
if __name__ == '__main__':
TouchSerialPort('/dev/ttyACM0', 1200) # '/dev/ttyACM0' '/dev/ttyUSB0'