AnsweredAssumed Answered

UART dropped chars as a polled device.

Question asked by Mark Grillo on Mar 24, 2010
Latest reply on Mar 26, 2010 by Mark Grillo
I have an issue using UART0 as polled device. I'm only receiving the first three characters and the last. For example: Terminal sends "12345678", serial_fd receives "1238". I've tried filling a char buffer using 'fgetc', 'fgetline', 'read' and tried several different baud rates with the same result. Below is the function I'm using to read the UART. (MQX 3.3.4 on a m52259demo, modified telnet_to_serial project as base). Queue size is the default 64.
 
int_16 iDrive_getline(uint_16 uiMaxWait, uint_8 ucPtr)
{
 int_16 iRtn=0;
 uint_16 uiTimeOut=0;
 
 while (TRUE)
 { 
   if (fstatus( serial_fd )) //activity on the serial port
   {
     iRtn = fgetc( serial_fd ); //get char on serial port
     if (iRtn==IO_ERROR)
     {
      break;
     }
     ucCharAry[ucPtr++] = iRtn; //fill buffer
     if (iRtn == 0x0A) //"\n"
     {
      iRtn = ((int_16)ucPtr + 1); //Data is good, return char count
      break;
     }
   }
   RTCS_time_delay(1); //1 mSec.
   uiTimeOut++;
   if (uiTimeOut >= uiMaxWait)
   {
     iRtn = SERIAL_TIMEOUT;
     break;
   }
   if (ucPtr >= 64)
   {
     iRtn = SERIAL_BUFOVRN;
     break;
   }
 } //Do 
 return (iRtn);
}
If I enter chars slowly during the loop above I'm fine. If the char stream is received before the loop above is started chars are dropped. Why? Isn't the buffer 64 bytes?
Thanks,
Mark Grillo

Outcomes