ARMmbed / ATParser

Parser for AT commands and similar protocols.
35 stars 27 forks source link

Parsing a string on a newline #1

Open evandavey opened 7 years ago

evandavey commented 7 years ago

How do I use this library to parse a response:

AT+CSGN\r\n
014532000023453\r\n
OK\r\n

I have tried

_parser.send("AT+CGSN") 
    && _parser.recv("AT+CGSN\r\n%s\r\nOK",_deviceStatus.imei);

and various other combinations and I can only get it to parse to the 0 then stop.

AT> AT+CGSN
AT<
AT= AT+CGSN
AT<
AT= 0
AT< 14532000023453
AT<
AT= OK
sarahmarshy commented 6 years ago

Though it's not pretty: _parser.recv("AT+CGSN%*[\r]%*[\n]%[^\r]%*[\r]%*[\n]OK%*[\r]%*[\n]",_deviceStatus.imei)

evandavey commented 6 years ago

Thanks @sarahmarshy. I've had to move on to another project, but will try to test when I get a chance.