Prusa3d Marlin fork
Public Member Functions | Static Public Member Functions | List of all members
modules::protocol::Protocol Class Reference

#include <mmu2_protocol.h>

Public Member Functions

DecodeStatus DecodeRequest (uint8_t c)
 
DecodeStatus DecodeResponse (uint8_t c)
 
const RequestMsg GetRequestMsg () const
 
const ResponseMsg GetResponseMsg () const
 
void ResetRequestDecoder ()
 resets the internal request decoding state (typically after an error)
 
void ResetResponseDecoder ()
 resets the internal response decoding state (typically after an error)
 

Static Public Member Functions

static uint8_t EncodeRequest (const RequestMsg &msg, uint8_t *txbuff)
 
static uint8_t EncodeWriteRequest (uint8_t address, uint16_t value, uint8_t *txbuff)
 
static constexpr uint8_t MaxRequestSize ()
 
static constexpr uint8_t MaxResponseSize ()
 
static uint8_t EncodeResponseCmdAR (const RequestMsg &msg, ResponseMsgParamCodes ar, uint8_t *txbuff)
 
static uint8_t EncodeResponseReadFINDA (const RequestMsg &msg, uint8_t findaValue, uint8_t *txbuff)
 
static uint8_t EncodeResponseQueryOperation (const RequestMsg &msg, ResponseCommandStatus rcs, uint8_t *txbuff)
 
static uint8_t EncodeResponseRead (const RequestMsg &msg, bool accepted, uint16_t value2, uint8_t *txbuff)
 

Detailed Description

Protocol class is responsible for creating/decoding messages in Rx/Tx buffer

Beware - in the decoding more, it is meant to be a statefull instance which works through public methods processing one input byte per call.

Member Function Documentation

◆ DecodeRequest()

DecodeStatus modules::protocol::Protocol::DecodeRequest ( uint8_t  c)

Takes the input byte c and steps one step through the state machine

Returns
state of the message being decoded

◆ DecodeResponse()

DecodeStatus modules::protocol::Protocol::DecodeResponse ( uint8_t  c)

Decodes response message in rxbuff

Returns
decoded response message structure

◆ EncodeRequest()

uint8_t modules::protocol::Protocol::EncodeRequest ( const RequestMsg msg,
uint8_t *  txbuff 
)
static

Encodes request message msg into txbuff memory It is expected the txbuff is large enough to fit the message

Returns
number of bytes written into txbuff

◆ EncodeResponseCmdAR()

uint8_t modules::protocol::Protocol::EncodeResponseCmdAR ( const RequestMsg msg,
ResponseMsgParamCodes  ar,
uint8_t *  txbuff 
)
static

Encode generic response Command Accepted or Rejected

Parameters
msgsource request message for this response
arcode of response parameter
txbuffwhere to format the message
Returns
number of bytes written into txbuff

◆ EncodeResponseQueryOperation()

uint8_t modules::protocol::Protocol::EncodeResponseQueryOperation ( const RequestMsg msg,
ResponseCommandStatus  rcs,
uint8_t *  txbuff 
)
static

Encode response to Query operation status

Parameters
msgsource request message for this response
codestatus of operation (Processing, Error, Finished)
valuerelated to status of operation(e.g. error code or progress)
txbuffwhere to format the message
Returns
number of bytes written into txbuff

◆ EncodeResponseRead()

uint8_t modules::protocol::Protocol::EncodeResponseRead ( const RequestMsg msg,
bool  accepted,
uint16_t  value2,
uint8_t *  txbuff 
)
static

Encode response to Read query

Parameters
msgsource request message for this response
acceptedtrue if the read query was accepted
value2variable value
txbuffwhere to format the message
Returns
number of bytes written into txbuff

◆ EncodeResponseReadFINDA()

uint8_t modules::protocol::Protocol::EncodeResponseReadFINDA ( const RequestMsg msg,
uint8_t  findaValue,
uint8_t *  txbuff 
)
static

Encode response to Read FINDA query

Parameters
msgsource request message for this response
findaValue1/0 (on/off) status of FINDA
txbuffwhere to format the message
Returns
number of bytes written into txbuff

◆ EncodeWriteRequest()

uint8_t modules::protocol::Protocol::EncodeWriteRequest ( uint8_t  address,
uint16_t  value,
uint8_t *  txbuff 
)
static

Encodes Write request message msg into txbuff memory It is expected the txbuff is large enough to fit the message

Returns
number of bytes written into txbuff

◆ GetRequestMsg()

const RequestMsg modules::protocol::Protocol::GetRequestMsg ( ) const
inline
Returns
the most recently lexed request message

◆ GetResponseMsg()

const ResponseMsg modules::protocol::Protocol::GetResponseMsg ( ) const
inline
Returns
the most recently lexed response message

◆ MaxRequestSize()

static constexpr uint8_t modules::protocol::Protocol::MaxRequestSize ( )
inlinestaticconstexpr
Returns
the maximum byte length necessary to encode a request message Beneficial in case of pre-allocating a buffer for enconding a RequestMsg.

◆ MaxResponseSize()

static constexpr uint8_t modules::protocol::Protocol::MaxResponseSize ( )
inlinestaticconstexpr
Returns
the maximum byte length necessary to encode a response message Beneficial in case of pre-allocating a buffer for enconding a ResponseMsg.

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