Skip to content

Checksumlayer does not report invalid message id error #5

@TimonTerBraak

Description

@TimonTerBraak

I have a bit of a weid and complex protocol, where I attempt to be robust for the following pattern:
XX XX ID DATA CHECKSUM XX XX

Since the message length is variable due to a lot of optional / conditional fields, the decoding attempts to reason back from the checksum towards the front of the message. At least that is my interpretation. If there are garbage bytes around the message, the decoder is unable to parse the data properly. I use a deque for the incoming datastream, and I have played around with error status and discarding bytes, but it does not seem the right approach.

While debugging I discovered the following when garbage bytes are found in front of the message. The message id layer reports (correctly) an invalid message id. However, the checksum layer only checks for the NotEnoughData and ProtocolError states. See the screenshot below.

Image

In the end a 'ProtocolError' is reported instead, which is also 'sort of fine', but a ProtocolError can be anything. Ideally, I would like to pop bytes from the front of the stream while there is enough data and an invalid message id is found. This would allow me to properly align the datastream with the protocol decoding. Does that make sense?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions