Open FFBoard
Open source force feedback firmware
FFBoardMain Class Reference

#include <FFBoardMain.h>

Inheritance diagram for FFBoardMain:
ChoosableClass CommandHandler CANInputMain CanBridge CustomMain FFBHIDMain MidiMain TMCDebugBridge FFBHIDExt FFBJoystick FFBWheel

Public Member Functions

virtual const ClassIdentifier getInfo ()
 
const ClassType getClassType () override
 returns the used classchooser selection id of this instance More...
 
 FFBoardMain ()
 
virtual ~FFBoardMain ()
 
virtual void usbInit ()
 
virtual void update ()
 
virtual void cdcRcv (char *Buf, uint32_t *Len)
 
virtual void cdcRcvReady (uint8_t itf)
 
virtual void usbSuspend ()
 
virtual void usbResume ()
 
virtual CommandStatus command (const ParsedCommand &cmd, std::vector< CommandReply > &replies)
 
virtual std::string getHelpstring ()
 
- Public Member Functions inherited from ChoosableClass
virtual ~ChoosableClass ()
 
uint16_t getSelectionID ()
 
- Public Member Functions inherited from CommandHandler
 CommandHandler (const char *clsname, uint16_t clsid, uint8_t instance=0)
 
virtual ~CommandHandler ()
 
virtual bool hasCommands ()
 
virtual void setCommandsEnabled (bool enable)
 
void registerCommands ()
 
virtual CommandStatus internalCommand (const ParsedCommand &cmd, std::vector< CommandReply > &replies)
 
virtual std::string getCommandsHelpstring ()
 
virtual std::string getCsvHelpstring ()
 
virtual uint8_t getCommandHandlerInstance ()
 
void broadcastCommandReply (CommandReply reply, uint32_t cmdId, CMDtype type)
 
void sendCommandReplyAsync (CommandReply reply, uint32_t cmdId, CMDtype type, CommandInterface *interface=nullptr)
 
virtual uint16_t getCommandHandlerID ()
 
virtual CmdHandlerInfogetCommandHandlerInfo ()
 
virtual bool isValidCommandId (uint32_t cmdid, uint32_t ignoredFlags=0, uint32_t requiredFlag=0)
 
virtual CmdHandlerCommanddefgetCommandFromName (const std::string &cmd, uint32_t ignoredFlags=0)
 
virtual CmdHandlerCommanddefgetCommandFromId (const uint32_t id, uint32_t ignoredFlags=0)
 
template<typename ID >
void registerCommand (const char *cmd, const ID cmdid, const char *help=nullptr, uint32_t flags=0)
 

Static Public Member Functions

static bool isCreatable ()
 
- Static Public Member Functions inherited from ChoosableClass
static bool isCreatable ()
 
- Static Public Member Functions inherited from CommandHandler
static void logSerial (std::string string)
 Send a log formatted sequence. More...
 
static void logSerialDebug (std::string string)
 Send a log formatted sequence if debug is on. More...
 
static bool logsEnabled ()
 
static void setLogsEnabled (bool enabled)
 
static uint32_t getClassIdFromName (const char *name)
 
static const char * getClassNameFromId (const uint32_t id)
 
static CommandHandlergetHandlerFromHandlerId (const uint16_t cmdhandlerID)
 
static CommandHandlergetHandlerFromId (const uint16_t id, const uint8_t instance=0xFF)
 
static CommandHandlergetHandlerFromClassName (const char *name, const uint8_t instance=0xFF)
 
static std::vector< CommandHandler * > getHandlersFromClassName (const char *name)
 
static std::vector< CommandHandler * > getHandlersFromId (const uint16_t id)
 
static bool isInHandlerList (CommandHandler *handler)
 
static std::string getAllHelpstrings ()
 
static std::vector< CommandHandler * > & getCommandHandlers ()
 
template<typename TVal >
static CommandStatus handleGetSet (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value)
 
template<typename TVal , class cls , class cls1 >
static CommandStatus handleGetSetFunc (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value, void(cls1::*setfunc)(TVal), cls *obj)
 
template<typename TVal , class cls , class cls1 , class cls2 >
static CommandStatus handleGetFuncSetFunc (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal(cls1::*getfunc)(), void(cls2::*setfunc)(TVal), cls *obj)
 
template<typename TVal , class cls , class cls1 >
static CommandStatus handleGetFuncSet (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value, TVal(cls1::*getfunc)(), cls *obj)
 

Public Attributes

std::unique_ptr< FFBoardMainCommandThreadcommandThread
 
std::unique_ptr< CDC_CommandInterfacecdcCmdInterface = std::make_unique<CDC_CommandInterface>()
 
ErrorPrinter errorPrinter
 
SystemCommands systemCommands
 System command handler. More...
 
std::unique_ptr< UART_CommandInterfaceuartCmdInterface = std::make_unique<UART_CommandInterface>(115200)
 

Static Public Attributes

static ClassIdentifier info ={.name = "Basic (Failsafe)" ,.id=0}
 
- Static Public Attributes inherited from ChoosableClass
static ClassIdentifier info
 
- Static Public Attributes inherited from CommandHandler
static bool logEnabled = true
 

Protected Attributes

std::unique_ptr< USBdeviceusbdev
 
- Protected Attributes inherited from ChoosableClass
uint16_t selectionId
 Should only be written by ClassChooser during creation. More...
 
- Protected Attributes inherited from CommandHandler
bool commandsEnabled = true
 
std::vector< CmdHandlerCommanddefregisteredCommands
 
CmdHandlerInfo cmdHandlerInfo
 

Static Protected Attributes

static char cdcbuf []
 

Additional Inherited Members

- Protected Member Functions inherited from CommandHandler
void setInstance (uint8_t instance)
 
virtual void addCommandHandler ()
 
virtual void removeCommandHandler ()
 
- Static Protected Member Functions inherited from CommandHandler
static std::vector< uint16_t > & getCommandHandlerIds ()
 

Detailed Description

Definition at line 32 of file FFBoardMain.h.

Constructor & Destructor Documentation

◆ FFBoardMain()

FFBoardMain::FFBoardMain ( )

Definition at line 21 of file FFBoardMain.cpp.

◆ ~FFBoardMain()

FFBoardMain::~FFBoardMain ( )
virtual

Definition at line 94 of file FFBoardMain.cpp.

Member Function Documentation

◆ cdcRcv()

void FFBoardMain::cdcRcv ( char *  Buf,
uint32_t *  Len 
)
virtual

Called when data is received on the CDC port

Reimplemented in TMCDebugBridge, and CanBridge.

Definition at line 32 of file FFBoardMain.cpp.

◆ cdcRcvReady()

void FFBoardMain::cdcRcvReady ( uint8_t  itf)
virtual

Called by the CDC serial port when data is ready

Definition at line 40 of file FFBoardMain.cpp.

◆ command()

CommandStatus FFBoardMain::command ( const ParsedCommand cmd,
std::vector< CommandReply > &  replies 
)
virtual
Parameters
[in]cmdThe parsed command to be executed.
[out]repliesA vector to return one or multiple reply objects into. Replies to the interface will be generated based on the reply objects. A string reply may not contain start, end and separation markers: [,],| Other characters are allowed.

Reimplemented from CommandHandler.

Reimplemented in CanBridge, CANInputMain, CustomMain, FFBHIDMain, MidiMain, and TMCDebugBridge.

Definition at line 49 of file FFBoardMain.cpp.

◆ getClassType()

const ClassType FFBoardMain::getClassType ( )
inlineoverridevirtual

returns the used classchooser selection id of this instance

Type of this class. Mainclass, motordriver... Should be implemented by the parent class so it is not in the info struct

Reimplemented from ChoosableClass.

Definition at line 37 of file FFBoardMain.h.

◆ getHelpstring()

std::string FFBoardMain::getHelpstring ( )
virtual

Returns a description of this class

Reimplemented from CommandHandler.

Reimplemented in CanBridge, CANInputMain, CustomMain, FFBHIDMain, MidiMain, and TMCDebugBridge.

Definition at line 90 of file FFBoardMain.cpp.

◆ getInfo()

const ClassIdentifier FFBoardMain::getInfo ( )
virtual

Implements ChoosableClass.

Reimplemented in CANInputMain, CustomMain, FFBHIDExt, FFBJoystick, FFBWheel, MidiMain, TMCDebugBridge, CanBridge, and FFBHIDMain.

Definition at line 25 of file FFBoardMain.cpp.

◆ isCreatable()

static bool FFBoardMain::isCreatable ( )
inlinestatic

Definition at line 36 of file FFBoardMain.h.

◆ update()

void FFBoardMain::update ( )
virtual

Called in the default thread with no delay Can be reimplemented by custom main classes but should not block

Reimplemented in CanBridge, and MidiMain.

Definition at line 71 of file FFBoardMain.cpp.

◆ usbInit()

void FFBoardMain::usbInit ( )
virtual

Called during the startup Should initialize a USBdevice and call registerUsb()

Reimplemented in MidiMain, CANInputMain, FFBHIDExt, FFBJoystick, FFBWheel, and FFBHIDMain.

Definition at line 61 of file FFBoardMain.cpp.

◆ usbResume()

void FFBoardMain::usbResume ( )
virtual

Called when the usb port is connected

Reimplemented in FFBHIDMain.

Definition at line 85 of file FFBoardMain.cpp.

◆ usbSuspend()

void FFBoardMain::usbSuspend ( )
virtual

Called when the usb port is disconnected

Reimplemented in FFBHIDMain.

Definition at line 78 of file FFBoardMain.cpp.

Member Data Documentation

◆ cdcbuf

char FFBoardMain::cdcbuf
staticprotected

Definition at line 67 of file FFBoardMain.h.

◆ cdcCmdInterface

std::unique_ptr<CDC_CommandInterface> FFBoardMain::cdcCmdInterface = std::make_unique<CDC_CommandInterface>()

Definition at line 57 of file FFBoardMain.h.

◆ commandThread

std::unique_ptr<FFBoardMainCommandThread> FFBoardMain::commandThread

Definition at line 56 of file FFBoardMain.h.

◆ errorPrinter

ErrorPrinter FFBoardMain::errorPrinter

Definition at line 58 of file FFBoardMain.h.

◆ info

ClassIdentifier FFBoardMain::info ={.name = "Basic (Failsafe)" ,.id=0}
static

Definition at line 34 of file FFBoardMain.h.

◆ systemCommands

SystemCommands FFBoardMain::systemCommands

System command handler.

Definition at line 59 of file FFBoardMain.h.

◆ uartCmdInterface

std::unique_ptr<UART_CommandInterface> FFBoardMain::uartCmdInterface = std::make_unique<UART_CommandInterface>(115200)

Definition at line 62 of file FFBoardMain.h.

◆ usbdev

std::unique_ptr<USBdevice> FFBoardMain::usbdev
protected

Definition at line 66 of file FFBoardMain.h.


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