c0de4x4 wrote on Thursday, December 19, 2013:
Hello everybody.
I have a problem with transmitting data to tcp when using timers. I have an application which creates a tcp server for 4 clients (using LwIP - netconn). Each accepted connection is associated with a thread, suspended by a queue. Using LPCXpresso base board and LPC1769 Rev.B (with IAR 6.70)
I’m trying to transmit the same data to all the connected clients with a frequency of 1 message per second. I did this in two ways:
- using a timer
- using another thread (with delay)
When I use the timer, after few minutes, the ethernet connection blocks in busy state. There were no problems when using another thread.
for (1): The timer callback function looks like this:
static void vTimerCallback( xTimerHandle pxTimer )
{
struct rf_queue *s1Queue, *s2Queue;
s1Queue = &id1Message;
s2Queue = &id2Message;
if(current_id_index == 0)
{
// send first ID
xQueueSend ( xQueueIDHandler, (void *)&s1Queue, ( portTickType ) 0);
current_id_index = 1;
}
else
{
// send second ID
xQueueSend ( xQueueIDHandler, (void *)&s2Queue, ( portTickType ) 0);
current_id_index = 0;
}
}
for (2) the thread is:
static portTASK_FUNCTION(vTaskTimer, pvParameters)
{
int i;
struct rf_queue *s1Queue, *s2Queue;
s1Queue = &id1Message;
s2Queue = &id2Message;
while(1)
{
vTaskDelay(configTICK_RATE_HZ);
if(current_id_index == 0)
{
// send first ID
xQueueSend ( xQueueIDHandler, (void *)&s1Queue, ( portTickType ) 0);
current_id_index = 1;
}
else
{
// send second ID
xQueueSend ( xQueueIDHandler, (void *)&s2Queue, ( portTickType ) 0);
current_id_index = 0;
}
}
}
In the FreeRTOSconfig, the timers are configured as follows:
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY 1
#define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH 96
Timer is created in main() with:
xTimerTest = xTimerCreate( "Test Timer", 1000 , pdTRUE, ( void * ) 1 , vTimerCallback);
configASSERT( xTimerTest );
xTimerStart( xTimerTest, 0 );
Am I missing something in the timers configuration or is it something related to queue send from timer callback?
Thank you
Cosmin