Parser for incoming XBee communications
The XBee parses data through its feed() method. When a complete and valid response is found, the response attribute is set to the corresponding XBeeResponse and the callback is called. Any malformed response is silently discarded.
Parameters: | callback (function) – callback method called with a XBeeResponse as first positional argument |
---|
Reset the state of the parser
Feed the parser with data
Parameters: | data (int or bytes or bytearray) – byte(s) to add |
---|
Escape a byte
Parameters: | byte (int) – the byte to escape |
---|---|
Raise : | ValueError if the byte is not a special byte |
Returns: | the escaped byte |
Return type: | int |
Escape a frame
Parameters: | frame (bytearray) – the frame to escape, starting with FRAME_DELIMITER |
---|---|
Raise : | ValueError if the frame does not start with a FRAME_DELIMITER |
Returns: | the escaped frame |
Return type: | bytearray |
Unescape a byte
Parameters: | byte (int) – the byte to unescape |
---|---|
Raise : | ValueError if the unescaped byte is not a special byte |
Returns: | the unescaped byte |
Return type: | int |