= Simple Serial Test Program = {{{ /* * File name: init.c * * A simple serial and shell test program. * * COPYRIGHT (c) 2008. * RobertF * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.com/license/LICENSE. * */ #define CONFIGURE_INIT #include #include #include /* String function definitions */ #include /* UNIX standard function definitions */ #include /* File control definitions */ #include /* Error number definitions */ #include /* POSIX terminal control definitions */ #include #include #include #include extern rtems_task Init(rtems_task_argument argument); #define CONFIGURE_APPLICATION_EXTRA_DRIVERS TTY1_DRIVER_TABLE_ENTRY #ifdef RTEMS_BSP_HAS_IDE_DRIVER #include /* for ata driver prototype */ #include /* for general ide driver prototype */ #endif #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER #ifdef RTEMS_BSP_HAS_IDE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER #endif #define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM /* * these values are higher than needed... */ #define CONFIGURE_MAXIMUM_TASKS 20 #define CONFIGURE_MAXIMUM_SEMAPHORES 20 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 20 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20 #define STACK_CHECKER_ON #define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_EXTRA_TASK_STACKS (6 * RTEMS_MINIMUM_STACK_SIZE) #define CONFIGURE_MALLOC_STATISTICS #include #define CONFIGURE_SHELL_COMMANDS_INIT #define CONFIGURE_SHELL_COMMANDS_ALL #include void testCom1(void) { char buffer[256]; printf("*** Simple COM1 Test (9600 8N1) ***\n"); int fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | _FNDELAY); printf("\nOpened COM1, fd=%d\n\n", fd); int numBytes = write(fd, "Hello, I'm waiting for input...\r\n", 33); if (numBytes < 0) { printf("\nFailed to send from COM1!\n"); } numBytes = read(fd, buffer, 255); if (numBytes < 0) { printf("\nFailed to read from COM1!\n"); } else { buffer[numBytes] = 0; // terminate printf(buffer); } close(fd); } rtems_task Init(rtems_task_argument ignored) { testCom1(); printf("\n====== starting shell ======\n"); rtems_shell_init( "SHLL", /* task_name */ RTEMS_MINIMUM_STACK_SIZE * 4, /* task_stacksize */ 100, /* task_priority */ "/dev/console", /* devname */ 0, /* forever */ 1 /* wait */ ); exit( 0 ); } }}}