Comm ports on Pc386

Correo Fernando-ruiz (E-mail) correo at fernando-ruiz.com
Wed Jul 4 23:57:48 UTC 2001


Hi Angelo.

Trying touch a minimum the config.c well compiled and executed is this.

/*
 *  Simple test program -- simplified version of sample test hello.
 *
 *  COPYRIGHT (c) 1989-1999.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.OARcorp.com/rtems/license.html.
 *
 *  $Id: main.c,v 1.3 2000/06/12 15:00:12 joel Exp $
 */

#define TEST_INIT

#include <bsp.h>

void test_main( void );

rtems_task Init(
  rtems_task_argument ignored
)
{
  test_main();

  rtems_task_delete(RTEMS_SELF);

}

/* configuration information */

#include <rtems.h>
#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_HAS_OWN_DEVICE_DRIVER_TABLE
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_MAXIMUM_TASKS             6

#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM

/* You needs this in order to start anything wrong when the task_create
(JOEL?)*/

#define CONFIGURE_MEMORY_OVERHEAD   16384
#define CONFIGURE_EXTRA_TASK_STACKS
(CONFIGURE_MAXIMUM_TASKS*4*RTEMS_MINIMUM_STACK_SIZE)

#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()
/* Whether you have a high priority task without
rtems_wait(delay/event/sem/queue/etc)
   you can hangup the system
(Try to change to realtime any task in the Windows2000/NT task list*/
{
  rtems_status_code status;
  Task_name = rtems_build_name( 'T', 'A', '1', ' ' );
  status = rtems_task_create(
    Task_name, 100, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES, &Task_id
  );
  status = rtems_task_start( Task_id, Test_task, 1 );


/*
 Problems in the device driver when the port is reopened/shared
 Test_task uses also /dev/ttyS1 (Perhaps no problem only a little mistake)
 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+"); /* B9600|CS0 termios default*/

	if (!fp)
		{
			printf ("Unable to open %s", tty_ports [0]);
		}
	else
		{
			while (1)
				{
					if (!fputc('t', fp))  /* Not the best use */
						{
							printf ("unable to write to port");
						}
					rtems_task_wake_after(10); /* A while */
				}
		}
}

/* end of file */

The 'tttt..' stream is showed every bufer size number of t's.

The fputc uses I/O buffered. You need raw I/O better(like the shell).

browse the sources and see rtems/c/src/libmisc/shell/shell.c

There you can see how a termios port is changed to raw mode and the buffer
is eliminated.
Also you can see how the bauds are changed. (My source was
rtems/c/src/tests/libtests/termios)

in shell_scanline I do a readkey() and putch() using two fildes of same
device.

PS:
 When login... (On a minicom/hyperterminal client or on /dev/console)
 The user 'root' is the superuser and 'rtems' is the normal user.
 The password is not validated (crypt.c missing) by the moment.

 Write a /etc/motd and /etc/issue and you can have a more friendly logiun
process.

browse the sources and see rtems/c/src/libmisc/shell/cmds.c in order add
your commands.

Enjoy it.

Do you want another kind of serial device mode?


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: martes, 03 de julio de 2001 22:50
Para: fernando.ruiz at ctv.es
CC: Correo Fernando-ruiz (E-mail) (E-mail)
Asunto: Re: Comm ports on Pc386


Find attached the source and makefile. Thank you very much for taking the
time to look at these
Warmest regards
Angelo Fraietta
"Fernando RUIZ CASAS (E-mail)" wrote:
 Can you send me all the source test application in order to rebuild in my
environment?Regards
Fernando RUIZ CASAS

home:correo at fernando-ruiz.com
work:fernando.ruiz at ctv.es


...





More information about the users mailing list