Skip to content

Response without leading '\r\n' is eaten by echo detector #184

Description

@ijager

I have encountered a specific case in which the response on a command is removed by digest::parser::echo:

"\r\n+QMTRECV: 1,0\r\n+QMTRECV: 1,0,\"t/dev/commands\",16,\"{\"cmd\": \"blink\"}\"\r\n\r\nOK\r\n"

First \r\n+QMTRECV: 1,0\r\n is correctly detected as an URC.

Then we are left with:

"+QMTRECV: 1,0,\"t/dev/commands\",16,\"{\"cmd\": \"blink\"}\"\r\n\r\nOK\r\n"

Because there is no \r\n in front, this will not be detected as an URC, which is good because this is actually a response to the "AT+QMTRECV" command.

However digest::parser::echo parses this as an echo and removes it. echo removes everything up to the next newline.

If I change echo to detect an echo as: `AT.....\r\n' like this:

/// Matches a full AT echo. Eg `AT+USORD=3,16\r\n`
    pub fn echo(buf: &[u8]) -> IResult<&[u8], &[u8]> {
        if buf.len() < 2 {
            return Ok((buf, &[]));
        }
        // commented out original
        // recognize(nom::bytes::complete::take_until("\r\n"))(buf)

        recognize(
            tuple((
                tag("AT"),
                nom::bytes::complete::take_until("\r\n")
            ))
        )(buf)

    }

Then I can parse my input, however there are 2 failing tests:

test digest::test::mm_echo_removal ... FAILED
test digest::test::garbage_cleanup ... FAILED

It seems like the echo parser also has the responsibility to remove garbage.
That means the issue comes down to differentiating between a response without a leading '\r\n' and garbage. But that is very hard when echo is on. Because for example with prompts there is no leading AT.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions