problems with fwrite on FPGA Power PC

Hi,

I'm using an FPGA (Xilinx Virtex-II Pro) with a power pc core build inside. I want to write a huge number of data from this device to Matlab on a computer through a serial (RS232) connection. Stdout is the output.

I'm using fwrite(&value,4,1,stdout) which works for all numbers except for 10 (or any other number with 00001010 in it).

for example:

int value = 5;
fwrite(&value,4,1,stdout);

gives: 0 0 0 5 = bytes in decimal form (which is what i expect)

but

int value = 10;
fwrite(&value,4,1,stdout);

gives: 0 0 0 13 10

It seems he mistakes the 10 as a new linefeed and outputs an extra carriage return in front of it? Is this normal and what or where can i solve this problem

thx in advance
Last edited on
This is probably due to stdout being a stream that operates in text mode.
You can try to reopen stdout in binary mode before sending the data:
 
freopen (NULL,"wb",stdout);

Topic archived. No new replies allowed.