I’m using FreeRTOS-Plus-TCP and found a situation where I wanted to wait on an empty socket set (which the system supports) but then I wanted to signal the socket set to wake up the thread to check for new connections and there currently isn’t a way to do this.
So I added the following function locally:
#if ( ipconfigSUPPORT_SIGNALS != 0 ) && ( ipconfigSUPPORT_SELECT_FUNCTION == 1 )
/**
* @brief Send a signal to the task which waits on this socket set.
* The socket set will receive an event of the type 'eSOCKET_INTR'.
*
* @param[in] pxSocketSet: The socket set that will be signalled.
*/
BaseType_t FreeRTOS_SignalSocketSet( SocketSet_t pxSocketSet )
{
BaseType_t xReturn;
if( pxSocketSet == NULL )
{
xReturn = -pdFREERTOS_ERRNO_EINVAL;
}
else if(pxSocketSet->xSelectGroup != NULL )
{
( void ) xEventGroupSetBits( pxSocketSet->xSelectGroup, ( EventBits_t ) eSELECT_INTR );
xReturn = 0;
}
return xReturn;
}
#endif /* ipconfigSUPPORT_SIGNALS && ipconfigSUPPORT_SELECT_FUNCTION */
This does exactly what I want, preventing my code from having to have a secondary wait system when no connections are active.
#if ( ipconfigSUPPORT_SIGNALS != 0 ) && ( ipconfigSUPPORT_SELECT_FUNCTION == 1 )
/**
* @brief Send a signal to the task which waits on this socket set.
* The socket set will receive an event of the type 'eSOCKET_INTR'.
*
* @param[in] pxSocketSet: The socket set that will be signalled.
*/
BaseType_t FreeRTOS_SignalSocketSet( SocketSet_t pxSocketSet )
{
BaseType_t xReturn = -pdFREERTOS_ERRNO_EINVAL;
if (( pxSocketSet != NULL ) && (pxSocketSet->xSelectGroup != NULL ))
{
( void ) xEventGroupSetBits( pxSocketSet->xSelectGroup, ( EventBits_t ) eSELECT_INTR );
xReturn = 0;
}
return xReturn;
}
#endif /* ipconfigSUPPORT_SIGNALS && ipconfigSUPPORT_SELECT_FUNCTION */
Hi Nigel,
As Kody already suggested, please share the change as a Pull Request. We would be happy to help you with the process and take in your contributions.