cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1

Anonymous
Not applicable

Hello
I need to send a binary value through ethernet, i´m using a library  2ForLife_W5100 in PSOC5LP.
My problem is that i need to convert a binary value to char to send. I´m trying to use this, but isn´t work:

itoa(exibe_AZ,total_AZ, 2);

The declaration:

    uint16 total_AZ = 0;
    uint16 total_EL = 0;
    char exibe_AZ[16];
    char exibe_EL[16];

Obs: I included stdlib.h

0 Likes
2 Replies
Bob_Marlowe
Expert II

The base you should use (last parameter in itoa) is ten(10) and not two(2)

   

 

   

Bob

0 Likes
SuMa_296631
Contributor II

Presumably you will be sending 4 x 8-bit values that make up the (assumed) 32-bit integer, so what is to stop you sending each 8-bit value just as it is?

   

Something like:

   

sendByte( value & 0xff);
sendByte( (value >> 😎 & 0xff);
sendByte( (value >> 16) & 0xff);
sendByte( (value >> 24) & 0xff);

   

Susan

0 Likes