How to be sure what is end of an AT command send to GSM module?
I need some character or string that represent end of AT command for every case due to finding when
Here is what I used in Python. It works. There might be some other better solutions.
ser = serial.Serial(com, baudrate, timeout=5)
while True:
# a simple AT return result parser
new_char = ser.read(1)
byte_flow += new_char
if len(byte_flow) >=4 and byte_flow[-4:] == b'\r\nOK':
break
elif len(byte_flow) >= 7 and byte_flow[-7:] == b'\r\nERROR':
break
byte_flow += ser.read(2) # the final '\r\n'
You can add more elif
if there is any other patterns.