Not receiving all RS232 data transmitted


#1

I have connected up my socket and can send and receive RS232 data over. My problem is that if my RS232 string is 26 characters I dont always receive 26 characters. Sometimes I do but most of the time I only receive 16 characters. What can cause this?

To send data I do the following
If CanSend == false
return FALSE
If DataLen == 0
return FALSE

ed_SendDataExt(Data, DataLen, FALSE, ED_ID_TCPSOCKET_1)

When I receive the data I do the following
if dataLen == 0
return

OutputString = adl_memGet(dataLen+1)
wm_strcpy(OutputString, data, dataLen)
adl_fcmSendData(UartHandle, OutputString, dataLen)
adl_memRelease(OutputString)

any suggestions???

Apologies for posting this in two places but I was unsure as to which was the correct forum. I dont know if it is a GPRS or UART problem


#2

Effectively I had the same problem, there are a buffer of 16 characters used by the RS232 chip. And before you can receive the next data you must read this buffer.
Here my function to resolve this problem by reading all data and using a timer to define the end of waiting for data :

adl_tmr_t *ttTimeoutRcvData;
u8 u8RcvDataLen;
u8 pu8RcvData[50];
bool boolRcvData;

bool RS232_DataHandler(u16 DataLen, u8 * Data)
{
  if (boolRcvData == FALSE)
  {
    u8RcvDataLen = 0;
    boolRcvMess = TRUE;
    if (ttTimeoutRcvData != 0)
   {
       //Delete old Timer
      adl_tmrUnSubscribe(ttTimeoutRcvData,(adl_tmrHandler_t) RS232_TimeoutRcvData, ADL_TMR_TYPE_100MS);
    }
   // TimeOut after 100 milli-second 
   ttTimeoutRcvData=(adl_tmr_t *)adl_tmrSubscribe(FALSE,  timeout_100ms,          ADL_TMR_TYPE_100MS, (adl_tmrHandler_t) RS232_ TimeoutRcvData);	
  }

memcpy(&pu8RcvData[u8RcvDataLen],Data,DataLen);
u8RcvDataLen += (u8) DataLen;

return TRUE;
}

void RS232_Init(void)
{
	ttTimeoutRcvData = 0;
	boolRcvData = FALSE;
}

void RS232_ TimeoutRcvData (void)
{
	ttTimeoutRcvData = 0;
	if (boolRcvData == TRUE) // Message has been received
	{
		boolRcvData = FALSE;
	}
}