flc_attach, flc_detach, flc_open, flc_read, flc_write -
FLIGHTLAB communications library
#include "flcomms.h" flc_attach(id,flags); FLC_HANDLE handle = flc_open(name, size, magic, flags); flc_read(handle, dst, size); flc_write(handle, src, size); flc_detach();
| Type | Name | Mode |
|---|---|---|
| const char * | name | |
| The name of the data block | ||
| size_t | size | |
| The size of the data block in bytes | ||
| int | magic | |
| A magic number, used for consistency checking. If this is set to 0, then no consistency checking is done. Otherwise, all processes which attach to this block must use the same number. | ||
| unsigned long | flags | |
| See below | ||
| FLC_HANDLE | handle | |
| A communications block handle returned from flc_open | ||
| void * | dst | |
| Buffer to store data read from data block | ||
| const void * | src | |
| Data to store in data block | ||
flc_attach(NULL, 0) Attaches to the main communications block. The id and flags parameters are for potential future enhancements; for now they should be NULL and 0, respectively. Returns 1 if OK, 0 on error.
flc_detach() Releases all data blocks and detaches from the master communications block.
flc_open Returns a handle to a data block. name should be the name of a Scope variable list without the leading `@' sign), or any other user-defined name. size should be the size in bytes of the data area. magic may be used for additional consistency checks: setting magic=0 disables the consistency checks.
flags should be a bitwise-OR combination of the following:
The type flag is a hint to the FLCOMMS network monitor. Homogeneous data blocks will be serialized in a common format before transmission across the network, to enable communication between hosts with different byte orders and floating point formats. FLC_TYPE_MIXED data blocks will be transmitted without any serialization, so they may only be shared amongst hosts with the same architecture.
Note that Scope always uses FLC_TYPE_DOUBLE for variable lists.
flc_read and flc_write copy data from and to the shared memory block indicated by handle.
flc_attach() returns 0 on error, 1 if OK.
flc_read() returns a pointer to an internal buffer holding a copy of the contents of the data block if successful, NULL otherwise.
flc_write() returns 1 on success, -1 on error.
In the case of an error, errno may be set to one of the following:
Note that the actual limits are in practice less than these upper bounds, due to memory allocation policies.
The error-reporting mechanism(s) leave much to be desired.
flcomms(1), netflc(3), ATTACH, APCTL, $FL_DIR/examples/flcomms