I/O handling
If an application requires fast and synchronized I/O data it can work directly against the
I/O system and call the I/O routines to read and write I/O on its own.
Initialization is done with the function io_init(), to which a process argument is supplied.
Process identifies which I/O units (agent, rack or card) are handled by a specific process.
Each I/O object has a Process attribute and if this corresponds to the process sent as
argument to io_init(), the unit will be handled by the application. If a card is handled
by an application, also the rack and agent of the card have to be handled by the application.
As the Process attribute is a bitmask, a unit can be handled by several processes by
setting several bits in the mask. If you, for example, have several cards in a rack, and some
of the cards should be handled by the plc-process and some by an application, the rack unit
has to be handled by both the plc and the application. Whether it works, to handle a
unit from several processes, depends on how the I/O methods for the unit are written.
For example for Profibus, you can't divide the handling of slaves into different
processes.
#include rt_io_base.h
io_tCtx io_ctx;
sts = io_init( io_mProcess_User, pwr_cNOid, &io_ctx, 0, scantime);
if ( EVEN(sts)) {
errh_Error( "Io init error: %m", sts);
throw co_error(sts);
}
Reading is executed with io_read() which reads data from the I/O units and places
the data in the signals connected to the unit. The application preferably links directly
to these signals, and also to the signals of the output units. The output units are written
to with the function io_write().
sts = io_read( io_ctx);
sts = io_write( io_ctx);