ATTACH(@outputs, "w")
ATTACH(@inputs, "r")
ATTACH([])
APCTL("sync");
// Load a model: exec("$FL_DIR/flme/models/articulated/arti-rgd-3iv-qs.def",1); // Set up variable lists for the data we want to share: pushg(world_model_airframe_cpg_xaout); varlist @STATES "Aircraft rigid body states" = .. posxi, posyi, poszi, .. phi, theta, psi; popg; pushg(world_model_control_cpg_in); varlist @PILOTIN "Pilot inputs" = .. xa, xb, xc, xp; popg // Publish the shared variables: attach(@STATES, "w"); attach(@PILOTIN, "r"); // Synchronize data: apctl("sync");
% flcomms -l Data blocks (serial=13) #: hflg flags name size addr #rw owner serial magic --------------------------------------------------------------- 124: 0104 r D PILOTIN 32 0x1100 1 0 s=000000 m=0xB1F7 125: 0204 w D STATES 48 0x1000 1 29392 s=000006 m=0x2D8C
r
= attached readable, w
= attached writable,flcomms -c
: Clean up after crashed writers, release write locksflcomms -t
: Show status of system IPC resources
(shared memory segment and semaphore array)flcomms -r
: Remove system IPC resourcesflcomms [-h]
: Show command usage informationipcs
: Standard Unix utility to display IPC resource informationipcrm
: Standard Unix utility to remove IPC resources
ipcs
and ipcrm
usage varies depending on system#include "flcomms.h"
in all C code-lflcomms
($FL_DIR/lib$FL_MACHTYPE/libflcomms.a
)flc_attach(NULL,0);
at program startupflc_open(...)
to acquire data block handlesflc_read(...)
and flc_write(...)
to transfer dataflc_close(...)
to release a handle (optional)flc_detach();
before exiting program (not optional)FLC_HANDLE h = flc_open("name", size, magic,
mode_flag | type_flag);
FLC_MODE_READ
: open data block for readingFLC_MODE_WRITE
: open for writingFLC_TYPE_DOUBLE
, FLC_TYPE_INT
, etc:
specify data typeFLC_TYPE_MIXED
: anything else|
)FLC_TYPE_DOUBLE
@
sign, all uppercaseflc_read(handle, dst, nbytes);
flc_write(handle, src, nbytes);
FLC_HANDLE
returned from flc_open(...)
flc_ready(read_handle)
: returns 1 if
data block has been written to since the last time the handle was read#include "flcomms.h" struct STATES { double posxi, posyi, poszi; /* position */ double phi, theta, psi; /* orientation */ } states; double pilotin[4]; ... flc_attach(NULL, 0); FLC_HANDLE states_handle = flc_open( "STATES", sizeof(struct STATES), 0, FLC_TYPE_DOUBLE|FLC_MODE_READ); FLC_HANDLE pilotin_handle = flc_open( "PILOTIN", 4*sizeof(double), 0, FLC_TYPE_DOUBLE|FLC_MODE_WRITE); ... flc_write(pilotin_handle, pilotin, 4*sizeof(double)); flc_read(states_handle, &states, sizeof(states));
flc_attach()
returns 1 if OK, 0 on errorflc_open()
returns NULL on errorflc_read()
may return 0 in case of concurrent write accesserrno
variable:
libflcomms(3)
, shmget(2)
and shmat(2)
manual pages for full listperror("...")
to report libflcomms-related errors"Invalid argument"
(EINVAL
)"Device or resource busy"
(EBUSY
)flcomms -c
to release write locksflc_read()
returns 0, errno=ETIME
("Timeout"
)ETIME
persists, writer has probably been killed or suspendedE2BIG
, ENOSPC
-- FLCOMMs size limitation exceeded
(data block too large, too many data blocks)double
s)netflc &
netflc -k
: broadcasts a ``shutdown'' message,
tells all netflc processes on the LAN to quitnetflc -i interval
:
specifies frame rate in millisec (default 20 millisec)netflc -v
: verbose outputnetflc -q
: quiet mode -- omit diagnostics other
than errorsnetflc -r
: ``receive mode'' -- don't broadcast updatesnetflc -s
: ``send mode'' -- ignore updates from other hostsflcomms -l
to determine magic number...FLC_HASH_INITIAL
and
FLC_HASH_MULTIPLIER
in flcomms.h
header file)0x0
as magic number to bypass checkflc_attach()
is not thread-safe --FLC_HANDLE
is not thread-safe --flc_open()
is thread-safeQuestions?