ChibiOS/RT
2.5.1
Abstract Sequential Streams
Collaboration diagram for Abstract Sequential Streams:

Detailed Description

This module define an abstract interface for generic data streams. Note that no code is present, just abstract interfaces-like structures, you should look at the system as to a set of abstract C++ classes (even if written in C). This system has then advantage to make the access to data streams independent from the implementation logic.
The stream interface can be used as base class for high level object types such as files, sockets, serial ports, pipes etc.

Data Structures

struct  BaseSequentialStreamVMT
 BaseSequentialStream virtual methods table. More...
struct  BaseSequentialStream
 Base stream class. More...

Macro Functions (BaseSequentialStream)

#define chSequentialStreamWrite(ip, bp, n)   ((ip)->vmt->write(ip, bp, n))
 Sequential Stream write.
#define chSequentialStreamRead(ip, bp, n)   ((ip)->vmt->read(ip, bp, n))
 Sequential Stream read.
#define chSequentialStreamPut(ip, b)   ((ip)->vmt->put(ip, b))
 Sequential Stream blocking byte write.
#define chSequentialStreamGet(ip)   ((ip)->vmt->get(ip))
 Sequential Stream blocking byte read.

Defines

#define _base_sequential_stream_methods
 BaseSequentialStream specific methods.
#define _base_sequential_stream_data
 BaseSequentialStream specific data.

Define Documentation

#define _base_sequential_stream_methods
Value:
/* Stream write buffer method.*/                                          \
  size_t (*write)(void *instance, const uint8_t *bp, size_t n);             \
  /* Stream read buffer method.*/                                           \
  size_t (*read)(void *instance, uint8_t *bp, size_t n);                    \
  /* Channel put method, blocking.*/                                        \
  msg_t (*put)(void *instance, uint8_t b);                                  \
  /* Channel get method, blocking.*/                                        \
  msg_t (*get)(void *instance);                                             \

BaseSequentialStream specific methods.

Definition at line 45 of file chstreams.h.

#define _base_sequential_stream_data

BaseSequentialStream specific data.

Note:
It is empty because BaseSequentialStream is only an interface without implementation.

Definition at line 60 of file chstreams.h.

#define chSequentialStreamWrite (   ip,
  bp,
 
)    ((ip)->vmt->write(ip, bp, n))

Sequential Stream write.

The function writes data from a buffer to a stream.

Parameters:
[in]ippointer to a BaseSequentialStream or derived class
[in]bppointer to the data buffer
[in]nthe maximum amount of data to be transferred
Returns:
The number of bytes transferred. The return value can be less than the specified number of bytes if an end-of-file condition has been met.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 97 of file chstreams.h.

#define chSequentialStreamRead (   ip,
  bp,
 
)    ((ip)->vmt->read(ip, bp, n))

Sequential Stream read.

The function reads data from a stream into a buffer.

Parameters:
[in]ippointer to a BaseSequentialStream or derived class
[out]bppointer to the data buffer
[in]nthe maximum amount of data to be transferred
Returns:
The number of bytes transferred. The return value can be less than the specified number of bytes if an end-of-file condition has been met.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 112 of file chstreams.h.

#define chSequentialStreamPut (   ip,
 
)    ((ip)->vmt->put(ip, b))

Sequential Stream blocking byte write.

This function writes a byte value to a channel. If the channel is not ready to accept data then the calling thread is suspended.

Parameters:
[in]ippointer to a BaseChannel or derived class
[in]bthe byte value to be written to the channel
Returns:
The operation status.
Return values:
Q_OKif the operation succeeded.
Q_RESETif an end-of-file condition has been met.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 128 of file chstreams.h.

#define chSequentialStreamGet (   ip)    ((ip)->vmt->get(ip))

Sequential Stream blocking byte read.

This function reads a byte value from a channel. If the data is not available then the calling thread is suspended.

Parameters:
[in]ippointer to a BaseChannel or derived class
Returns:
A byte value from the queue.
Return values:
Q_RESETif an end-of-file condition has been met.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 142 of file chstreams.h.