Serial communication on Leon3

Fernando RUIZ correo at
Wed Mar 15 18:50:03 UTC 2006


 You can close stdin,stdout,stderr and reopen like /dev/null.

With this your serial device will be free for your private use.

You need reopen the serial device /dev/ttyS1 (or similar name)
in raw mode.

Consult the shell.c source to known the setup procedure.

Use man linux to show all the options.

In shell.c the input device can be any character device (serial, socket
tcp/ip, ...)
and the characters are read one by one.

See you.


You have availiable a raw stream.

   setvbuf(stdin,NULL,_IONBF,0); /* Not buffered*/
   /* make a raw terminal,Linux MANuals */
   if (tcgetattr (fileno(stdin), &term)>=0) {
    term.c_iflag &=
    term.c_oflag &= ~OPOST;
    term.c_oflag |= (OPOST|ONLCR); /* But with cr+nl on
output */
    term.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
    term.c_cflag  = CLOCAL | CREAD |(shell_env->tcflag);
    term.c_cc[VMIN]  = 1;
    term.c_cc[VTIME] = 0;
    if (tcsetattr (fileno(stdin), TCSADRAIN, &term) < 0) {
      fprintf(stderr,"shell:cannot set terminal

-----Mensaje original-----
De: Luca Germano [mailto:lucagermano at]
Enviado el: mercredi 15 mars 2006 18:11
Para: rtems-users at
Asunto: Serial communication on Leon3

I must handle a serial communication between Leon3 and a Linux Pc.
Rtems mapps the stdio on UART. I have a lot of problems to read byte
from serial port on Leon3 with the standard C function like getc or
scanf. Have someone handled a serial communication on Leon3 UART?

More information about the users mailing list