1. I enabled stty and entered the cmd
Still read returned only 1 byte when 3 bytes were in the queue.
2. I changed the fifo settings to:
No Tx fifo
Rx fifo with 8 words length
Interrupt after 4 bytes in fifo (value 1)
Timeout: 1 character length
With this settings the fifoed uart was stable and survived the stess test.
The stress test was sendig a 1k text file to the nios from a terminal over and over.
I did not look into the new altuart.c so far.
My application looks like this:
#include <termios.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/signal.h>
#include <sys/types.h>
#include "../wv_data.h"
#include "../prot2.h"
#define _POSIX_SOURCE 1 //POSIX compliant source
#define FALSE 0
#define TRUE 1
/**
* read is non blocking
*/
main(int argc, char *argv)
{
int fd,iSize,i;
struct termios oldtio, newtio; //place for old and new port settings for serial port
struct sigaction saio; //definition of signal action
unsigned char mesg=""; //buffer for where data is put
int iTimeout,iStatus;
long BAUD;
long DATABITS;
long STOPBITS;
long PARITYON;
long PARITY;
BAUD=B115200;
DATABITS=CS8;
STOPBITS=0;
PARITYON=0;
PARITY=0;
system("stty -F /dev/ttyS1 raw");
fd=open("/dev/ttyS1", O_RDWR|O_NOCTTY|O_NDELAY);
if(fd<0)
{
printf("%s,%s:Could not open /dev/ttyS1!",__FILE__,__FUNCTION__);
exit(-1);
}
fcntl(fd, F_SETFL, FNDELAY);
tcgetattr(fd, &oldtio); // save current port settings
// set new port settings for canonical input processing
newtio.c_cflag=BAUD|CRTSCTS|DATABITS|STOPBITS|PARITYON|PARITY|CLOCAL|CREAD;
newtio.c_iflag=IGNPAR;
newtio.c_oflag=0;
newtio.c_lflag=0; //ICANON;
newtio.c_cc=1;
newtio.c_cc=0;
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &newtio);
while(1)
{
iSize=read(fd,mesg,MAX_MESG_SIZE);
if(iSize>0)
{
printf("Rxs=%d\n",iSize); //!!!
for(i=0;i<iSize;i++)
{
printf("%02x ",mesg);
}
printf("\n");
}
if(iSize>0)
{
mesg=0x80;
mesg=0xFF;
mesg=0xAA;
iSize=3;
/*
printf("Txs=%d\n",iSize); //!!!
for(i=0;i<iSize;i++)
{
printf("%02x ",mesg);
}
printf("\n");
*/
iStatus=write(fd,mesg,iSize);
if(iStatus!=iSize)
{
printf("%s,%s: Send error,s=%d!\n",__FILE__,__FUNCTION__,iStatus);
break;
}
} //end if iSize>0
usleep(1); //give time to other processes
} //while 1
// restore old port settings
tcsetattr(fd, TCSANOW, &oldtio);
close(fd); //close the com port
} //end of main