Skip to content

Instantly share code, notes, and snippets.

@skfwMelonpan
Created July 28, 2015 05:31
Show Gist options
  • Save skfwMelonpan/67f12fc3aeab57ab7fe4 to your computer and use it in GitHub Desktop.
Save skfwMelonpan/67f12fc3aeab57ab7fe4 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import sys
import serial
import time
import datetime
ser=serial.Serial("/dev/ttyAMA0",9600)
start = datetime.datetime.now()
end = start+datetime.timedelta(seconds=60)
print start
while True:
line=ser.readline()
print "%s,%s"%(datetime.datetime.now()-start,line)
if end-datetime.datetime.now()<datetime.timedelta(seconds=0):
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment