Serial communication on Leon3

Fernando RUIZ correo at fernando-ruiz.com
Wed Mar 15 18:50:03 UTC 2006


HI,

 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.


here
http://www.rtems.com/cgi-bin/viewcvs.cgi/rtems/cpukit/libmisc/shell/shell.c?
rev=1.14&content-type=text/vnd.viewcvs-markup

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 &=
~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
    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
attributes(%s)\n",devname);
    };
----------------------------------


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


Hi
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?
Thanks





More information about the users mailing list