/* * @brief Serves the same purpose as formatted output string for the robot. * * Processes the input string into an output string rone understands. * If the input string is too large, cfprintfOverRunError is set to TRUE. * * @returns void */ void cprintf(char *format, ...) { va_list arguments; va_start(arguments, format); int32 potentialChars; boolean cfprintfOverRunError = FALSE; char* charPtr; if (cprintfOSInit) { osSemaphoreTake(cprintfMutex, portMAX_DELAY); } /* Process the input string and store the output in the 'outStringFormatted' */ /* note that vsnprintf returns the number of characters that would have been * written to the buffer if it were large enough. */ potentialChars = vsnprintf(cfprintfBufferPtr, CPRINTF_TEXT_STRING_SIZE - 1, format, arguments); if (potentialChars >= (CPRINTF_TEXT_STRING_SIZE - 1)) { cfprintfOverRunError = TRUE; } charPtr = cfprintfBufferPtr; while (*charPtr != '\0') { if (*charPtr == '\n') { // change '\n' into the current CRLF mode switch (CRLFMode) { case CPRINTF_CRLF_CR: sputchar('\r'); break; case CPRINTF_CRLF_CRLF: sputchar('\r'); sputchar('\n'); break; case CPRINTF_CRLF_LFCR: sputchar('\n'); sputchar('\r'); break; case CPRINTF_CRLF_LF: default: sputchar('\n'); break; } } else { sputchar(*charPtr); } charPtr++; } sputcharFlush(); if (cprintfOSInit) { osSemaphoreGive(cprintfMutex); } // clean up the argument list va_end(arguments); }
void sputs( u8 *txt ) // send string { while( *txt ) sputchar( *txt++ ); }
void sputs( void *s ) { uint8_t *s1 = s; while( *s1 ) sputchar( *s1++ ); }