Ok turns out I am an impatient man.
I need to modify this code so thatwas simply requesting the data too quickly; screen stays connected and shows it doesn't loop eternally, but this works forPython is just too fast when it reads the moment (willinput.
This code attempts to read the time from the modem at 2/10 of a second intervals for 20 seconds. If unsuccessful it sleeps for 20 seconds and then tries again. It will return the datetime string that is provided to this):the modem. That can be parsed from the "response" variable.
import serial import time, sys import datetime response = '' SERIAL_PORT = "i=0 time_found=False response='' SERIAL_PORT="/dev/ttyACM0" ser = serialser=serial.Serial(SERIAL_PORT, baudrate = 9600, timeout = 15) while time_found==False: ser.write('AT+CCLK?\r') response = ser.readline() while "CCLK:" not in response: response = ser response=ser.readline() time.sleep(0.2) ++i if i==200: break if "CCLK:" in response: time_found=True else: time.sleep(20) print response I was simply requesting the data too quickly; screen stays connected and shows it, Python is just too fast when it reads the input.
I will put some kind of a sleep value in the loop and then timeout the loop if it fails to read. I may put the overall script in a loop with a 10 minute delay so that it will run until successful.