alweib wrote on Thursday, April 26, 2018:
Hey everyone,
I’m having an issue sharing a TCP socket between two tasks in FreeRTOS (v. 7.0) and LWIP(v. 1.40).
I’m using the socket for a cmd / reply interface and also to send information back asynchronously. These 2 ways of writing to the socket are of course in two different tasks. I’m usign a semaphore to control access to the socket:
bool wdpshell_write(void* data,int l){
if(pxNewWdpConnection != NULL)
{
xSemaphoreTake( xSemaphoreWdpBlock, portMAX_DELAY);
bool err = (ERR_OK == netconn_write(pxNewWdpConnection, data, l, NETCONN_COPY ));
xSemaphoreGive( xSemaphoreWdpBlock );
return err;
}
return false;
}
It works fine when only the cmd / reply or the async sends info back, without the other running, but when both run i lose the connection. Setting in a delay (vTaskDelay( webSHORT_DELAY ) after the semaphore take cmd, it seems to work. Can anyone explain this behaviour? It would be very detrimental for performance if there should be a delay for all traffic in that direction.
Thanks in advance.
Aleksander