32 const std::vector<CommandResult> results = {
makeCommandReply(reply, handler, cmdId, type,
nullptr)};
35 itf->sendReplies(results,
nullptr);
43 std::vector<CommandResult> results = {
makeCommandReply(reply, handler, cmdId, type,
this)};
50 fakeCmd.
cmdId = cmdId;
60 fakeResult.
reply = reply;
129 if(formatWriteAsRead){
135 reply +=
"NOT_FOUND";
138 if(result.reply.empty()){
141 uint16_t repliesRemaining = result.reply.size();
147 if(--repliesRemaining > 0){
170 if(originalCommand.
instance != 0xFF){
172 cmdstring += std::to_string(originalCommand.
instance);
181 cmdstring += std::string(cmdDef->
cmd);
187 cmdstring += std::to_string(originalCommand.
adr);
191 cmdstring += std::to_string(originalCommand.
val);
195 cmdstring += std::to_string(originalCommand.
val);
197 cmdstring += std::to_string(originalCommand.
adr);
213 replyPart.assign(reply.
reply);
215 replyPart = std::to_string(reply.
val);
217 replyPart = std::to_string(reply.
val);
219 replyPart += std::to_string(reply.
adr);
227 replyPart = std::to_string(originalCommand.
val);
229 replyPart = std::to_string(originalCommand.
val);
231 replyPart += std::to_string(originalCommand.
adr);
289 nextFormat = originalInterface !=
this && originalInterface !=
nullptr;
381 nextFormat = originalInterface !=
this && originalInterface !=
nullptr;
static TU_ATTR_ALWAYS_INLINE bool tud_cdc_connected(void)
std::vector< CommandResult > resultsBuffer
const uint32_t maxSendBuffer
virtual ~CDC_CommandInterface()
void batchDone() override
bool enableBroadcastFromOtherInterfaces
bool readyToSend() override
const uint32_t parserTimeout
void sendReplies(const std::vector< CommandResult > &results, CommandInterface *originalInterface) override
static uint16_t cdcSend(std::string *reply, uint8_t itf)
static uint32_t remainingData(uint8_t itf=0)
bool parse(std::vector< ParsedCommand > &commands)
void setClearBufferTimeout(uint32_t timeout)
bool add(char *Buf, uint32_t *Len)
virtual CmdHandlerCommanddef * getCommandFromId(const uint32_t id, uint32_t ignoredFlags=0)
virtual uint16_t getCommandHandlerID()
virtual CmdHandlerInfo * getCommandHandlerInfo()
virtual bool readyToSend()
virtual void sendReplyAsync(std::vector< CommandReply > &reply, CommandHandler *handler, uint32_t cmdId, CMDtype type)
static std::vector< CommandInterface * > cmdInterfaces
virtual bool hasNewCommands()
static void broadcastCommandReplyAsync(const std::vector< CommandReply > &reply, CommandHandler *handler, uint32_t cmdId, CMDtype type=CMDtype::get)
virtual ~CommandInterface()
static CommandResult makeCommandReply(const std::vector< CommandReply > &reply, CommandHandler *handler, uint32_t cmdId, CMDtype type=CMDtype::get, CommandInterface *originalInterface=nullptr)
virtual void sendReplies(const std::vector< CommandResult > &results, CommandInterface *originalInterface)=0
bool addBuf(char *Buf, uint32_t *Len)
static std::string formatOriginalCommandFromResult(const ParsedCommand &originalCommand, CommandHandler *commandHandler, const bool formatWriteAsRead=false)
bool getNewCommands(std::vector< ParsedCommand > &commands) override
static void generateReplyValueString(std::string &replyPart, const CommandReply &reply)
uint32_t bufferCapacity()
static void generateReplyFromCmd(std::string &replyPart, const ParsedCommand &originalCommand)
static void formatReply(std::string &reply, const std::vector< CommandResult > &results, const bool formatWriteAsRead=false)
const uint32_t parserTimeout
void sendReplies(const std::vector< CommandResult > &results, CommandInterface *originalInterface) override
void batchDone() override
UART_CommandInterface(uint32_t baud=115200)
virtual ~UART_CommandInterface()
std::vector< CommandResult > resultsBuffer
const uint32_t maxSendBuffer
bool enableBroadcastFromOtherInterfaces
UART_InitTypeDef uartconfig
UART_InitTypeDef & getConfig()
bool transmit_IT(const char *txbuf, uint16_t size)
bool reconfigurePort(UART_InitTypeDef &config)
uint32_t WaitForNotification(TickType_t Timeout=portMAX_DELAY)
void Delay(const TickType_t Delay)
void addCallbackHandler(std::vector< C > &vec, C instance)
void removeCallbackHandler(std::vector< C > &vec, C instance)
ParsedCommand originalCommand
CommandHandler * commandHandler
std::vector< CommandReply > reply
uint16_t handlerId
ID of the command handler responding to the command.
CommandInterface * originalInterface
Command interface on which this command was received. nullptr indicates a broadcast.
static TU_ATTR_ALWAYS_INLINE bool tud_ready(void)