Author Topic: [BitCloud] Sprintf and ExtAddr_t  (Read 908 times)

0 Members and 1 Guest are viewing this topic.

Offline danergo

  • Regular Contributor
  • *
  • Posts: 111
  • Country: hu
[BitCloud] Sprintf and ExtAddr_t
« 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
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 6323
  • Country: us
    • Personal site
Re: [BitCloud] Sprintf and ExtAddr_t
« Reply #1 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.


 
Alex
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf