Created
July 23, 2017 02:34
-
-
Save anonymous/e67e5721800ee74c0c4ed6a43fd87c37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import serial | |
from datetime import datetime | |
ser = serial.Serial(port='/dev/ttyACM0', baudrate=38400, timeout=0.5) | |
file = 'test.csv' | |
line = ser.read(1000) | |
#infinity loop | |
while True: | |
if( ser.inWaiting() > 0 ): | |
data = ser.read() | |
f = open(file, 'a') | |
f.write(data) | |
print data | |
if( '\n' in data ): | |
now = datetime.now().strftime('%Y/%m/%d %H:%M:%S, ') | |
f.write(now) | |
print now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment