Install a file-descriptor function
int PtAppAddFd( PtAppContext_t app, int fd, unsigned mode, PtFdProc_t fun, void *data); int PtAppAddFdPri( PtAppContext_t app, int fd, unsigned mode, PtFdProc_t fun, void *data, int priority):
These functions install an "FD function" that will inform the application about device events.
The app argument is the address of the application context, a structure that manages all the data associated with this application. For Photon 1.1x, this must be specified as NULL, so that the default context is used.
The mode argument defines what kind of conditions the application is interested in:
These values correspond to conditions defined for the ionotify() or select() functions. You can OR two or all three values together. You can change the mode later by calling PtAppSetFdMode()
Multiple FD functions attached to the same file descriptor aren't supported. PtAppAddFd() fails with errno set to EBUSY if you try to attach another function to the same FD.
The fun argument defines the function to be called. This function should match the following prototype:
typedef int PtFdProcF_t( int fd, void *data, unsigned mode ); typedef PtFdProcF_t *PtFdProc_t;
The fd and data arguments will have the same value as the fd and data arguments to PtAppAddFd(). The mode argument will indicate which conditions were actually met.
If the fun function returns a value other than Pt_CONTINUE, it will be removed automatically from the list of fd functions.
There are other flags that you can add to the mode argument to PtAppAddFd(). They can be used for optimizing the performance by avoiding unnecessary messages. Note that these flags aren't necessarily implemented for both QNX 4 and Neutrino; if a flag isn't implemented, it's defined as zero.
For PtAppAddFdPri(), the priority parameter specifies the priority of the Photon pulse that's created (see PtAppCreatePulse()).
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
PtAppCreatePulse(), PtAppRemoveFd(), PtAppSetFdMode()
"Other I/O mechanisms" in the Interprocess Communication and Lengthy Operations chapter of the Programmer's Guide