Hello,
i have a small problem with reading Data over UART.
I declared the Max Datasize to 512 but if i want to read Data which can be longer than 56 bytes i get the following TRACES (in attachment)
After 56 Bytes, data will be read in several steps.
I want to read in data with max SIze of 256 Bytes but not in sveral steps.
Can anybody help me?
Thanks
zafer
2
How did you set Max Datasize to 512? Can you show your related code?
And what is your baudrate?
Hello zafer,
my Baudrate is 115200 Baud
This is my Code for reading the data:
define UART_MAX_DATA_SIZE 512
static u8 buff_1 [UART_MAX_DATA_SIZE];
static const u8* buffer_pool[] =
{
buff_1,
};
void cbUART1Rx (void)
{
u32 NbTbRead = UA_ZERO;
u32 NbRead = UA_ZERO;
s32 Ret = OK;
u32 Idxbuff = UA_ZERO;
static bool BuffFull = FALSE;
TRACE ( ( UA_UART1_TRACEID, "[cbUART1Rx] Task Context [%d]",
adl_ctxGetID ( ) ) );
// create Uart1 Event
Uart1EventHandle = adl_eventCreate ( UART1_INIT_TX_RX_MASK );
TRACE ( ( UA_UART1_TRACEID, "cbUART1Rx [%x]", Uart1EventHandle ) );
//Received Data are just forwarded to UART2 ...
while ( UA_INFINITE_LOOP_COUNTER )
{
TRACE ( ( UA_UART1_TRACEID, "Wait for a Received Data......" ) );
// wait for Rx Available event
Ret = adl_eventWait ( Uart1EventHandle, UART1_RX_EVENT_WAIT_MASK,
NULL, ADL_EVENT_WAIT_ALL,
ADL_EVENT_NO_TIMEOUT );
TRACE ( ( UA_UART1_TRACEID, "Wait for a Received Data......[%d]",
Ret ) );
// clear Rx Available event
adl_eventClear ( Uart1EventHandle, UART1_RX_EVENT_WAIT_MASK, NULL );
ptrbuff = ( u8* )buffer_pool[ Idxbuff ]; //Wechselfunktion zwischen buff_1 und buff_2
// Idxbuff ^= 1; //EXOR Verknüpfung (Idxbuff 0=buff_1;Idxbuff 1=buff_2
wm_memset ( ptrbuff, UA_ZERO, UART_MAX_DATA_SIZE );
for ( NbTbRead = UART1_MAX_DATA_SIZE;
( NbRead = uart1_itf.read ( Uart1Handle, ptrbuff,NbTbRead ) ); )
{
TRACE ( ( UA_UART1_TRACEID, "Read Data Size : %d", NbRead ) );
//Point at first free byte position in the receive buffer
ptrbuff += NbRead;
// Compute maximum allowed amount of bytes to be read
NbTbRead -= NbRead;
TRACE ( ( UA_UART1_TRACEID, "Data is : %d", NbRead ) );
buflen=NbRead;
if ( !NbTbRead )
{
// No more available space
TRACE ( ( UA_UART1_TRACEID, "Read buffer is FULL" ) );
BuffFull = TRUE;
adl_eventSet ( Uart1EventHandle, UART1_RX_EVENT_WAIT_MASK );
break;
}
} // END of Data READ
snd_buffer=&buff_1;
if ( BuffFull == TRUE )
{
BuffFull = FALSE;
// clear RxComplete event
adl_eventClear ( Uart1EventHandle,
UART1_RX_EVENT_WAIT_MASK, NULL );
}
// End of while ( UA_INFINITE_LOOP_COUNTER )
}
}
awneil
4
That’s not the way FCM works - you must write your application to accept the data in whatever arbitrary size FCM may choose.
See: Q2686 UART receive buffer size is limit only 56? - #10 by awneil
And: FCM and WIP - #10 by awneil
Here’s an example of how to handle data arriving in arbitrary-sized blocks: Good paper on Event-Driven Programming - #6 by awneil