@@ -34,6 +34,14 @@ void debug_print(char *type, char* filename, uint32_t line, char* format, ...)
3434{
3535 chMtxLock (& mtx );
3636
37+ uint8_t str [256 ];
38+
39+ va_list args ;
40+ va_start (args , format );
41+ chsnprintf ((char * )str , sizeof (str ), format , args );
42+ va_end (args );
43+
44+
3745 if (isConsoleOutputAvailable ()) {
3846 if (TRACE_TIME ) {
3947 chprintf ((BaseSequentialStream * )& SDU1 , "[%8d.%03d]" , chVTGetSystemTime ()/CH_CFG_ST_FREQUENCY , (chVTGetSystemTime ()* 1000 /CH_CFG_ST_FREQUENCY )%1000 );
@@ -42,12 +50,7 @@ void debug_print(char *type, char* filename, uint32_t line, char* format, ...)
4250 if (TRACE_FILE ) {
4351 chprintf ((BaseSequentialStream * )& SDU1 , "[%12s %04d]" , filename , line );
4452 }
45- chprintf ((BaseSequentialStream * )& SDU1 , " " );
46- va_list args ;
47- va_start (args , format );
48- chprintf ((BaseSequentialStream * )& SDU1 , (format ), args );
49- va_end (args );
50- chprintf ((BaseSequentialStream * )& SDU1 , "\r\n" );
53+ chprintf ((BaseSequentialStream * )& SDU1 , " %s\r\n" , str );
5154 }
5255
5356 if (TRACE_TIME ) {
@@ -57,12 +60,7 @@ void debug_print(char *type, char* filename, uint32_t line, char* format, ...)
5760 if (TRACE_FILE ) {
5861 chprintf ((BaseSequentialStream * )& SD3 , "[%12s %04d]" , filename , line );
5962 }
60- chprintf ((BaseSequentialStream * )& SD3 , " " );
61- va_list args ;
62- va_start (args , format );
63- chprintf ((BaseSequentialStream * )& SD3 , (format ), args );
64- va_end (args );
65- chprintf ((BaseSequentialStream * )& SD3 , "\r\n" );
63+ chprintf ((BaseSequentialStream * )& SD3 , " %s\r\n" , str );
6664
6765 chMtxUnlock (& mtx );
6866}
0 commit comments