[En-Nut-Discussion] Translation of \n to \r\n
Dusan Ferbas
dferbas at etech.cz
Sat Dec 6 20:04:37 CET 2008
Hi Ajit,
if you want to reduce code size, you can use following, simpler way:
uart = fopen("uart0", "r+b"); //select binary mode
//following is set automatically when binary mode is selected
//_ioctl(_fileno(uart), UART_SETCOOKEDMODE, &cooked_mode);
Dusan
At 1 Dec 2008 14:36:09, Ajit Narayanan wrote:
>Thanks Ole, this indeed fixes the problem.
>
>Ajit
>
> > Hi Ajit,
> >
> >> I am running Ethernut on an AT91SAM7x256 board.
> >>
> >> I find that the following statements:
> >> NutRegisterDevice(&DEV_UART, 0, 0);
> >> file = fopen(DEV_UART_NAME, "r+");
> >> fputc( '\n', file );
> >>
> >> results in \r\n being sent over the UART, instead of just \n.
> >>
> >> Is this the expected behavior? How can I send just a \n?
> >
> > Seems you have enabled cooked mode. Try the following:
> >
> > u_long cooked_mode = 0;
> > _ioctl(_fileno(file), UART_SETCOOKEDMODE, &cooked_mode);
> >
> > Setting cooked_mode disables cooked mode for this uart and will result
> > in binary transmission.
Dusan
More information about the En-Nut-Discussion
mailing list