I have a problem with sending binary data via ATxMega128A1.
I want to use the stdout
with fwrite
function, if possible. But I'm not able to set it in binary mode and every value that is 0x0a, is automatically converted to 0x0d 0x0a...
I'm totally frustrated, because all the wonderful solutions I found (fopen(..., "wb")
or fdopen(dup(fileno(stdout)), "wb");
from enter link description here or freopen(NULL, "wb", stdout)
and so on) won't work on avr-gnu-toolchain.
Can anyone help me please to transfer my array of simple binary data?
uint8_t data[10];
data[0] = 1;
data[1] = 2;
data[2] = 3;
data[3] = 10;
....
data[8] = 3;
data[9] = 5;
fwrite(data, 10, 1, stdout);
// receiving of 10 bytes at receiver:
// 0x01 0x02 0x03 0x0d 0x0a ... 0x03
As you can see the written data to serial port is appended by a leading 0x0d before the 0x0a and my last value is missing on receiver's side, when reading 10 bytes.
It is bad, that the interface automatically alters the data.
Is there a suitable solution to tell stdout
to go in "stupid" binary mode and just transfer the data as they are?!
Best regards
and I hope for a good solution