PC <->Leon3 serial communication

Chris Johns chrisj at rtems.org
Mon Mar 20 11:38:37 UTC 2006


Luca Germano wrote:
> 
> seems that the leon3 bsp does not support to configure the UART with the 
> termios interface. I don't know if this means that also the termios 
> supports raw mode for data isd not supported.

The raw mode is handled in the termios code above the driver.

> The problem is that RTEMS for Leon3 mapp all the stdio on UART port. Can 
> you tell me what termios functions handle the raw data mode?? I can test 
> them. Thanks

The details are described here:

  http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap11.html

This code is typed in here and has not been compiled.

Regards
Chris

int tty_raw (const char* tty, int baudrate, int use_handshakes)
{
   struct termios term;

   int fd = open (tty, O_RDWR);

   if (fd < 0)
   {
     fprintf (stderr, "tty: open failed: %s\n", strerror (errno));
     return -1;

   if (tcgetattr (fd, &term) < 0)
   {
     fprintf (stderr, "tty: tcgetattr failed: %s\n", strerror (errno));
     close (fd);
     return -1;
   }

   /* No echo, no canonical processing, no extended processing,
    * signal characters off. */
   term.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);

   /* 8 bits, enable receiver */
   term.c_cflag = (CS8 | CREAD);

   /* Do we want to use handshake signals or not. */
   if (use_handshakes)
     term.c_cflag |= CLOCAL;
   else
     term.c_cflag |= CRTSCTS;

   /* Turn off output processing. */
   term.c_oflag &= ~OPOST;

   /* Ignore breaks. */
   term.c_iflag =  IGNBRK;

   /* Output flags */
   term.c_oflag = ONOCR;

   /* Set the interbyte timeout for receiving data. */
   term.c_cc[VMIN] = 64;
   term.c_cc[VTIME] = 1;

   cfsetispeed (&term, baudrate);
   cfsetospeed (&term, baudrate);

   if (tcsetattr (fd, TCSANOW, &term) < 0)
   {
     fprintf (stderr, "tty: tcsetattr failed: %s\n", strerror (errno));
     close (fd);
     return -1;
   }

   return fd;
}



More information about the users mailing list