-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththerminterface.py
More file actions
executable file
·27 lines (21 loc) · 850 Bytes
/
Copy paththerminterface.py
File metadata and controls
executable file
·27 lines (21 loc) · 850 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
#!/usr/bin/python
port = "/dev/ttyACM0" #default device under which TI Launchpad shows up
baud = 9600 #default baud used in uC firmware
import serial, re, datetime
datapattern = '([0-9A-F]{16})\s([+-][0-9]{3}\.[0-9]{4})'
therminterface = serial.Serial(port, baud, timeout=5)
while True:
therminterface.write("x") #therminterface wont send us any data until we request it, by sending anything
now = datetime.datetime.now()
rawdata = therminterface.read(9999)
sensors = re.findall(datapattern, rawdata)
datestring = now.strftime("%Y-%m-%d %H:%M:%S")
for sensor in sensors:
serialnumber = sensor[0]
temperature = sensor[1]
print(datestring + ' ' + serialnumber + ' ' + temperature)
sensorfile=open(serialnumber, 'a+')
sensorfile.write(datestring + ', ' + temperature + '\n')
sensorfile.close()
print('\n')
therminterface.close()