|
Fang-Robotics-MCB
Fang Robotics Team Codebase
|
#include <dji_serial.hpp>


Classes | |
| struct | FrameHeader |
| struct | SerialMessage |
Public Types | |
| using | ReceivedSerialMessage = SerialMessage< SERIAL_RX_BUFF_SIZE > |
Public Member Functions | |
| DJISerial (Drivers *drivers, Uart::UartPort port, bool isRxCRCEnforcementEnabled=true) | |
| mockable | ~DJISerial ()=default |
| mockable void | initialize () |
| mockable void | updateSerial () |
| virtual void | messageReceiveCallback (const ReceivedSerialMessage &completeMessage)=0 |
Public Attributes | |
| struct tap::communication::serial::DJISerial::FrameHeader | modm_packed |
| struct tap::communication::serial::DJISerial::SerialMessage | modm_packed |
Static Public Attributes | |
| static const uint16_t | SERIAL_RX_BUFF_SIZE = 1024 |
| static const uint16_t | SERIAL_HEAD_BYTE = 0xA5 |
Protected Attributes | |
| Drivers * | drivers |
A serial handler that implements a specific protocol to be used for communicating with the referee system. Also used for our personal communication with the xavier.
Extend this class and implement messageReceiveCallback if you want to use this serial protocol on a serial line.
Structure of a Serial Message: \rst +--------------—+---------------------------------------------------------—+ | Byte Number | Byte Description | +=================+============================================================+ | Frame Header | +--------------—+---------------------------------------------------------—+ | 0 | Frame Head Byte (0xA5) | +--------------—+---------------------------------------------------------—+ | 1 | Frame Data Length, LSB | +--------------—+---------------------------------------------------------—+ | 2 | Frame Data Length, MSB | +--------------—+---------------------------------------------------------—+ | 3 | Frame Sequence Number | +--------------—+---------------------------------------------------------—+ | 4 | CRC8 of the frame, (bytes 0 - 3) | +--------------—+---------------------------------------------------------—+ | 5 | Message Type, LSB | +--------------—+---------------------------------------------------------—+ | 6 | Message Type, MSB | +--------------—+---------------------------------------------------------—+ | Body - Data Length bytes | +--------------—+---------------------------------------------------------—+ | Message CRC | +--------------—+---------------------------------------------------------—+ | 7 + Data Length | CRC16 of header and frame, LSB (bytes 0 - 6 + Data Length) | +--------------—+---------------------------------------------------------—+ | 8 + Data Length | CRC16 of header and frame, MSB | +--------------—+---------------------------------------------------------—+ \endrst
| using tap::communication::serial::DJISerial::ReceivedSerialMessage = SerialMessage<SERIAL_RX_BUFF_SIZE> |
| tap::communication::serial::DJISerial::DJISerial | ( | Drivers * | drivers, |
| Uart::UartPort | port, | ||
| bool | isRxCRCEnforcementEnabled = true |
||
| ) |
Construct a Serial object.
| [in] | port | serial port to work on. |
| [in] | isRxCRCEnforcementEnabled | true to enable Rx CRC Enforcement. |
|
default |
| void tap::communication::serial::DJISerial::initialize | ( | ) |
Initialize serial. In particular, initializes the hardware serial specified upon construction.
uart.hpp if you want to use the serial. Also, if you add a new uart port to be generated in the project.xml file, you should add it to both the Uart class and this function. Uart
|
pure virtual |
Called when a complete message is received. A derived class must implement this in order to handle incoming messages properly.
| [in] | completeMessage | a reference to the full message that has just been received by this class. |
Implemented in tap::communication::serial::RefSerial.
| void tap::communication::serial::DJISerial::updateSerial | ( | ) |
Receive messages. Call periodically in order to receive all incoming messages.
|
protected |
| struct tap::communication::serial::DJISerial::FrameHeader tap::communication::serial::DJISerial::modm_packed |
| struct tap::communication::serial::DJISerial::SerialMessage tap::communication::serial::DJISerial::modm_packed |
|
static |
|
static |