- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The base you should use (last parameter in itoa) is ten(10) and not two(2)
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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