This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

printf() problem

Hello,

I'm using Keil to write data over the serial port.

ubyte b=0x0A;
printf("%c",b);


with this code I reveive two bytes: “0x0D” and “0x0A” in PC instead of “0x0A”. This happens only with “0x0A”. What's wrong with it?

Thanks
Senmeis

Parents
  • You made an assumption that the output stream would be binary. When in text mode, you get the two-character newline sequence used by Windows/MS-DOS.

    Was it the PC who sent the data, or was it the PC who receievd. Normal PC programs will convert newline into two characters if the stream isn't set as binary. Most probably, Keil has similar support on their side.

Reply
  • You made an assumption that the output stream would be binary. When in text mode, you get the two-character newline sequence used by Windows/MS-DOS.

    Was it the PC who sent the data, or was it the PC who receievd. Normal PC programs will convert newline into two characters if the stream isn't set as binary. Most probably, Keil has similar support on their side.

Children