-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_002_uart.py
More file actions
36 lines (29 loc) · 730 Bytes
/
_002_uart.py
File metadata and controls
36 lines (29 loc) · 730 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
28
29
30
31
32
33
34
35
36
from serial import Serial
import time
serialPort = Serial("/dev/ttyAMA0", 9600, timeout=2)
if (serialPort.isOpen() == False):
serialPort.open()
outStr = ''
inStr = ''
serialPort.flushInput()
serialPort.flushOutput()
print "ready for serial"
##for i, a in enumerate(range(33, 126)):
## outStr += chr(a)
##
## serialPort.write(outStr)
## time.sleep(0.05)
## inStr = serialPort.read(serialPort.inWaiting())
##
## print "inStr = " + inStr
## print "outStr = " + outStr
##
## if(inStr == outStr):
## print "WORKED! for length of %d" % (i+1)
## else:
## print "failed"
while True:
serialPort.write("start")
response = serialPort.readline()
print response
serialPort.close()