Telegram transmission stops after a while

This article applies to:
DolphinAPI 2.0.0.0, 2.1.0.0

QUESTION

I am having an application that receives and transmits radio telegrams. When I start the application it works ok, but after a while it stops transmitting telegrams. My source code is the following:

wrong_radio2serial.c

	while (1)
	{
		CLR_WDT();
 
                // Handle radio to uart traffic
		if (radio_getTelegram(&rTelIn, &pTelIn) == OK)
		{
			io_togDigital(ADIO_5);
			misc_radioToSerial(&rTelIn,&sTelOut);
			while (uart_sendTelegram(&sTelOut) != OK);
		}
 
                // Handle uart to radio traffic        
		if (uart_getTelegram(&sTelIn) == OK)
		{
		    misc_serialToRadio(&sTelIn,&rTelOut);
			while (radio_sendTelegram(&rTelOut,&pTelOut) !=OK);
		}
	}

ANSWER

All Rx and Tx radio buffers shares the same memory resources. Currently there is no radio buffer dedicated to transmitting telegrams. This can lead to a situation that incoming telegrams will fill all available buffers, thus no buffer is left for transmitting a telegram. To avoid this situation you have to keep fetching telegrams from the buffer even when transmitting.

Correct Example:

correct_radio2serial.c

void FetchTelegram()
{
  // Handle radio to uart traffic
  if (radio_getTelegram(&rTelIn, &pTelIn) == OK)
  {
    io_togDigital(ADIO_5);
    misc_radioToSerial(&rTelIn,&sTelOut);
    while (uart_sendTelegram(&sTelOut) != OK);
  }
 
}
 
	while (1)
	{
		CLR_WDT();
		FetchTelegram();
 
                // Handle uart to radio traffic        
		if (uart_getTelegram(&sTelIn) == OK)
		{
		    misc_serialToRadio(&sTelIn,&rTelOut);
			while (radio_sendTelegram(&rTelOut,&pTelOut) !=OK)
                        { FetchTelegram() };
		}
	}

RELATED TO:
4170

FAQ Single Template