Open FFBoard
Open source force feedback firmware
UART_CommandInterface Class Reference

#include <CommandInterface.h>

Inheritance diagram for UART_CommandInterface:
UARTDevice cpp_freertos::Thread StringCommandInterface CommandInterface

Public Member Functions

 UART_CommandInterface (uint32_t baud=115200)
 
virtual ~UART_CommandInterface ()
 
void Run ()
 
void sendReplies (const std::vector< CommandResult > &results, CommandInterface *originalInterface) override
 
void uartRcv (char &buf)
 
bool readyToSend ()
 
const std::string getHelpstring ()
 
void batchDone () override
 
- Public Member Functions inherited from UARTDevice
 UARTDevice ()
 
 UARTDevice (UARTPort &port)
 
virtual ~UARTDevice ()
 
virtual void startUartTransfer (UARTPort *port, bool transmit)
 
virtual void endUartTransfer (UARTPort *port, bool transmit)
 
- Public Member Functions inherited from cpp_freertos::Thread
 Thread (const std::string Name, uint16_t StackDepth, UBaseType_t Priority)
 
 Thread (const char *Name, uint16_t StackDepth, UBaseType_t Priority)
 
 Thread (uint16_t StackDepth, UBaseType_t Priority)
 
bool Start ()
 
virtual ~Thread ()
 
TaskHandle_t GetHandle ()
 
void Suspend ()
 
void Resume ()
 
void ResumeFromISR ()
 
void Notify ()
 
void NotifyFromISR ()
 
uint32_t WaitForNotification (TickType_t Timeout=portMAX_DELAY)
 
UBaseType_t GetPriority ()
 
UBaseType_t GetPriorityFromISR ()
 
void SetPriority (UBaseType_t NewPriority)
 
std::string GetName ()
 
char * GetName ()
 
- Public Member Functions inherited from StringCommandInterface
 StringCommandInterface (uint32_t bufferMaxCapacity=512)
 
bool addBuf (char *Buf, uint32_t *Len)
 
uint32_t bufferCapacity ()
 
bool getNewCommands (std::vector< ParsedCommand > &commands) override
 
- Public Member Functions inherited from CommandInterface
 CommandInterface ()
 
virtual ~CommandInterface ()
 
virtual bool hasNewCommands ()
 
virtual void sendReplyAsync (std::vector< CommandReply > &reply, CommandHandler *handler, uint32_t cmdId, CMDtype type)
 

Private Attributes

const uint32_t parserTimeout = 2000
 
UART_InitTypeDef uartconfig
 
uint32_t baud = 115200
 
std::string sendBuffer
 
bool enableBroadcastFromOtherInterfaces = false
 
std::vector< CommandResultresultsBuffer
 
bool nextFormat = false
 
uint32_t bufferLength = 0
 
const uint32_t maxSendBuffer = 512
 

Additional Inherited Members

- Static Public Member Functions inherited from cpp_freertos::Thread
static void Yield ()
 
static void StartScheduler ()
 
static void EndScheduler ()
 
- Static Public Member Functions inherited from StringCommandInterface
static void formatReply (std::string &reply, const std::vector< CommandResult > &results, const bool formatWriteAsRead=false)
 
static std::string formatOriginalCommandFromResult (const ParsedCommand &originalCommand, CommandHandler *commandHandler, const bool formatWriteAsRead=false)
 
static void generateReplyValueString (std::string &replyPart, const CommandReply &reply)
 
static void generateReplyFromCmd (std::string &replyPart, const ParsedCommand &originalCommand)
 
- Static Public Member Functions inherited from CommandInterface
static CommandResult makeCommandReply (const std::vector< CommandReply > &reply, CommandHandler *handler, uint32_t cmdId, CMDtype type=CMDtype::get, CommandInterface *originalInterface=nullptr)
 
static void broadcastCommandReplyAsync (const std::vector< CommandReply > &reply, CommandHandler *handler, uint32_t cmdId, CMDtype type=CMDtype::get)
 
- Static Public Attributes inherited from CommandInterface
static std::vector< CommandInterface * > cmdInterfaces
 
- Protected Member Functions inherited from cpp_freertos::Thread
virtual void Cleanup ()
 
void Delay (const TickType_t Delay)
 
void DelayUntil (const TickType_t Period)
 
void ResetDelayUntil ()
 
bool Wait (ConditionVariable &Cv, Mutex &CvLock, TickType_t Timeout=portMAX_DELAY)
 
- Protected Attributes inherited from UARTDevice
UARTPortuartport = nullptr
 
- Protected Attributes inherited from StringCommandInterface
CmdParser parser
 
- Protected Attributes inherited from CommandInterface
bool parserReady = false
 

Detailed Description

Definition at line 91 of file CommandInterface.h.

Constructor & Destructor Documentation

◆ UART_CommandInterface()

UART_CommandInterface::UART_CommandInterface ( uint32_t  baud = 115200)

Definition at line 327 of file CommandInterface.cpp.

◆ ~UART_CommandInterface()

UART_CommandInterface::~UART_CommandInterface ( )
virtual

Definition at line 338 of file CommandInterface.cpp.

Member Function Documentation

◆ batchDone()

void UART_CommandInterface::batchDone ( )
overridevirtual

Command thread signals that all commands in this batch are done

Reimplemented from CommandInterface.

Definition at line 399 of file CommandInterface.cpp.

◆ getHelpstring()

const std::string UART_CommandInterface::getHelpstring ( )
inlinevirtual

Reimplemented from StringCommandInterface.

Definition at line 101 of file CommandInterface.h.

◆ readyToSend()

bool UART_CommandInterface::readyToSend ( )
virtual

Ready to send if there is no data in the backup buffer of the cdc port

Reimplemented from CommandInterface.

Definition at line 345 of file CommandInterface.cpp.

◆ Run()

void UART_CommandInterface::Run ( )
virtual

Implementation of your actual thread code. You must override this function.

Note
If INCLUDE_vTaskDelete is defined, then you may return from your Run method. This will cause the task to be deleted from FreeRTOS, however you are still responsible to delete the task object. If this is not defined, then retuning from your Run() method will result in an assert.

Implements cpp_freertos::Thread.

Definition at line 350 of file CommandInterface.cpp.

◆ sendReplies()

void UART_CommandInterface::sendReplies ( const std::vector< CommandResult > &  results,
CommandInterface originalInterface 
)
overridevirtual

Implements CommandInterface.

Definition at line 370 of file CommandInterface.cpp.

◆ uartRcv()

void UART_CommandInterface::uartRcv ( char &  buf)
virtual

Receives one byte and adds it to the parser

Reimplemented from UARTDevice.

Definition at line 390 of file CommandInterface.cpp.

Member Data Documentation

◆ baud

uint32_t UART_CommandInterface::baud = 115200
private

Definition at line 109 of file CommandInterface.h.

◆ bufferLength

uint32_t UART_CommandInterface::bufferLength = 0
private

Definition at line 116 of file CommandInterface.h.

◆ enableBroadcastFromOtherInterfaces

bool UART_CommandInterface::enableBroadcastFromOtherInterfaces = false
private

Definition at line 111 of file CommandInterface.h.

◆ maxSendBuffer

const uint32_t UART_CommandInterface::maxSendBuffer = 512
private

Definition at line 117 of file CommandInterface.h.

◆ nextFormat

bool UART_CommandInterface::nextFormat = false
private

Definition at line 115 of file CommandInterface.h.

◆ parserTimeout

const uint32_t UART_CommandInterface::parserTimeout = 2000
private

Definition at line 106 of file CommandInterface.h.

◆ resultsBuffer

std::vector<CommandResult> UART_CommandInterface::resultsBuffer
private

Definition at line 114 of file CommandInterface.h.

◆ sendBuffer

std::string UART_CommandInterface::sendBuffer
private

Definition at line 110 of file CommandInterface.h.

◆ uartconfig

UART_InitTypeDef UART_CommandInterface::uartconfig
private

Definition at line 108 of file CommandInterface.h.


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