The byte stream is an abstraction of classes representing byte stream in/output devices like serial lines and TCP or UDP sockets.
FTS byte streams are FTS objects.
Various i/o objects can refer to an FTS byte stream in order to receive bytes (listeners) or send bytes to an internal or external device or file. Mulitple MIDI port listeners can be registered for a single stream.
If an i/o object refers to byte stream objects by a named variable, the same program (patch) can be configured for completely different setups simply by redefining the byte stream object defining the variable.
Different implementations of FTS byte streams are developed for different platforms and byte stream protocols. In many cases i/o objects implement a protocol (encoding and decoding) in order to send more complex data structures via a serial byte stream.
The API documented by this module permits to implement FTS byte stream classes. It contains the byte stream structure itself and the initialization functions for the FTS class implementing an FTS byte stream: fts_bytestream_class_init(), fts_bytestream_init().
A byte stream class allowing input, calls fts_bytestream_set_input() in the objects initialization and uses the provided input function fts_bytestream_input() in the routines handling incoming data. These functions propagate the incoming data to the listening i/o objects refering to the byte stream.
For the output a byte stream class must implement two output functions for sending single characters and entire strings to the bytestream as well as an optional function to flush eventual output buffers. The functions are declared by fts_bytestream_set_output() in the objects initialization.
|
Flush byte streams output buffer. This function is optional and has not be declared only for byte streams using an output buffer |
|
The FTS byte stream structure. The FTS byte stream "inherits" from FTS object. The structure fts_bytestream_t itself must be included by a class implementing a byte stream:
typedef struct my_bytestream { fts_bytestream_t stream; ... } my_bytestream_t;
A byte stream class must call |
|
Initialize a class implementing an FTS byte stream.
|
|
Initialize a byte stream structure.
|
|
Call all listeners of the byte stream. For incoming data a function is called by the object implementing an byte stream, which calls all listeners.
|
|
Declare initialized byte stream as input.
|
|
Declare an initialized byte stream as output and assign it's output functions.
|