RES: Serial device access with qemu!

Wendell Pereira da Silva wendell.silva at compsisnet.com.br
Tue Nov 23 12:18:56 UTC 2010


Dear Jeferson,

Well, let us try tty_driver  :-)

Put #include <bsp/tty_drv.h> in your include list before #include <rtems/confdefs.h>

Rigth after CONFIGURE_NUMBER_OF_TERMIOS_PORTS put the following:
#define CONFIGURE_APPLICATION_EXTRA_DRIVERS \
      TTY1_DRIVER_TABLE_ENTRY, \
      TTY2_DRIVER_TABLE_ENTRY

Let me know if it works.

Wendell.


________________________________
De: Jeferson Luiz Rodrigues Souza [mailto:jeferodrigues at gmail.com]
Enviada em: terça-feira, 23 de novembro de 2010 09:12
Para: Wendell Pereira da Silva
Cc: rtems-users at rtems.org
Assunto: Re: Serial device access with qemu!

Hi Wendell,

thanks for your reply.
On Tue, Nov 23, 2010 at 11:04 AM, Wendell Pereira da Silva <wendell.silva at compsisnet.com.br<mailto:wendell.silva at compsisnet.com.br>> wrote:
Hi Jeferson,

Note that "/dev/ttyS0" in the QEMU is not the same path registered by the pc586 (pc386 variant) BSP.
Do you have tried "/dev/ttyS1"?

Yes, I tried with "/dev/ttyS1" and the same problem happens. I also tested the serial port in the host and it is ok.

Any idea?

Rest regards,
Jeferson.

Best regards,

Wendell.

________________________________
De: rtems-users-bounces at rtems.org<mailto:rtems-users-bounces at rtems.org> [mailto: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 06:50
Para: rtems-users at rtems.org<mailto:rtems-users at rtems.org>
Assunto: Serial device access with qemu!

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.

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);
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20101123/063c13b6/attachment-0001.html>


More information about the users mailing list