ATParser icon indicating copy to clipboard operation
ATParser copied to clipboard

Parsing a string on a newline

Open evandavey opened this issue 8 years ago • 2 comments

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

evandavey avatar Feb 04 '17 07:02 evandavey

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

sarahmarshy avatar Jul 28 '17 14:07 sarahmarshy

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

evandavey avatar Jul 28 '17 22:07 evandavey