rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Functions
priv Namespace Reference

Data Structures

class  FuncChain
 
class  FuncChain< TFirst, TRest... >
 
class  FuncChain<>
 

Functions

void efiPrintfInternal (const char *format,...)
 

Detailed Description

Author
Matthew Kennedy, (c) 2019

This lets us compose multiple functions in to a single function. If we have conversion functions F(x), G(x), and H(x), we can define a new function FuncChain<F, G, H> that will compute H(G(F(X))). F first, then G, then H.

Function Documentation

◆ efiPrintfInternal()

void priv::efiPrintfInternal ( const char format,
  ... 
)

Definition at line 177 of file loggingcentral.cpp.

177 {
178#if EFI_UNIT_TEST || EFI_SIMULATOR
179 if (verboseMode) {
180 printf("[%dus]efiPrintfInternal:", time2print(getTimeNowUs()));
181 va_list ap;
182 va_start(ap, format);
183 vprintf(format, ap);
184 va_end(ap);
185 printf("\r\n");
186 }
187#endif
188#if (EFI_PROD_CODE || EFI_SIMULATOR) && EFI_TEXT_LOGGING
189 LogLineBuffer* lineBuffer;
190 msg_t msg;
191
192 {
193 // Acquire a buffer we can write to
194 chibios_rt::CriticalSectionLocker csl;
195 msg = freeBuffers.fetchI(&lineBuffer);
196 }
197
198 // No free buffers available, so we can't log
199 if (msg != MSG_OK) {
200 return;
201 }
202
203 // Write the formatted string to the output buffer
204 va_list ap;
205 va_start(ap, format);
206 size_t len = chvsnprintf(lineBuffer->buffer, sizeof(lineBuffer->buffer), format, ap);
207 va_end(ap);
208
209 // Ensure that the string is comma-terminated in case it overflowed
210 lineBuffer->buffer[sizeof(lineBuffer->buffer) - 1] = LOG_DELIMITER[0];
211
212 if (len > sizeof(lineBuffer->buffer) - 1)
213 len = sizeof(lineBuffer->buffer) - 1;
214 for (size_t i = 0; i < len; i++) {
215 /* just replace all non-printable chars with space
216 * TODO: is there any other "prohibited" chars? */
217 if (isprint(lineBuffer->buffer[i]) == 0)
218 lineBuffer->buffer[i] = ' ';
219 }
220
221 {
222 // Push the buffer in to the written list so it can be written back
223 chibios_rt::CriticalSectionLocker csl;
224
225 filledBuffers.postI(lineBuffer);
226 }
227#endif
228}
efitimeus_t getTimeNowUs()
Definition efitime.cpp:26
int time2print(int64_t time)
Definition efitime.h:22
bool verboseMode
static chibios_rt::Mailbox< LogLineBuffer *, lineBufferCount > filledBuffers
static chibios_rt::Mailbox< LogLineBuffer *, lineBufferCount > freeBuffers
char buffer[256]
printf("\n")

Referenced by efiPrintfInternal().

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