RTCS: select() is removed in MQX 4.0.2. Howto migrate an application using select() ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RTCS: select() is removed in MQX 4.0.2. Howto migrate an application using select() ?

1,475 Views
Fabi
Contributor III

In MQX 4.0.2 the file rtcs/source/if/select.c can't be compiled (due to modification of SOCKSELECT_PARM).

What is the best way to migrate an existing application using 'select', 'FD_ZERO', 'FD_SET' etc ?

Labels (1)
Tags (2)
0 Kudos
Reply
3 Replies

647 Views
Martin_
NXP Employee
NXP Employee

Just an update that this has happened: The new select() , BSD-like, is in the Freescale KSDK MQX 1.0.0, and will be in Freescale MQX 4.2.0. We have "RTCS_" prefix:

FD_SET --> RTCS_FD_SET

FD_CLR --> RTCS_FD_CLR

fs_set --> rtcs_fd_set

etc.

You will find these prototypes in the RTCS header file: rtcs_sock.h

For the select() function prototype we currently have:

int32_t select(int32_t nfds,

rtcs_fd_set *restrict readfds,

rtcs_fd_set *restrict writefds,

uint32_t timeout_ms);

so we do not support errorfds and our timeout is in milliseconds.

The default value for rtcs_fd_set_size: RTCSCFG_FD_SETSIZE in: rtcscfg.h. By default it is 8, if an application will create more sockets this value should be increased accordingly.

 

We still support backward compatibility with RTCS_selectset() and RTCS_selectall() when RTCSCFG_BACKWARD_COMPATIBILITY_RTCSSELECT build time option is TRUE (this is the default value).

All of our example applications have been completely migrated to use the new select(), so it is possible to compile RTCS library with RTCSCFG_BACKWARD_COMPATIBILITY_RTCSSELECT set to FALSE.

For complete reference, I attach the RTCS BSD-like select() documentation:

/*FUNCTION*-------------------------------------------------------------

*

* Function Name   : select

* Parameters      :

*

*     int32_t      nfds       [IN] The first nfds socket handles

*                                  are checked in each set; i.e.,

*                                  the sockets from 0 through nfds-1

*                                  in the descriptor sets are examined.

*     rtcs_fd_set *     readfds   [IN/OUT]

*       IN - array of pointers to SOCKET_STRUCT to examine for receive activity

*       OUT - readfds contains the socket handles where activity

*           has been detected

*     rtcs_fd_set *     writefds  [IN/OUT]

*       IN - array of pointers to SOCKET_STRUCT to examine for transmit activity

*       OUT - writefds contains the socket handles where activity

*           has been detected

*     uint32_t     timeout_ms [IN]

*       if timeout_ms is zero, select() may block indefinitely.

*       if timeout_ms is 0xFFFFFFFF, select() only polls the socket descriptors

*         and returns when the actual status is determined.

*       other values determine time limit in milliseconds that the select

*         would block at max

*      

* Comments  :  Due to the restrict keyword the fd_sets must not overlap;

*  readfds, writefds shall not point to the same fd_set structure

*  in memory.

*  The select() function returns the number of ready sockets that are

*  contained in the descriptor sets, or RTCS_ERROR if an error occurred

*  (RTCS_errno is set appropriately).If the time limit expires, select() returns 0. 

*  Any of readfds, writefds may be given as null pointers if

*  no descriptors are of interest.

*  select() function modifies the content of readfds/writefds.

*

*  SPECIAL NOTES:

*  datagram socket in writefds is reported as always writeable.

*

*END*-----------------------------------------------------------------*/

0 Kudos
Reply

647 Views
Martin_
NXP Employee
NXP Employee

You can implement your own FD_* functions as a management of an array of uint32_t values (socket handles). Also you will need to write your own select() using the RTCS_selectset() function.

We will provide BSD-like select() interface with an MQX release later this year.

647 Views
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi F,

Please include some project where you are using it to make suggestions.

Regards,

Garabo

0 Kudos
Reply