diondokter / at-commands

Rust project for building and parsing at commands
Apache License 2.0
33 stars 5 forks source link

Failing to parse closing bracket #12

Open HerrMuellerluedenscheid opened 3 months ago

HerrMuellerluedenscheid commented 3 months ago

Hey,

I'm encountering an issue parseing the following sequence:

let (unsolicited_code, status) = at_commands::parser::CommandParser::parse(b"\r\n+CREG: (0-2)\r\n\r\nOK\r\n")
    .expect_identifier(b"\r\n+CREG: (")
    .expect_int_parameter()
    .expect_identifier(b"-")
    .expect_int_parameter()
    .expect_identifier(b")\r\n\r\nOK\r\n")
    .finish()
    .unwrap();

This errors at the closing bracket ) with

called `Result::unwrap()` on an `Err` value: ParseError(13)

Do you have a clue what I'm doing wrong?

diondokter commented 3 months ago

Hi, ehh, I've never seen parentheses used in at commands to be honest. This doesn't seem like anything standard.

I'm not sure why it errors on the closing parenthesis... Might be fixable. However, due to the non-standard nature of the response, I'd call the expect_raw_string function to get the values and then parse the result yourself.

But if you're willing to investigate, it might be a small simple fix.

HerrMuellerluedenscheid commented 3 months ago

Thanks! I will take a deeper dive