PIP 5.6.1
Platform-Independent Primitives
Complex I/O (PIConnection)

PIConnection is an abstract layer over physical I/O devices: it manages a device pool, filters (packet extraction), senders (timed output), and diagnostics. Several connections can share one physical device through the pool; each device has an associated read thread that you start/stop with startThreadedRead() and stopThreadedRead().

Device pool

The device pool is a single per-application container of unique devices. Each PIConnection talks to real hardware through this pool, so one serial port or socket can feed multiple logical connections.

Filters

A filter is a PIPacketExtractor plus a set of bound devices or other filters. When the read thread gets data from a device, that data can be passed to one or more filters. Filters have unique names; use filter(name) to get the PIPacketExtractor*, and filterBoundedDevices() for the list of bound devices/filters. One filter can receive from several sources and be bound to several others.

Senders

Senders are named timers that periodically send data to bound devices. Create a sender or add a device to a sender with addSender(). Each sender runs a timer and calls the virtual senderData(); the returned value is sent to bound devices. Alternatively use setSenderFixedData() to send fixed data without calling senderData().

Diagnostics

PIConnection creates a PIDiagnostics for each device or filter. Access them with diagnostic().

Configuration

You can build a PIConnection from a config file section or configure it later with configureFromConfig() (see Configuration from file). Devices are described by full paths (see PIIODevice documentation). makeConfig() produces a string you can insert into a config file.