Page 1 of 1

please check console log, when use chprintf

Posted: Mon Jun 13, 2022 8:59 am
by jslee
Hello, somebody help me please?

Below is my example code.

Code: Select all

uint64_t tempVal  = 315989888600;
chprintf(chp1, "\t tempVal : %d %03d\r\n", (tempVal / 1000), (tempVal % 1000));
uint64_t tempVal2 = tempVal % 1000;
chprintf(chp1, "\t tempVal2: %03d\r\n", tempVal2);

And I got console log like below

Code: Select all

tempVal : 315989888 000
tempVal2: 600


I was expecting
tempVal : 315989888 600
but, got
tempVal : 315989888 000

What am I doing wrong?

Re: please check console log, when use chprintf

Posted: Mon Jun 13, 2022 10:52 am
by Giovanni
Hi,

Do not pass uint64_t to chprintf(), cast it to uin32_t or assign values to 32 bits variables beforehand.

Giovanni

Re: please check console log, when use chprintf

Posted: Wed Jul 13, 2022 2:51 am
by jslee
Giovanni wrote:Hi,

Do not pass uint64_t to chprintf(), cast it to uin32_t or assign values to 32 bits variables beforehand.

Giovanni


Aright. No more problem. Thank you