@@ -250,19 +250,16 @@ void CDC_CommandInterface::Run(){
250250
251251
252252void CDC_CommandInterface::sendReplies (const std::vector<CommandResult>& results,CommandInterface* originalInterface){
253- // if( (!enableBroadcastFromOtherInterfaces && originalInterface != this) ){
254- // return;
255- // }
256- //
257- // replystr.reserve(100);
258- // StringCommandInterface::formatReply(replystr,results, originalInterface != this && originalInterface != nullptr);
259- // if(!replystr.empty())
260- // CDCcomm::cdcSend(&replystr, 0);
253+
254+ if (HAL_GetTick () - lastSendTime > parserTimeout){
255+ resultsBuffer.clear (); // Empty buffer because we were not able to reply in time to prevent the full buffer from blocking future commands
256+ // CDCcomm::clearRemainingBuffer(0);
257+ }
261258
262259 if ( (!enableBroadcastFromOtherInterfaces && originalInterface != this ) ){
263260 return ;
264261 }
265-
262+ lastSendTime = HAL_GetTick ();
266263 resultsBuffer.assign (results.begin (), results.end ());
267264 resultsBuffer.shrink_to_fit ();
268265 nextFormat = originalInterface != this && originalInterface != nullptr ;
@@ -273,6 +270,9 @@ void CDC_CommandInterface::sendReplies(const std::vector<CommandResult>& results
273270 * Ready to send if there is no data in the backup buffer of the cdc port
274271 */
275272bool CDC_CommandInterface::readyToSend (){
273+ if (HAL_GetTick () - lastSendTime > parserTimeout && CDCcomm::remainingData (0 ) == 0 ){
274+ return true ;
275+ }
276276 return CDCcomm::remainingData (0 ) == 0 && resultsBuffer.empty ();
277277}
278278
0 commit comments