ERIS CORE

◆ sendLZ4Message()

void FASTRUN SvcSerialCommandInterface::sendLZ4Message ( )

Calling this function signals the end of a compressed message.
The txBuffer contents are lz4 compressed, base64 encoded and finally sent.
The serial message format is "LZ4 [UNCOMPRESSED_SIZE] [BASE64 encoded LZ4 compressed message]".

Definition at line 115 of file svcSerialCommandInterface.cpp.

115  {
116  uint16_t compressed_len,uncompressed_len;
117 
118  while(throttle()){
119  delay(5);
120  };
121 #ifdef USE_EXTMEM
122  //do nothing - one time malloc in the constructor
123 #else
124  char workingBuffer[SERIAL_WORKING_BUFFER_SIZE];
125 #endif
126  am->requestArmSetClock(CPU_BOOST_MAX_FREQ);
127  memset(p_working_buffer,0,SERIAL_WORKING_BUFFER_SIZE);
128  uncompressed_len = index_tx_buffer;
129  compressed_len = LZ4_compress_fast(p_tx_Buffer,p_working_buffer,index_tx_buffer,SERIAL_WORKING_BUFFER_SIZE,1);
130  empty();
131  encode_base64((unsigned char *)p_working_buffer, compressed_len, (unsigned char *)p_tx_Buffer);
132 
133  Serial.print("LZ4 ");
134  Serial.print(uncompressed_len);
135  Serial.print(" ");
136  Serial.println(p_tx_Buffer);
137  am->requestArmSetClock(CPU_BASE_FREQ);
138 
139 #ifdef USE_EXTMEM
140  //do nothing - one time malloc in the constructor
141 #else
142  //do nothing - local var
143 #endif
144 }
AppManager * am
Definition: AppBaseClass.h:38
bool requestArmSetClock(uint32_t requested_cpu_frequency)
provides an interface for apps to request cpu freq change note: this is only a request....
Definition: AppManager.cpp:603
bool throttle()
returns true if the available serial buffer falls below SERIAL_THROTTLE_BUFFER_REMAINING_THRESHOLD if...
void empty()
zero out the transmit buffer and reset the write index

References AppBaseClass::am, empty(), index_tx_buffer, p_tx_Buffer, p_working_buffer, AppManager::requestArmSetClock(), and throttle().

Referenced by AudioDirector::getAudioStreamObjByName(), AppWren::isWrenResultOK(), AppWren::loadScript(), AppCQT::messageHandler(), SvcErisAudioParameterController::messageHandler(), messageHandler_GET_RAM1(), messageHandler_GET_RAM2(), SvcDataDictionary::printDictionary(), AppManager::printStats(), AudioDirector::printStats(), AppWren::rebootRequest(), AppCQT::render(), streamTransmitHandler(), update(), and writeFn().

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