Dear Joel,<br><br><div class="gmail_quote">On Tue, Nov 23, 2010 at 2:21 PM, Joel Sherrill <span dir="ltr"><<a href="mailto:joel.sherrill@oarcorp.com">joel.sherrill@oarcorp.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On 11/23/2010 02:50 AM, Jeferson Luiz Rodrigues Souza wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi everyone,<br>
<br>
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?<br>

<br>
The qemu command line is:<br>
<br>
sudo qemu -serial "/dev/ttyS0" -fda floppy.img -boot a<br>
<br>
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?<br>
<br>
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.<br>
<br>
</blockquote></div>
The /dev/ttyS0 above is the host serial port.  The -serial says<br>
attach attach the serial port COM1 on the target simulator<br>
PC to the specified device.  So you are attaching the virtual<br>
COM1 to the real serial port on the host /dev/ttyS0. Is that<br>
what you intend to do?<br>
<br>
FWIW COM1 --> /dev/ttyS1<br>
COM2 --> /dev/ttyS2<br>
<br>
on the RTEMS target.<br>
<br></blockquote><div><br>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?<br>
<br>Where is the name of serial devices in RTEMS defined? I tried use the open() function as follows:<br><br> int serial_fp = open("/dev/ttyS0",O_RDONLY);<br>or <br> int serial_fp = open("/dev/ttyS1",O_RDONLY);<br>
or<br> int serial_fp = open("COM1",O_RDONLY);<br><br>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"<br><br>
Thanks to reply,<br><br>Best regards,<br>Jeferson.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
--joel<div><div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Thanks,<br>
jefecomp.<br>
<br>
<br>
#include <signal.h><br>
#include <stdlib.h><br>
#include <stdio.h><br>
#include <pthread.h><br>
#include <uart.h><br>
#include <termios.h><br>
#include<sched.h><br>
#include <bsp.h><br>
#include <fcntl.h><br>
#include <sys/types.h><br>
#include <sys/stat.h><br>
<br>
#define CONFIGURE_INIT<br>
#include <rtems.h><br>
<br>
<br>
void *POSIX_Init();<br>
<br>
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER<br>
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER<br>
#define CONFIGURE_APPLICATIONS_NEEDS_RTC_DRIVER<br>
#define CONFIGURE_MICROSECONDS_PER_TICK 1000<br>
<br>
#define CONFIGURE_MAXIMUM_POSIX_THREADS 10<br>
#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 10<br>
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 10<br>
#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 10<br>
#define CONFIGURE_MAXIMUM_POSIX_TIMERS 10<br>
#define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 40<br>
#define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 10<br>
#define CONFIGURE_POSIX_INIT_THREAD_TABLE<br>
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5<br>
#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 3<br>
#include<rtems/confdefs.h><br>
<br>
void *POSIX_Init()<br>
{<br>
    printf("Serial Port Test!!!\n");<br>
<br>
    char buffer[255];<br>
    int bytesRead;<br>
    int serial_fp = open("/dev/ttyS0",O_RDONLY);<br>
<br>
    printf("SERIAL_FP = %i\n",serial_fp);<br>
<br>
    if(serial_fp < 0)<br>
    {<br>
        printf("FAILURE TO OPEN SERIAL PORT\n");<br>
        perror(serial_fp);<br>
        exit(-1);<br>
    }<br>
<br>
    //write(serial_fp,buffer,strlen(buffer)+1);<br>
    bytesRead = read(serial_fp, buffer, 255);<br>
<br>
<br>
    if(bytesRead < 0)<br>
    {<br>
        printf("Problems in the read of Serial Port");<br>
        close(serial_fp);<br>
        exit(1);<br>
    }<br>
    else<br>
        buffer[bytesRead] = 0;<br>
<br>
<br>
    printf(buffer);<br>
<br>
    close(serial_fp);<br>
    exit(0);<br>
}<br>
</blockquote>
<br>
<br></div></div><font color="#888888">
-- <br>
Joel Sherrill, Ph.D.             Director of Research&  Development<br>
joel.sherrill@OARcorp.com        On-Line Applications Research<br>
Ask me about RTEMS: a free RTOS  Huntsville AL 35805<br>
   Support Available             (256) 722-9985<br>
<br>
<br>
</font></blockquote></div><br>