Hi All
Iam using devc-8250ser drivers for the UART ST16C654CJ68
i have the following code to read from the UART
int ReadUart(char *uartPath, unsigned char *buf, int size, int option)
{
int fd, len = 0;
/* Open a file for input & output */
// fd = open( uartPath, O_RDWR );
fd = open(uartPath, O_RDWR, S_IRWXU );
if (fd == -1) {
printf("ERROR: uutifReadUart, Device %s can't be Opened.\r\n", uartPath);
return (-1);
}
if(option)
{
len = read(fd, buf, size);
} else {
/* Flush the UART */
len = UUTIF_UART_DATA_SIZE;
while(len) {
len = read(fd, buf, UUTIF_UART_DATA_SIZE);
delay(10);
}
}
/* Close the file */
close( fd );
return len;
}
my boss is telling me that this is no good , and reading should be only when there is data avaiable , I dont know what he means , I am assuming that I have to wait for an intrrupt or a reg value to Read Am I right?
and if somebody have idea how can I make this function read only when there is data , that would help a lot
Thanks All