ERIS CORE

◆ throttle()

bool FASTRUN SvcSerialCommandInterface::throttle ( )

returns true if the available serial buffer falls below SERIAL_THROTTLE_BUFFER_REMAINING_THRESHOLD if the buffer falls below SERIAL_THROTTLE_CHECK_CONNECTION_BUFFER_THRESHOLD delay for a small period of time if another check finds the buffer isn't moving then flush the buffer. returns false otherwise

Returns
true
false

Definition at line 169 of file svcSerialCommandInterface.cpp.

169  {
170  uint16_t avail;
171  avail = Serial.availableForWrite();
172 
173  if(avail < SERIAL_THROTTLE_CHECK_CONNECTION_BUFFER_THRESHOLD){
174  uint16_t delta_avail;
175  uint16_t msec_delay_counter = 0;
176  //serial tx buffer not available
177  do{
178  delay(5);
179  msec_delay_counter += 5;
180  delta_avail = Serial.availableForWrite();
181  if (delta_avail > SERIAL_THROTTLE_CHECK_CONNECTION_BUFFER_THRESHOLD) break;
182  } while (msec_delay_counter < SERIAL_THROTTLE_CHECK_CONNECTION_MAX_DELAY);
183 
184  if(avail == delta_avail){
185  return true;
186  } else{
187  //Serial.println(F("M WRN throttling"));//use this for debug only!
188  am->data->increment("SERIAL_THROTTLE_EVENTS");
189  }
190  }
191  if(avail < SERIAL_THROTTLE_BUFFER_THRESHOLD) return true;
192  return false;
193 }
AppManager * am
Definition: AppBaseClass.h:38
SvcDataDictionary * data
Definition: AppManager.h:63
bool increment(const char *key)
increments the value of a global record creates a new record if one does not exist and initializes ...

References AppBaseClass::am, AppManager::data, and SvcDataDictionary::increment().

Referenced by flush(), messageHandler_GET(), messageHandler_GET_RAM1(), messageHandler_GET_RAM2(), messageHandler_LS(), AudioDirector::printStats(), send(), sendLZ4Message(), streamTransmitHandler(), txOverflowHandler(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: