End of response to an AT command

viktor.radovic picture viktor.radovic · Nov 8, 2012 · Viewed 10.7k times · Source

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 whole response is received.

I guess it have something with "\r\n" sequence but, this sequence could be at the beginning of AT command response?

Answer

jeb picture jeb · Nov 8, 2012

Like you suppose it's \r\n.
This defines the end of a line.

And it makes only sense to process complete lines.

Some commands respons with only OK\r\n, some with some data.
So you should build at first a parser, who can detect complete lines, so they can be processed with a function that handles responses.

Sometimes you can get even responses you don't request, like change events net login or the sim status #QSS: 2\r\n.

So you need to know what answer you expect and wait until you get this