JM9 XRCU Board 0.1.0
Libraries API Reference
Loading...
Searching...
No Matches
JM9_unpacker Class Reference

JM9 UART packet unpacker. More...

#include <Jason.h>

Public Member Functions

 JM9_unpacker (HardwareSerial &init_uart, const uint8_t init_start_byte)
 Creates an unpacker.
 
 ~JM9_unpacker ()
 Destroys this unpacker.
 
bool update ()
 Checks if a new packet is received.
 
uint8_t * get_packet_ptr ()
 Gets the pointer to the received data.
 
uint8_t get_packet_len ()
 Gets the length of the received data.
 

Public Attributes

HardwareSerialuart
 The underlying UART object.
 

Detailed Description

JM9 UART packet unpacker.

Author
YH Choi @ JM9

Constructor & Destructor Documentation

◆ JM9_unpacker()

JM9_unpacker::JM9_unpacker ( HardwareSerial & init_uart,
const uint8_t init_start_byte )

Creates an unpacker.

Parameters
init_uartthe UART object to read packets from
init_start_bytethe start byte of each packet

◆ ~JM9_unpacker()

JM9_unpacker::~JM9_unpacker ( )

Destroys this unpacker.

Releases the used memory.

Member Function Documentation

◆ get_packet_len()

uint8_t JM9_unpacker::get_packet_len ( )

Gets the length of the received data.

Only call this method after update() returns true.
To be used with get_packet_ptr().

Returns
the length of the received data
See also
update()
get_packet_ptr()

◆ get_packet_ptr()

uint8_t * JM9_unpacker::get_packet_ptr ( )

Gets the pointer to the received data.

The array pointed by this pointer contains data bytes only.
Only call this method after update() returns true.
To be used with get_packet_len().

Returns
the pointer to the received data
See also
update()
get_packet_len()

◆ update()

bool JM9_unpacker::update ( )

Checks if a new packet is received.

Returns
true if a new packet is completely received and checksumed, false otherwise

The documentation for this class was generated from the following files: