Core

class hachi.core.XBee(callback=None)

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()

Reset the state of the parser

feed(data)

Feed the parser with data

Parameters:data (int or bytes or bytearray) – byte(s) to add
hachi.core.escape(byte)

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
hachi.core.escape_frame(frame)

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
hachi.core.unescape(byte)

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

Hachi

Hachi is a Python library to interact with XBees.

PyPI downloads

Donate

If you like hachi, please consider making a donation

Related Topics

This Page

Fork me on GitHub