Environment:
Tower kit using twrk60d100m processor board
Using MQX 4.0.2 and CW 10.5.
Using J-Link or on-board (USB) JTAG
Problem:
The application has printf statements and also vprintf statements in it.
printf output shows up on the debug console
vprintf output disappears
My research results so far:
printf ends up using a routine that writes to the console (and uses SEMIHOSTING SWI) to send characters - these appear on the debug console under CW debug
vprintf tries to use the kernel table->active task->stdout file pointer (which is NULL) and because of a test for NULL, throws away all the output.
My question:
How can I get the vprintf output to show up on the debug console?
Failing that, how can I get the printf and vprintf output to show up in the same place?
Hi Stephen,
Please have a look at my attached "hello.c" file that can be placed into your MQX4.0/mqx/examples/hello2 folder.
Assumptions are RTOS user_config.h has #define BSPCFG_ENABLE_IODEBUG 1.
The BSP tower header file modified with following (I tested this on my TWR-K20D72M using OSBDM interface):
Please look at comments "//DES" in source file.
#ifndef BSP_DEFAULT_IO_CHANNEL
#if BSPCFG_ENABLE_IODEBUG //DES was BSPCFG_ENABLE_TTYB
#define BSP_DEFAULT_IO_CHANNEL "iodebug:" //IDE debug console //DES was "ttyb:" /* OSJTAG-COM polled mode */
#define BSP_DEFAULT_IO_CHANNEL_DEFINED
#else
#define BSP_DEFAULT_IO_CHANNEL NULL
#endif
#else
/* undef is for backward compatibility with user_configh.h files which have already had it defined */
#undef BSP_DEFAULT_IO_CHANNEL_DEFINED
#define BSP_DEFAULT_IO_CHANNEL_DEFINED
#endif
In summary from the hello.c file:
#if CUSTOMER_CODE2 //DES 1=test,0=default code
errmsg( "%s %d %s\n", "Failed", 100, "times" ); //DES Note: without the "\n" errmsg doesn't display the message (unless another printf used with "\n"). With the "\n" it displays OK.
#endif
My console window shows:
Hello
World
Error: Failed 100 times
Regards,
David