22 lines
656 B
Python
22 lines
656 B
Python
|
#! /usr/bin/env python
|
||
|
import serial, sys, time, io
|
||
|
serialPort = '/dev/ttyACM0'
|
||
|
try:
|
||
|
serialPort = sys.argv[1]
|
||
|
except Exception, e:
|
||
|
pass
|
||
|
ser = serial.Serial(port=serialPort, baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS)
|
||
|
sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))
|
||
|
ser.isOpen()
|
||
|
buffer = ''
|
||
|
while True:
|
||
|
try:
|
||
|
buffer = ser.readline()
|
||
|
buffer_split = buffer.split(' ')
|
||
|
temp = float(buffer_split[-2])
|
||
|
print unicode(time.time()) + ',' + unicode(temp)
|
||
|
sys.stdout.flush()
|
||
|
except Exception, e:
|
||
|
sys.stderr.write(str(e) + '\n')
|
||
|
continue
|