I'm looking for some guidelines how to properly parse response data received from GSM module. I'm using uBlox SARA-G350. Documentation states:
Information responses:
<CR><LF><text><CR><LF>
Result codes:
<CR><LF><verbose code><CR><LF>
If the command line is successfully performed, the string "OK" (<CR><LF>OK<CR><LF>)
is sent, otherwise "ERROR".
It might looks everything simple. We should read each sentence from <CR><LF>
to <CR><LF>
but...
<CR><LF>OK<CR><LF>
(see example below)Example - sms message sent to gsm module:
"Hi. Is IT
OK
"
After CMGL module respond (this is how end of sequence of returned data might looks like):
Hi. Is IT<CR><LF>
OK<CR><LF>
<CR><LF>
OK<CR><LF>
As you can see we have doubled <CR><LF>OK<CR><LF>
.
How do I know that I have whole sentence and should stop reading data from module and do parsing received data?
How AT parser should behave in situation like this?
Where I can find some guidelines how to properly parse incoming response data from gsm module?
I found it. My bad assumption was that sms message can contain CrLf within. This is not true (at least for uBlox SARA-G350). All CrLf within some text received from module are replaced to Lf.
Thanks to that I can know that end of sentence will be when one of the next combinations arrives:
<CR><LF>OK<CR><LF>
<CR><LF>ERROR<CR><LF>
<CR><LF> >
The last one is prompt sign for sms sending command.