[ECOS] Problem reading data from serial Port

Ricardo Andrino ricardo_andrino@web.de
Fri Mar 26 09:32:00 GMT 2004

Hello again,
i am a little confused with this. My eCos application(running on th AT91EB40A) only try to read characters one by one from a host , and for this i have made a loop as follow( i have used POSIX functions):

The program that sends the data works fine and send always the following data sequence:
0x44 0x47 0x02 0xaa 0x03 0xa8
but my program read different sequences:
0x44 0x47 0xa8 0x44 0x02 0xaa 0xa8 or even others.

I have configured the serial port (4800, 8E1) see bellow:

if (fd <0) 
fcntl(fd, F_SETFL, 0); 

tcgetattr(fd, &oldtio); /* save current port  settings */

Set bps rate and 8n1 (8bit,parity even,1 stop-bit).
Also don't hangup automatically and ignore modem status.
Finally enable receiving characters*/

newtio.c_cflag |= (CLOCAL | CREAD); 
newtio.c_cflag |= PARENB;
newtio.c_cflag &= ~CSTOPB;
newtio.c_cflag &= ~CSIZE;
newtio.c_cflag &= ~PARODD;
newtio.c_cflag |= CS8;

Ignore bytes with parity errors and make terminal raw and dumb.
This option can be changed*/
newtio.c_iflag = IGNPAR;

/*Don´t echo characters.Don't generate signals.No canonical
input else raw input*/

newtio.c_lflag = 0;
newtio.c_lflag &= ~(ICANON | ISIG);
newtio.c_lflag &= ~ECHO;

/* blocking read until 1 byte arrives. Warning, the option VMIN !=0 couldn't 
work good in eCos */


/*4800 bauds in and out*/

cfsetispeed(&newtio, BAUDRATE);
cfsetospeed(&newtio, BAUDRATE);

/* now clean the modem line and activate the settings for port */

tcflush(fd, TCIFLUSH);
tcsetattr(fd,TCSANOW, &newtio); 

What could be the problem, timing problems, port configurations problems?

I would appreciate any kind of help.
... and the winner is... WEB.DE FreeMail! - Deutschlands beste E-Mail
ist zum 39. Mal Testsieger (PC Praxis 03/04) http://f.web.de/?mc=021191

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list