Example #1
0
size_t debugPrint(const char *fmt, ...)
/*
  printf style debugging output
  outputs a trailing newline
*/
{
  va_list ap;
  va_start(ap, fmt);
  NullStream lenStream = {&nullVmt, 0};
  chvprintf((BaseSequentialStream *) &lenStream, fmt, ap);
  size_t len = lenStream.len;
  if (len) {
    chMtxLock(&debugOutLock);
    size_t qspace = chOQGetEmptyI(&debugOutQ);
    if (qspace) {
      if (len >= qspace)
        len = qspace - 1;  //truncate string if it won't fit in queue
      if (len) {
        if (len > 255)
          len = 255;
        qStream dbgStream = {&qVmt, len};
        chOQPutTimeout(&debugOutQ, len, TIME_IMMEDIATE);
        chvprintf((BaseSequentialStream *) &dbgStream, fmt, ap);
        resumeReader();
        len++;
      }
    }else
      len=0;
    chMtxUnlock();
  }else
    if (debugPutc('\n') >= 0)
      len=1;
  va_end(ap);
  return len;
}
Example #2
0
static void vappendPrintfI(Logging *logging, const char *fmt, va_list arg) {
	intermediateLoggingBuffer.eos = 0; // reset
	efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#1b");
	chvprintf((BaseSequentialStream *) &intermediateLoggingBuffer, fmt, arg);
	intermediateLoggingBuffer.buffer[intermediateLoggingBuffer.eos] = 0; // need to terminate explicitly
	append(logging, (char *) intermediateLoggingBufferData);
}
Example #3
0
/**
 * This methods prints the message to whatever is configured as our primary console
 */
void print(const char *format, ...) {
	if (!is_serial_ready())
		return;
	va_list ap;
	va_start(ap, format);
	chvprintf((BaseSequentialStream *)CONSOLE_CHANNEL, format, ap);
	va_end(ap);
}
Example #4
0
void debugPrint(const char * fmt, ...)
{
    va_list ap;
    va_start(ap, fmt);
    chMtxLock(&printMtx);
    chvprintf((BaseSequentialStream*)&SERIAL_DRIVER, fmt, ap);
    chMtxUnlock();
    va_end(ap);
}
Example #5
0
static void lcdPrintf(const char *fmt, ...) {
	va_list ap;
	va_start(ap, fmt);
	lcdLineStream.eos = 0; // reset
	chvprintf((BaseSequentialStream *) &lcdLineStream, fmt, ap);
	lcdLineStream.buffer[lcdLineStream.eos] = 0; // terminator
	va_end(ap);
	lcd_HD44780_print_string(lcdLineBuffer);
}
Example #6
0
/**
 * This methods prints the message to whatever is configured as our primary console
 */
void print(const char *format, ...) {
#if !EFI_UART_ECHO_TEST_MODE
	if (!isCommandLineConsoleReady()) {
		return;
	}
	va_list ap;
	va_start(ap, format);
	chvprintf((BaseSequentialStream*) getConsoleChannel(), format, ap);
	va_end(ap);
#endif /* EFI_UART_ECHO_TEST_MODE */
}
Example #7
0
void LogTextMessage(const char* format, ...) {
  if ((usbGetDriverStateI(BDU1.config->usbp) == USB_ACTIVE) && (connected)) {
    int h = 0x546F7841; // "AxoT"
    chSequentialStreamWrite((BaseSequentialStream * )&BDU1,
                            (const unsigned char* )&h, 4);

    va_list ap;
    va_start(ap, format);
    chvprintf((BaseSequentialStream *)&BDU1, format, ap);
    va_end(ap);
    chSequentialStreamPut((BaseSequentialStream * )&BDU1, 0);
  }
}
Example #8
0
size_t debugPrint(const char *fmt, ...)
/*
  printf style debugging output
  outputs a trailing newline
*/
{
  size_t len;
  va_list ap;
  va_start(ap, fmt);
  static MUTEX_DECL(debugPrintLock);
  static uint8_t buf[debugPrintBufSize];
  static MemoryStream dbgStream;
  chMtxLock(&debugPrintLock);
  msObjectInit(&dbgStream, buf, sizeof(buf), 0);
  chvprintf((BaseSequentialStream *) &dbgStream, fmt, ap);
  va_end(ap);
  debugPut(buf, len=dbgStream.eos);
  chMtxUnlock();
  return len;
}
Example #9
0
// todo: why is this method here and not in error_handling.c ?
void firmwareError(const char *fmt, ...) {
	if (hasFirmwareErrorFlag)
		return;
	setOutputPinValue(LED_ERROR, 1);
	turnAllPinsOff();
	hasFirmwareErrorFlag = TRUE;
	if (indexOf(fmt, '%') == -1) {
		/**
		 * in case of simple error message let's reduce stack usage
		 * because chvprintf might be causing an error
		 */
		strcpy((char*) errorMessageBuffer, fmt);

	} else {
		firmwareErrorMessageStream.eos = 0; // reset
		va_list ap;
		va_start(ap, fmt);
		chvprintf((BaseSequentialStream *) &firmwareErrorMessageStream, fmt, ap);
		va_end(ap);

		firmwareErrorMessageStream.buffer[firmwareErrorMessageStream.eos] = 0; // need to terminate explicitly
	}
}
Example #10
0
static void vappendPrintfI(Logging *logging, const char *fmt, va_list arg) {
	intermediateLoggingBuffer.eos = 0; // reset
	chvprintf((BaseSequentialStream *) &intermediateLoggingBuffer, fmt, arg);
	intermediateLoggingBuffer.buffer[intermediateLoggingBuffer.eos] = 0; // need to terminate explicitly
	append(logging, (char *) intermediateLoggingBufferData);
}