EEVblog Electronics Community Forum

Electronics => Microcontrollers => Topic started by: danergo on November 27, 2015, 01:21:29 pm

Title: [BitCloud] Sprintf and ExtAddr_t
Post by: danergo on November 27, 2015, 01:21:29 pm
Hello,

This should be a very easy stuff. How can I send back on usart an ExtAddr_t?
Usart is up and works okay, however:
Code: [Select]
//extaddr is declared and defined somewhere else
char buffer[100];
sprintf(buffer, "ADDR: %llu\n\r", extaddr);
sendonusart(buffer, strlen(buffer));

This code only sends "ADDR: " (and \n\r).
So usart is working, sprintf is working, but %llu looks not working somewhy. Have you seen this?

Thanks!
danergo
Title: Re: [BitCloud] Sprintf and ExtAddr_t
Post by: ataradov on November 27, 2015, 07:33:08 pm
So usart is working, sprintf is working, but %llu looks not working somewhy. Have you seen this?
That depends on your compiler and libc, not BitCloud.

The easiest way that is supported by all possible combinations is to print the address in hex and split it into two parts:

Code: [Select]
char buffer[100];
sprintf(buffer, "ADDR: %08lx%08lx\n\r", (uint32_t)(extaddr>>32), (uint32_t)(extaddr & 0xffffffff));
sendonusart(buffer, strlen(buffer));

I think some sample application print out 64-bit values, but they might do the same thing.