Hi thx for your response.
I tried to handle the clients like the example of tony on the nucleo-h723g:
- Im creating 1 task for the server:
static void vUDPReceivingUsingZeroCopyInterface( void *pvParameters )
{
int32_t lBytes;
uint8_t *pucUDPPayloadBuffer;
struct freertos_sockaddr xClient, xBindAddress;
uint32_t xClientLength = sizeof( xClient ), ulIPAddress;
Socket_t xListeningSocket;
/* Attempt to open the socket. */
xListeningSocket = FreeRTOS_socket( FREERTOS_AF_INET,
/\* FREERTOS_AF_INET6 to be used for IPv6 \*/
FREERTOS_SOCK_DGRAM,
/\*FREERTOS_SOCK_DGRAM for UDP.\*/
FREERTOS_IPPROTO_UDP );
/* Check the socket was created. */
configASSERT( xListeningSocket != FREERTOS_INVALID_SOCKET );
/* Bind to port 10000. */
memset( &xBindAddress, 0, sizeof(xBindAddress) );
xBindAddress.sin_port = FreeRTOS_htons( 10000 );
xBindAddress.sin_family = FREERTOS_AF_INET4; /* FREERTOS_AF_INET6 to be used for IPv6 */
FreeRTOS_bind( xListeningSocket, &xBindAddress, sizeof( xBindAddress ) );
for( ;; )
{
/\* Receive data from the socket. ulFlags has the zero copy bit set
(FREERTOS_ZERO_COPY) indicating to the stack that a reference to the
received data should be passed out to this RTOS task using the second
parameter to the FreeRTOS_recvfrom() call. When this is done the
IP stack is no longer responsible for releasing the buffer, and
the RTOS task \*\*must\*\* return the buffer to the stack when it is no longer
needed. By default the block time is portMAX_DELAY but it can be
changed using FreeRTOS_setsockopt(). \*/
lBytes = FreeRTOS_recvfrom( xListeningSocket,
&pucUDPPayloadBuffer,
0,
FREERTOS_ZERO_COPY,
&xClient,
&xClientLength );
if( lBytes > 0 )
{
/\* Data was received and can be processed here. \*/
}
if( lBytes >= 0 )
{
/\* The receive was successful so this RTOS task is now responsible for
the buffer. The buffer \*\*must\*\* be freed once it is no longer
needed. \*/
/\*
\* The data can be processed here.
\*/
/\* Return the buffer to the TCP/IP stack. \*/
FreeRTOS_ReleaseUDPPayloadBuffer( pucUDPPayloadBuffer );
}
}
}
And i also tried the one without the zero-copy.
I tried to run on debug and im seeing that the pvPortMalloc() function is failing when trying to get a network buffer and as a Result the following function get called:
void vApplicationMallocFailedHook( void )
{
/\* If configUSE_MALLOC_FAILED_HOOK is set to 1 then this function will
\* be called automatically if a call to pvPortMalloc() fails. pvPortMalloc()
\* is called automatically when a task, queue or semaphore is created. \*/
for( ;; );
}
/*-----------------------------------------------------------*/
The thing is im not running out of space of network buffers, im using the logging of vPrintResourceStats and im see that the heap is not full and there are still network buffers that can be allocated.
Any ideas what can cause it?
If your checking the demo it would be great if there will be a demo with newer releases with new Networkinterface.c because In @tony-josi-aws demo its using version 2.3.2.
Thanks alot for your help guys.