I think I have just found a small issue with chvprintf function, which is related to the width definition when the width is supposed to be defined during run-time, e.g.:
Code: Select all
uint32_t ii = 1234;
uint8_t width = 12;
chprintf( (BaseSequentialStream *)&SD3, "%0*d \r\n", width , ii);
The results should be:
000000001234
and is:
*d
For the record I am using current version of chibios from github and gcc compiler 6.3.1. The platform is nucleo144 stm32f767 but the issue would be visible on any platform.
I have a fix which works for me:
file chprintfc.c, function chvprintf, starting line 174
current version:
Code: Select all
/* Width modifier.*/
if (c == '*') {
width = va_arg(ap, int);
}
modified version:
Code: Select all
/* Width modifier.*/
if ( *fmt == '*') {
width = va_arg(ap, int);
++fmt;
c = *fmt++;
}
The problem can be tested using simple project (blinker + few lines calling chprintf) which I have attached to this post.
Funny is that exactly this few lines were modified in around May 2019 and the bug was introduced - the earlier version worked ok...
Jurek