Code: Select all
import time
from datetime import datetime
import serial
now = datetime.now()
ser = serial.Serial('/dev/ttyACM0',9600)
while True:
print (ser.readline())
print ("%s:%s:%s" % (now.hour, now.minute, now.second))
time.sleep(2)
b'Hello Mr.Pi\r\n'
22:58:53
b'testing 2nd line\r\n'
22:58:53
b'Hello Mr.Pi\r\n'
22:58:53
b'testing 2nd line\r\n'
22:58:53
("The Hello Mr.Pi" and "testing 2nd line" is being printed from the Arduino this is just for testing purposes later on they will be changed)
As you can see the time stamp doesn't update. Also it is annoying that there is all of that extra stuff (b'.....\r\n') but that is a different problem I have.
If I stop the program ctrl + c and then start the program again the time does update. Anyone have any ideas?
Additional Info:
Raspberry Pi 2
Python 3.4.2 language I do have access to Python 2