Using TTY Drivers with i386/pc386 BSP

Mike Siers mikes at poliac.com
Thu Apr 5 13:27:45 UTC 2001


Hi Joel,
Yep, when I increased the number of file descriptors
it fixed my problem.  I had already incresed the number
of termios ports.

Thanks for the help
Mike Siers


-----Original Message-----
From: Joel Sherrill [mailto:joel.sherrill at OARcorp.com]
Sent: Wednesday, April 04, 2001 2:04 PM
To: Mike Siers
Cc: rtems-users at oarcorp.com
Subject: Re: Using TTY Drivers with i386/pc386 BSP


configure more file descriptors.  The default is just enough
for stdin, out, and error to save memory.  Also you probably
need to increase CONFIGURE_NUMBER_OF_TERMIOS_PORTS to reflect
that you will have multiple ones open concurrently.  See

http://www.oarcorp.com/rtems/releases/4.5.0/rtemsdoc-4.5.0/share/rtemsdoc/ht
ml/c_user/c_user00379.html

for descriptions.

Mike Siers wrote:
>
> Hi,
> I am trying to use the tty serial device drivers for the
> pc386 BSP.  The code below is my test code to open up the
> serial port, configure it, and write out some text data.
> I tested this code under OpenBSD with the exact same hardware
> and it works fine.  When I run the code under RTEMS it says
> the /dev/ttyS1 device is initialized but the open command
> fails.  Any help would be greatly appreciated.
>
> Thanks
> Mike Siers
>
> ===========================================================
>
> #include <stdio.h>
> #include <string.h>
> #include <unistd.h>
> #include <fcntl.h>
> #include <errno.h>
> #include <termios.h>
>
> #define CONFIGURE_INIT
> #include <rtems.h>
> #include <tty_drv.h>
>
> /* functions */
> rtems_task Init(rtems_task_argument argument);
>
> #include <bsp.h>
>
> #define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
> rtems_driver_address_table Device_drivers[3] = {
>   CONSOLE_DRIVER_TABLE_ENTRY,
>   TTY1_DRIVER_TABLE_ENTRY,
>   {NULL, NULL, NULL, NULL, NULL, NULL}
> };
>
> #define CONFIGURE_MAXIMUM_TASKS             4
> #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> #define CONFIGURE_EXTRA_TASK_STACKS         (3 * RTEMS_MINIMUM_STACK_SIZE)
>
> #include <confdefs.h>
>
> rtems_task Init(rtems_task_argument argument)
> {
>   int              i;
>   int              iStatus;
>   int              iLength;
>   int              iFile;
>   struct termios   options;
>   char            *pData  = "YEP-YEP-YEP\r\n";
>
>   puts( "\n\n*** SERIAL TEST ***" );
>
>   iFile = open("/dev/ttyS1", O_RDWR|O_NOCTTY);
>   if ( iFile == -1 ) {
>     puts("*** PORT /dev/ttyS1 OPEN FAILED ***");
>   }
>   else {
>     fcntl(iFile, F_SETFL, 0);
>
>     tcgetattr(iFile, &options);
>     cfsetispeed(&options, B9600);
>     cfsetospeed(&options, B9600);
>     options.c_cflag     |=  (CLOCAL|CREAD|CS8);
>     options.c_lflag     &= ~(ICANON|ECHO|ECHOE|ISIG);
>     options.c_oflag     &= ~(OPOST);
>     options.c_cc[VMIN]  =  0;
>     options.c_cc[VTIME] =  10;
>     tcsetattr(iFile, TCSANOW, &options);
>
>     iLength = strlen(pData);
>     for (i=0; i<20; i++) {
>       iStatus = write(iFile, (void *)pData, iLength);
>       if ( iStatus < iLength ) {
>         puts("*** PORT /dev/ttyS1 WRITE FAILED ***");
>       }
>     }
>
>     close(iFile);
>     iFile = (int)-1;
>   }
> }
>
> ===========================================================

--
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985




More information about the users mailing list