EV3UartProtocolParserSensorSide
EV3UartProtocolParserSensorSide Namespace Reference

Classes

class  Parser
 
struct  ParserReturn
 

Enumerations

enum  State : uint8_t { State::STATE_START = 0, State::WAIT_HEADER = 0, State::WAIT_CHECKSUM = 1, State::STATE_END = 1 }
 
enum  ParseResult : uint8_t {
  ParseResult::INSUFFICIENT_DATA, ParseResult::RECEIVED_INVALID_HEADER, ParseResult::RECEIVED_SYS_ACK, ParseResult::RECEIVED_SYS_NACK,
  ParseResult::RECEIVED_CMD_SELECT, ParseResult::RECEIVED_CMD_WRITE, ParseResult::RECEIVED_CMD_INVALID_FCS
}
 

Functions

constexpr uint8_t two_pow (uint8_t val)
 
constexpr State next_state (State st)
 

Variables

constexpr uint8_t BUFFER_LEN { EV3UartGenerator::Framing::BUFFER_MIN }
 

Enumeration Type Documentation

◆ ParseResult

Enumeration listing the possible results from parsing an additional byte of data coming from the EV3, returned by Parser

Enumerator
INSUFFICIENT_DATA 

The parser does not currently have sufficient data to return a significant parsing result. More data should be passed to the Parser::update() function.

RECEIVED_INVALID_HEADER 

The parser received an invalid header byte, a byte that is not the header for any message that the EV3 can send to a sensor.

The reasons for this could be:

  • Invalid header byte type (not CMD or SYS)
  • Invalid header byte sub-type (not [SELECT, WRITE] for CMD types or not [ACK, NACK] for SYS types)
  • Invalid payload length in header byte (not [0] for SYS types, or not [1] for SELECT sub-type, or not [1, 32] for WRITE sub-type)
RECEIVED_SYS_ACK 

Parser received a SYS ACK message

RECEIVED_SYS_NACK 

Parser received a SYS ACK message

RECEIVED_CMD_SELECT 

Parser received a CMD SELECT message with good FCS

RECEIVED_CMD_WRITE 

Parser received a CMD WRITE message with good FCS

RECEIVED_CMD_INVALID_FCS 

Parser received a CMD message with invalid FCS

Definition at line 142 of file EV3UartProtocolParserSensorSide.hpp.

◆ State

Enumeration listing the states the parser state machine can be in

Enumerator
STATE_START 

Starting value for State values.

WAIT_HEADER 

Parser is waiting for the header byte.

WAIT_CHECKSUM 

Parser is waiting for the checksum byte.

STATE_END 

End value for State values.

Definition at line 115 of file EV3UartProtocolParserSensorSide.hpp.

Function Documentation

◆ next_state()

constexpr State EV3UartProtocolParserSensorSide::next_state ( State  st)

Increments the variable representing the current parser state machine state to the next state, wrapping around if necessary.

Parameters
stcurrent state of the state machine
Returns
next state of the state machine, wrapping around to State::STATE_START if necessary.

Definition at line 130 of file EV3UartProtocolParserSensorSide.hpp.

References STATE_END, and STATE_START.

Referenced by EV3UartProtocolParserSensorSide::Parser::update().

◆ two_pow()

constexpr uint8_t EV3UartProtocolParserSensorSide::two_pow ( uint8_t  val)

Raises two to the power of val

Parameters
valwhat to raise two to the power of, in the range [0, 7]
Returns
two raised to the power of val
Warning
undefined for values of val greater than 7.

Definition at line 108 of file EV3UartProtocolParserSensorSide.hpp.

Referenced by EV3UartProtocolParserSensorSide::Parser::payload_length().

Variable Documentation

◆ BUFFER_LEN

constexpr uint8_t EV3UartProtocolParserSensorSide::BUFFER_LEN { EV3UartGenerator::Framing::BUFFER_MIN }

Length of internally allocated buffer to store messages incoming from the EV3

Definition at line 98 of file EV3UartProtocolParserSensorSide.hpp.