-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathardpi-serial_2.py
More file actions
50 lines (41 loc) · 838 Bytes
/
Copy pathardpi-serial_2.py
File metadata and controls
50 lines (41 loc) · 838 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
37
38
39
40
41
42
43
44
45
46
47
48
49
import threading
from Queue import Queue
import os
import math
import time
import serial
import sys
import string, socket, select
import RPi.GPIO as GPIO
serdata=""
serQ=Queue(20)
def SerRead():
global serQ
try:
while True :
ser = serial.Serial('/dev/ttyAMA0', 9600)
ser.write("A")
response = ser.readline()
serQ.put(response)
except KeyboardInterrupt:
ser.close()
def SerDisplay():
global serQ
try:
while True:
datavals = serQ.get()
serQ.task_done()
datasplit=datavals.split(",")
for n in datasplit:
print n
# if n!="":
# if int(n)>8:
# print n
# else:
# pass
except KeyboardInterrupt:
ser.close()
SerReadT= threading.Thread(name='SerRead', target=SerRead)
SerDisplayT= threading.Thread(name='SerDisplay', target=SerDisplay)
SerReadT.start()
SerDisplayT.start()