Framing Module
Response Frame received from Free-Wili commands
Serial Module API
Support for FreeWili serial framing.
- class freewili.framing.ResponseFrame(rf_type: ResponseFrameType, rf_type_data: str, timestamp: int, seq_number: int, response: str, success: int, _raw: str)
Bases:
object
Response Frame from a FreeWili serial.
- classmethod from_raw(frame: str | bytes, strict: bool = True) Ok[Self] | Err[str]
Take a response frame string and create a ResponseFrame.
Parameters:
- framestr
response frame string to decode.
- strictbool
allows the timestamp to be invalid.
Returns:
- Result[ResponseFrame, str]:
Ok(ResponseFrame) if decoded successfully, Err(str) if not.
- static is_frame(frame: bytes | str) bool
Identify if the frame value is something we can parse.
Parameters:
- framebytes | str:
response frame string to decode.
Returns:
- bool:
True if is a frame, False otherwise.
- is_ok() bool
Validates if the frame was successful.
Parameters:
None
Returns:
- bool:
True if success == 1, False otherwise.
- static is_start_of_frame(frame: bytes | str) bool
Identify if the frame value is something we might be able to parse when complete.
Parameters:
- framebytes | str:
response frame string to decode.
Returns:
- bool:
True if is a frame, False otherwise.
- response: str
- response_as_bytes(check_ok: bool = True) Ok[bytes] | Err[str]
Convert the response into bytes.
Parameters:
- check_ok: bool
Calls is_ok() to make sure the frame is valid.
Returns:
- Result[bytes, str]:
Ok(bytes) if valid, False if data couldn’t be converted.
- rf_type: ResponseFrameType
- rf_type_data: str
- seq_number: int
- success: int
- timestamp: int