title: Howto properly parse response data received from GSM module?
body: <p>I'm looking for some guidelines how to properly parse response data received from GSM module. I'm using uBlox SARA-G350. Documentation states:</p>
  
  <pre><code>Information responses:
  &lt;CR&gt;&lt;LF&gt;&lt;text&gt;&lt;CR&gt;&lt;LF&gt;
  
  Result codes:
  &lt;CR&gt;&lt;LF&gt;&lt;verbose code&gt;&lt;CR&gt;&lt;LF&gt;
  
  If the command line is successfully performed, the string "OK" (&lt;CR&gt;&lt;LF&gt;OK&lt;CR&gt;&lt;LF&gt;)
  is sent, otherwise "ERROR".
  </code></pre>
  
  <p>It might looks everything simple. We should read each sentence from <code>&lt;CR&gt;&lt;LF&gt;</code> to <code>&lt;CR&gt;&lt;LF&gt;</code> but...</p>
  
  <ul>
  <li>data may become in chunks</li>
  <li>response may contains doubled <code>&lt;CR&gt;&lt;LF&gt;OK&lt;CR&gt;&lt;LF&gt;</code> (see example below)</li>
  </ul>
  
  <p>Example - sms message sent to gsm module:</p>
  
  <pre><code>"Hi. Is IT
  OK
  "
  </code></pre>
  
  <p>After CMGL module respond (this is how end of sequence of returned data might looks like):</p>
  
  <pre><code>Hi. Is IT&lt;CR&gt;&lt;LF&gt;
  OK&lt;CR&gt;&lt;LF&gt;
  &lt;CR&gt;&lt;LF&gt;
  OK&lt;CR&gt;&lt;LF&gt;
  </code></pre>
  
  <p>As you can see we have doubled <code>&lt;CR&gt;&lt;LF&gt;OK&lt;CR&gt;&lt;LF&gt;</code>.</p>
  
  <p>How do I know that I have whole sentence and should stop reading data from module and do parsing received data?</p>
  
  <p>How AT parser should behave in situation like this?</p>
  
  <p>Where I can find some guidelines how to properly parse incoming response data from gsm module?</p>