Comm ports on Pc386

Joel Sherrill joel.sherrill at OARcorp.com
Tue Jul 3 13:13:19 UTC 2001



Angelo Fraietta wrote:
> 
> I appears that the call to fopen should somehow make its way to tty1_open. I
> do not believe that this is happening as I am not getting the fail message
> from that call.  Tomorrow I will have a closer investigation and maybe place
> some code in there to display whether it is getting there. Could it be that
> the call to fopen requires some other configuration in order to map the
> device driver to the filename?

No it is likely that you do not have enough file descriptors allocated. The
default is 3 (stdin, out, and error).  

> Angelo Fraietta wrote:
> 
> > Thank you for the help you have provided so far. I eventually got the
> > program to build by adding
> > #define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
> >
> > When I attempt to run the program, I get the message that /dev/ttsy1 & 2
> > are initialised, however, I get the messages
> >
> > RTEMS: creating task sh1 in shell_init() (status: request not satisfied)
> >
> > I get a similar message for all three tasks.  Additionally, I spawned a
> > task like the previous attempt, using  fopen ("/dev/ttys1"), however, this
> > fails also.
> >
> > The code in its entirety is as follows:
> >
> > #define TEST_INIT
> >
> > #include <bsp.h>
> >
> > void test_main( void );
> >
> > rtems_task Init(
> >   rtems_task_argument ignored
> > )
> > {
> >   test_main();
> > }
> >
> > /* configuration information */
> >
> > #include <rtems.h>
> > #include <tty_drv.h>
> > #include <console.h>
> > #include <clockdrv.h>
> > #include <timerdrv.h>
> >
> >
> >
> > #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> > #define CONFIGURE_MAXIMUM_TASKS             6
> >
> > rtems_driver_address_table Device_drivers[] = {
> >         CONSOLE_DRIVER_TABLE_ENTRY,
> >         TTY1_DRIVER_TABLE_ENTRY,
> >         TTY2_DRIVER_TABLE_ENTRY,
> >         CLOCK_DRIVER_TABLE_ENTRY,
> >         {NULL,NULL,NULL,NULL,NULL,NULL},
> > };
> >
> > #define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
> > #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> >
> > /*#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER*/
> >
> > #define CONFIGURE_INIT
> >
> > #include <confdefs.h>
> > #include <stdio.h>
> >
> > rtems_id   Task_id;
> > rtems_name Task_name;
> >
> > rtems_task Test_task( rtems_task_argument unused);
> > void test_main()
> > {
> >   rtems_status_code status;
> >   Task_name = rtems_build_name( 'T', 'A', '1', ' ' );
> >   status = rtems_task_create(
> >     Task_name, 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
> >     RTEMS_DEFAULT_ATTRIBUTES, &Task_id
> >   );
> >   status = rtems_task_start( Task_id, Test_task, 1 );
> >
> >
> > shell_init("sh1",16384,100,"/dev/ttyS1"  ,B9600|CS8,TRUE);
> > shell_init("sh2",16384,100,"/dev/ttyS2"  ,B9600|CS8,TRUE);
> > shell_init("shc",16384,100,"/dev/console",B9600|CS8,TRUE);
> >
> > }
> >
> >
> > const char* tty_ports [] =
> > {
> >  "/dev/ttyS1",
> >  "/dev/ttyS2"
> > };
> >
> > rtems_task Test_task(
> >   rtems_task_argument unused
> > )
> > {
> >
> >  FILE* fp = fopen (tty_ports [0], "r+");
> >
> >  if (!fp)
> >   {
> >    printf ("Unable to open %s", tty_ports [0]);
> >   }
> >  else
> >   {
> >    while (1)
> >     {
> >      if (!fputc('t', fp))
> >       {
> >        printf ("unable to write to port");
> >       }
> >     }
> >   }
> > }
> >
> >
> > "Fernando RUIZ CASAS (E-mail)" wrote:
> >
> >> Hi
> >> If you want to use shell_init without tpc/ip enabled I can send to you
> >> the patch already submitted to Joel.(05/26/01)
> >>
> >> I have not made none modification in the pc386 BSP code to enable
> >> the ports. Only this code has been used.
> >> In shell_init only a make raw mode TERMIOS is done
> >> (How the linux man page says)
> >> None error is showed in the compilation of pc386(pc686) bsp.
> >>
> >> Browse in the sources and ask directely to Eric, Rosimildo & more about
> >> the
> >> use of this. (The authors of little patchs...)
> >> I have use this ports like a linux device using only TERMIOS programming.
> >>
> >> And this works successfully.
> >>
> >> Your code seems correct. I Can try it.
> >>
> >> Fernando RUIZ CASAS
> >> home:correo at fernando-ruiz.com
> >> work:fernando.ruiz at ctv.es
> >>
> >> > -----Mensaje original-----
> >> > De: Angelo Fraietta [mailto:angelo at hunterlink.net.au]
> >> > Enviado el: lunes, 02 de julio de 2001 3:38
> >> > Para: correo at fernando-ruiz.com
> >> > CC: Rtems-Users (E-mail)
> >> > Asunto: Re: Comm ports on Pc386
> >> >
> >> >
> >> > I am using the previous snapshot as  do not have networking
> >> > enabled. I am
> >> > trying to open the commport and write some chars (for now).
> >> > If I just try to
> >> > open the port without the code you provided, the file does
> >> > not open. I assume
> >> > it is because the port has to be configured with the code you
> >> > provided.
> >> > However, trying to compile this below, I get a heap of parse errors in
> >> > ttr_drv.h.
> >> > Is this because of the snapshot or am I doing something wrong here?
> >> >
> >> >
> >> >
> >> >
> >> > #include <tty_drv.h>
> >> > #include <console.h>
> >> > #include <clockdrv.h>
> >> > #include <timerdrv.h>
> >> >
> >> > rtems_driver_address_table Device_drivers[] = {
> >> >         CONSOLE_DRIVER_TABLE_ENTRY,
> >> >         TTY1_DRIVER_TABLE_ENTRY,
> >> >         TTY2_DRIVER_TABLE_ENTRY,
> >> >         CLOCK_DRIVER_TABLE_ENTRY,
> >> >         {NULL,NULL,NULL,NULL,NULL,NULL},
> >> > };
> >> >
> >> > #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> >> > #define CONFIGURE_MAXIMUM_TASKS             1
> >> > #include <confdefs.h>
> >> >
> >> > rtems_id   Task_id;
> >> > rtems_name Task_name;
> >> >
> >> > const char* tty_ports [] =
> >> > {
> >> >  "/dev/ttyS1",
> >> >  "/dev/ttyS2"
> >> > };
> >> >
> >> > rtems_task Test_task(
> >> >   rtems_task_argument unused
> >> > )
> >> > {
> >> >  FILE* fp = fopen (tty_ports [0], "r+");
> >> >
> >> >  if (!fp)
> >> >   {
> >> >    printf ("Unable to open %s", tty_ports [0]);
> >> >   }
> >> >  else
> >> >   {
> >> >    while (1)
> >> >     {
> >> >      if (!fputc('t', fp))
> >> >       {
> >> >        printf ("unable to write to port");
> >> >       }
> >> >     }
> >> >   }
> >> >
> >> > }
> >> >
> >> > Init()
> >> > {
> >> >  Task_name = rtems_build_name( 'T', 'A', '1', ' ' );
> >> >   rtems_status_code status;
> >> >   status = rtems_task_create(
> >> >     Task_name, 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
> >> >     RTEMS_DEFAULT_ATTRIBUTES, &Task_id
> >> >   );
> >> >   status = rtems_task_start( &Task_id, Test_task, 1 );
> >> > }
> >> >
> >> >
> >> >
> >> >
> >> > "Correo Fernando-ruiz (E-mail)" wrote:
> >> >
> >> > > > -----Mensaje original-----
> >> > > > De: Angelo Fraietta [mailto:angelo at hunterlink.net.au]
> >> > > > Enviado el: jueves, 28 de junio de 2001 3:52
> >> > > > Para: rtems-users
> >> > > > Asunto: Comm ports on Pc386
> >> > > >
> >> > > >
> >> > > > Does anyone have an example of using the comm ports on a
> >> > PC386 build?
> >> > > >
> >> > > > --
> >> > >
> >> > > ***************************************************************
> >> > >
> >> > > #include <tty_drv.h>
> >> > > #include <console.h>
> >> > > #include <clockdrv.h>
> >> > > #include <timerdrv.h>
> >> > >
> >> > > rtems_driver_address_table Device_drivers[] = {
> >> > >         CONSOLE_DRIVER_TABLE_ENTRY,
> >> > >         TTY1_DRIVER_TABLE_ENTRY,
> >> > >         TTY2_DRIVER_TABLE_ENTRY,
> >> > >         CLOCK_DRIVER_TABLE_ENTRY,
> >> > >         {NULL,NULL,NULL,NULL,NULL,NULL},
> >> > > };
> >> > > #include <confdefs.h>
> >> > >
> >> > > ****************************************************************
> >> > >
> >> > > Adding this like rtems device configuration you have
> >> > > THREE termios ports in your PC.
> >> > >
> >> > > /dev/console
> >> > > /dev/ttyS1
> >> > > /dev/ttyS2
> >> > >
> >> > > How to manage this ports with TERMIOS?
> >> > > See the /rtems/c/src/tests/libtests/termios directory.
> >> > > A complete program to drive a termios device.
> >> > > (My first source to understand it. Thanks Eric Norum)
> >> > > Enjoy it.
> >> > >
> >> > > Are you using the last snapshot (20010525)?
> >> > > With this you can open remote consoles in every port termios.
> >> > >
> >> > > /* TASK NAME,STACK SIZE, TASK PRIO, DEV_NAME, BAUDS & LINE
> >> > SETT.,FOREVER*/
> >> > > #include <shell.h>
> >> > > Init() {
> >> > > ...
> >> > > shell_init("sh1",16384,100,"/dev/ttyS1"  ,B38400|CS8,TRUE);
> >> > > shell_init("sh2",16384,100,"/dev/ttyS2"  ,B38400|CS8,TRUE);
> >> > > shell_init("shc",16384,100,"/dev/console",B38400|CS8,TRUE);
> >> > > ...
> >> > > }
> >> > >
> >> > > Three users accessing at same time at the PC but with RTEMS rtos.
> >> > > A new task for evevy user.
> >> > >
> >> > > Fernando RUIZ CASAS
> >> > > home: correo at fernando-ruiz.com
> >> > > work: fernando.ruiz at ctv.es
> >> > >
> >> > > > Angelo Fraietta
> >> > > >
> >> > > > PO Box 859
> >> > > > Hamilton NSW 2303
> >> > > >
> >> > > > Home Page
> >> > > >
> >> > > > http://users.hunterlink.net.au/~maaaf/
> >> > > >
> >> > > > There are those who seek knowledge for the sake of
> >> > knowledge - that is
> >> > > > CURIOSITY
> >> > > > There are those who seek knowledge to be known by others - that is
> >> > > > VANITY
> >> > > > There are those who seek knowledge in order to serve -
> >> > that is LOVE
> >> > > >     Bernard of Clairvaux (1090 - 1153)
> >> > > >
> >> > > >
> >> > > >
> >> >
> >> > --
> >> > Angelo Fraietta
> >> >
> >> > PO Box 859
> >> > Hamilton NSW 2303
> >> >
> >> > Home Page
> >> >
> >> > http://users.hunterlink.net.au/~maaaf/
> >> >
> >> > There are those who seek knowledge for the sake of knowledge - that is
> >> > CURIOSITY
> >> > There are those who seek knowledge to be known by others -
> >> > that is VANITY
> >> > There are those who seek knowledge in order to serve - that is LOVE
> >> >     Bernard of Clairvaux (1090 - 1153)
> >> >
> >> >
> >> >
> >
> > --
> > Angelo Fraietta
> >
> > PO Box 859
> > Hamilton NSW 2303
> >
> > Home Page
> >
> > http://users.hunterlink.net.au/~maaaf/
> >
> > There are those who seek knowledge for the sake of knowledge - that is
> > CURIOSITY
> > There are those who seek knowledge to be known by others - that is VANITY
> > There are those who seek knowledge in order to serve - that is LOVE
> >     Bernard of Clairvaux (1090 - 1153)
> >
> 
> --
> Angelo Fraietta
> 
> PO Box 859
> Hamilton NSW 2303
> 
> Home Page
> 
> http://users.hunterlink.net.au/~maaaf/
> 
> There are those who seek knowledge for the sake of knowledge - that is
> CURIOSITY
> There are those who seek knowledge to be known by others - that is VANITY
> There are those who seek knowledge in order to serve - that is LOVE
>     Bernard of Clairvaux (1090 - 1153)
> 

-- 
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