- #!/usr/bin/python3
- import serial
- import time
- import sys
- ser = serial.Serial('/dev/ttyUSB1',9600,timeout=0)
- #ser.setDTR(1)
- print(ser.name)
- seq = []
- count = 1
- previousTime=time.time()
- currentTime=time.time()
- c=0
- while True :
- for c in ser.read():
- seq.append(chr(c))
- joined_seq = ''.join(str(v) for v in seq)
- if chr(c) == '\r':
- #print("Line " + str(count) + ': ' + joined_seq)
- #strToHex(joined_seq)
- print(str(int(time.time()))+","+joined_seq.strip()+"")
- sys.stdout.flush()
- c=0
- seq = []
- count += 1
- time.sleep(0.0001)
- ser.close()
monitor serial port and log csv with timestamp.
Posted by Anonymous on Tue 26th Feb 2019 03:32
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
python.kpaste.net RSS