|
EV3UartProtocolParserSensorSide
|
#include <EV3UartProtocolParserSensorSide.hpp>
Classes | |
| struct | HeaderInformation |
Public Member Functions | |
| Parser () | |
| Parser (const Parser &)=delete | |
| ParserReturn | update (uint8_t input) |
| uint8_t * | data () |
| const uint8_t * | data () const |
| void | reset_state () |
Private Member Functions | |
| uint8_t | payload_length (const uint8_t hdr) |
| HeaderInformation | analyze_header (const uint8_t hdr) |
Private Attributes | |
| uint8_t | buffer [BUFFER_LEN] |
| uint8_t | message_payload_length = 0 |
| uint8_t | message_pending_bytes = 0 |
| State | current_state = State::STATE_START |
Parser for parsing EV3 UART sensor protocol messages that come from the EV3
Definition at line 218 of file EV3UartProtocolParserSensorSide.hpp.
| EV3UartProtocolParserSensorSide::Parser::Parser | ( | ) |
Definition at line 66 of file EV3UartProtocolParserSensorSide.cpp.
|
delete |
|
private |
Analyze an EV3 message header
| hdr | message header byte |
Definition at line 22 of file EV3UartProtocolParserSensorSide.cpp.
References EV3UartProtocolParserSensorSide::Parser::HeaderInformation::header_valid.
| uint8_t * EV3UartProtocolParserSensorSide::Parser::data | ( | ) |
Obtain a pointer to the data received from the EV3 by the parser.
Memory addresses up to, (but not including) BUFFER_LEN -1 bytes away from this pointer are guaranteed to be accessible.
| res | Pointer points to |
|---|---|
| RECEIVED_INVALID_HEADER | Meaningless data |
| RECEIVED_SYS_ACK | Meaningless data |
| RECEIVED_SYS_NACK | Meaningless data |
| RECEIVED_CMD_SELECT | SELECT message's payload |
| RECEIVED_CMD_WRITE | WRITE message's payload |
| RECEIVED_CMD_INVALID_FCS | Payload of message with invalid FCS |
Definition at line 134 of file EV3UartProtocolParserSensorSide.cpp.
| const uint8_t * EV3UartProtocolParserSensorSide::Parser::data | ( | ) | const |
Provides the same functionality as the similarly named function, except that it returns a pointer to a memory region that cannot be modified.
Definition at line 138 of file EV3UartProtocolParserSensorSide.cpp.
|
private |
Obtain the payload length from a valid message header byte
| hdr | message header byte |
Definition at line 18 of file EV3UartProtocolParserSensorSide.cpp.
References EV3UartProtocolParserSensorSide::two_pow().

| void EV3UartProtocolParserSensorSide::Parser::reset_state | ( | ) |
Reset the state of the parser, so that the next byte input into the parser will be treated as a header byte candidate.
Definition at line 142 of file EV3UartProtocolParserSensorSide.cpp.
References EV3UartProtocolParserSensorSide::STATE_START.
| ParserReturn EV3UartProtocolParserSensorSide::Parser::update | ( | uint8_t | input | ) |
Update the parser with one byte of information from the EV3
| input | byte of information from the EV3 |
Definition at line 70 of file EV3UartProtocolParserSensorSide.cpp.
References EV3UartProtocolParserSensorSide::INSUFFICIENT_DATA, EV3UartProtocolParserSensorSide::next_state(), EV3UartProtocolParserSensorSide::Parser::HeaderInformation::payload_length, EV3UartProtocolParserSensorSide::RECEIVED_CMD_INVALID_FCS, EV3UartProtocolParserSensorSide::RECEIVED_CMD_SELECT, EV3UartProtocolParserSensorSide::RECEIVED_CMD_WRITE, EV3UartProtocolParserSensorSide::RECEIVED_INVALID_HEADER, EV3UartProtocolParserSensorSide::RECEIVED_SYS_ACK, EV3UartProtocolParserSensorSide::RECEIVED_SYS_NACK, EV3UartProtocolParserSensorSide::WAIT_CHECKSUM, and EV3UartProtocolParserSensorSide::WAIT_HEADER.

|
private |
Internal buffer used to buffer information from the EV3.
buffer[0] stores the header byte received from the EV3 buffer[1] stores the first byte of the payload from the EV3 buffer[payload_length + 1] stores the FCS byte received from the EV3
Definition at line 227 of file EV3UartProtocolParserSensorSide.hpp.
|
private |
Definition at line 230 of file EV3UartProtocolParserSensorSide.hpp.
|
private |
Definition at line 228 of file EV3UartProtocolParserSensorSide.hpp.
|
private |
Definition at line 229 of file EV3UartProtocolParserSensorSide.hpp.