Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::communication::serial::DJISerial Class Referenceabstract

#include <dji_serial.hpp>

Inheritance diagram for tap::communication::serial::DJISerial:
Collaboration diagram for tap::communication::serial::DJISerial:

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

Driversdrivers
 

Detailed Description

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

Member Typedef Documentation

◆ ReceivedSerialMessage

Constructor & Destructor Documentation

◆ DJISerial()

tap::communication::serial::DJISerial::DJISerial ( Drivers drivers,
Uart::UartPort  port,
bool  isRxCRCEnforcementEnabled = true 
)

Construct a Serial object.

Parameters
[in]portserial port to work on.
[in]isRxCRCEnforcementEnabledtrue to enable Rx CRC Enforcement.

◆ ~DJISerial()

mockable tap::communication::serial::DJISerial::~DJISerial ( )
default

Member Function Documentation

◆ initialize()

void tap::communication::serial::DJISerial::initialize ( )

Initialize serial. In particular, initializes the hardware serial specified upon construction.

Note
currently, only uart ports 1, 2, and 6 are enabled. Be sure to add a serial port to 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.
See also
Uart

◆ messageReceiveCallback()

virtual void tap::communication::serial::DJISerial::messageReceiveCallback ( const ReceivedSerialMessage completeMessage)
pure virtual

Called when a complete message is received. A derived class must implement this in order to handle incoming messages properly.

Parameters
[in]completeMessagea reference to the full message that has just been received by this class.

Implemented in tap::communication::serial::RefSerial.

◆ updateSerial()

void tap::communication::serial::DJISerial::updateSerial ( )

Receive messages. Call periodically in order to receive all incoming messages.

Note
tested with a delay of 10 microseconds with referee system. The longer the timeout the more likely a message failure may occur.

Member Data Documentation

◆ drivers

Drivers* tap::communication::serial::DJISerial::drivers
protected

◆ modm_packed [1/2]

struct tap::communication::serial::DJISerial::FrameHeader tap::communication::serial::DJISerial::modm_packed

◆ modm_packed [2/2]

struct tap::communication::serial::DJISerial::SerialMessage tap::communication::serial::DJISerial::modm_packed

◆ SERIAL_HEAD_BYTE

const uint16_t tap::communication::serial::DJISerial::SERIAL_HEAD_BYTE = 0xA5
static

◆ SERIAL_RX_BUFF_SIZE

const uint16_t tap::communication::serial::DJISerial::SERIAL_RX_BUFF_SIZE = 1024
static

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