RES: Serial device access with qemu!

Joel Sherrill joel.sherrill at OARcorp.com
Tue Nov 23 18:32:09 UTC 2010


Hi,

I have attached a diff to 4.9 which will make the pc386 install
tty_drv.h.  There is also a diff to the fileio sample to show
the configuration changes.  Plus a png to show that the
serial devices are there.

Hopefully this will help.

--joel

On 11/23/2010 12:12 PM, Wendell Pereira da Silva wrote:
>
> Jeferson,
>
> Try to incriese the number of termio file descriptors:
>
> #define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 6
>
> Regards,
>
> Wendell.
>
> ------------------------------------------------------------------------
>
> *De:*rtems-users-bounces at rtems.org 
> [mailto:rtems-users-bounces at rtems.org] *Em nome de *Jeferson Luiz 
> Rodrigues Souza
> *Enviada em:* terça-feira, 23 de novembro de 2010 13:25
> *Para:* Joel Sherrill
> *Cc:* rtems-users at rtems.org
> *Assunto:* Re: Serial device access with qemu!
>
> Dear Joel,
>
> On Tue, Nov 23, 2010 at 2:21 PM, Joel Sherrill 
> <joel.sherrill at oarcorp.com <mailto:joel.sherrill at oarcorp.com>> wrote:
>
> On 11/23/2010 02:50 AM, Jeferson Luiz Rodrigues Souza wrote:
>
> Hi everyone,
>
> I am trying to access a serial port in RTEMS 4.9.4 using a pc586 bsp. 
> However, when I execute the application using qemu the code cannot 
> open the device, and the perror() function presents the following 
> message: "No such file or directory". It seems that RTEMS did not 
> initialize a properly driver to handle serial device. Is it right?
>
> The qemu command line is:
>
> sudo qemu -serial "/dev/ttyS0" -fda floppy.img -boot a
>
> I made a search in this list and I found references about serial port 
> access but nothing to help in my case. Could anyone help me or point 
> me some documentation about serial port access in RTEMS?
>
> The code used in the test is presented below. I do not have some 
> experience with RTEMS and I do not know the source of this problem.
>
> The /dev/ttyS0 above is the host serial port.  The -serial says
> attach attach the serial port COM1 on the target simulator
> PC to the specified device.  So you are attaching the virtual
> COM1 to the real serial port on the host /dev/ttyS0. Is that
> what you intend to do?
>
> FWIW COM1 --> /dev/ttyS1
> COM2 --> /dev/ttyS2
>
> on the RTEMS target.
>
>
> I need to read some data from a device connected in the host serial 
> port (e.g. /dev/ttyS0) inside an application running in RTEMS with 
> qemu.  So, is my source code correct? or Do I need some extra 
> configuration?
>
> Where is the name of serial devices in RTEMS defined? I tried use the 
> open() function as follows:
>
>  int serial_fp = open("/dev/ttyS0",O_RDONLY);
> or
>  int serial_fp = open("/dev/ttyS1",O_RDONLY);
> or
>  int serial_fp = open("COM1",O_RDONLY);
>
> and got the same message when I checked the serial_fp value and print 
> the error message using perror() function: "No such file or directory"
>
> Thanks to reply,
>
> Best regards,
> Jeferson.
>
>     --joel
>
>         Thanks,
>         jefecomp.
>
>
>         #include <signal.h>
>         #include <stdlib.h>
>         #include <stdio.h>
>         #include <pthread.h>
>         #include <uart.h>
>         #include <termios.h>
>         #include<sched.h>
>         #include <bsp.h>
>         #include <fcntl.h>
>         #include <sys/types.h>
>         #include <sys/stat.h>
>
>         #define CONFIGURE_INIT
>         #include <rtems.h>
>
>
>         void *POSIX_Init();
>
>         #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
>         #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
>         #define CONFIGURE_APPLICATIONS_NEEDS_RTC_DRIVER
>         #define CONFIGURE_MICROSECONDS_PER_TICK 1000
>
>         #define CONFIGURE_MAXIMUM_POSIX_THREADS 10
>         #define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 10
>         #define CONFIGURE_MAXIMUM_POSIX_MUTEXES 10
>         #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 10
>         #define CONFIGURE_MAXIMUM_POSIX_TIMERS 10
>         #define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 40
>         #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 10
>         #define CONFIGURE_POSIX_INIT_THREAD_TABLE
>         #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
>         #define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 3
>         #include<rtems/confdefs.h>
>
>         void *POSIX_Init()
>         {
>            printf("Serial Port Test!!!\n");
>
>            char buffer[255];
>            int bytesRead;
>            int serial_fp = open("/dev/ttyS0",O_RDONLY);
>
>            printf("SERIAL_FP = %i\n",serial_fp);
>
>            if(serial_fp < 0)
>            {
>                printf("FAILURE TO OPEN SERIAL PORT\n");
>                perror(serial_fp);
>                exit(-1);
>            }
>
>            //write(serial_fp,buffer,strlen(buffer)+1);
>            bytesRead = read(serial_fp, buffer, 255);
>
>
>            if(bytesRead < 0)
>            {
>                printf("Problems in the read of Serial Port");
>                close(serial_fp);
>                exit(1);
>            }
>            else
>                buffer[bytesRead] = 0;
>
>
>            printf(buffer);
>
>            close(serial_fp);
>            exit(0);
>         }
>
>     -- 
>     Joel Sherrill, Ph.D.             Director of Research&  Development
>     joel.sherrill at OARcorp.com        On-Line Applications Research
>     Ask me about RTEMS: a free RTOS  Huntsville AL 35805
>       Support Available             (256) 722-9985
>


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


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pc386_tty.diff
URL: <http://lists.rtems.org/pipermail/users/attachments/20101123/9c544974/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pc386_tty.png
Type: image/png
Size: 9017 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/users/attachments/20101123/9c544974/attachment.png>


More information about the users mailing list