Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

Stream I/O Management

Buffered stream device support. More...

Functions

int NutIfStreamRead (NUTDEVICE *dev, char *data, int size)
 Read from a stream device. More...

int NutIfStreamGetLine (NUTDEVICE *dev, char *data, int size)
 Get a line from a stream device. More...

int NutIfStreamWrite (NUTDEVICE *dev, const char *data, int len)
 Write to a stream device. More...

int NutIfStreamWrite_P (NUTDEVICE *dev, PGM_P data, int len)
 Write program space data to a stream device. More...

int NutIfStreamFlush (NUTDEVICE *dev)
 Flush stream device buffer. More...


Detailed Description

Buffered stream device support.

Stream devices use input and output buffers. If an application writes to a stream device, the output data is not directly passed to the device, but buffered first. The transmission starts in the backgorund, if the output buffer is full or if a special flush function is called.


Function Documentation

int NutIfStreamFlush ( NUTDEVICE * dev )
 

Flush stream device buffer.

Flushes the output buffer for the specified device by writing its current contents to the corresponding device.

Parameters:
dev   Identifies the device to flush. This pointer must have been retrieved by calling NutDeviceOpen().

Returns:
0 on success, -1 otherwise.

int NutIfStreamGetLine ( NUTDEVICE * dev,
char * data,
int size )
 

Get a line from a stream device.

Reads a string from the specified device. Characters are read up to and including the first newline character or until the number of characters read is equal to the specified maximum, whichever comes first.

Parameters:
dev   Identifies the device to read from. This pointer must have been retrieved by calling NutDeviceOpen().
data   Points to the buffer that receives the data.
size   Specifies the maximum number of bytes to read.

Returns:
The number of bytes read or -1 in case of an error.

int NutIfStreamRead ( NUTDEVICE * dev,
char * data,
int size )
 

Read from a stream device.

Parameters:
dev   Identifies the device to read from. This pointer must have been retrieved by calling NutDeviceOpen().
data   Pointer to the buffer that receives the data.
size   Size of the buffer.

Returns:
The number of bytes read or -1 in case of an error.

int NutIfStreamWrite ( NUTDEVICE * dev,
const char * data,
int len )
 

Write to a stream device.

The data isn't immediately transfered to the physical device, but buffered in a transmit buffer. Transmission starts either when the buffer is full or when this function is called with a zero data pointer.

Parameters:
dev   Identifies the device to write to. This pointer must have been retrieved by calling NutDeviceOpen().
data   Pointer to data to be written. If this pointer is NULL, the stream device starts transmitting the buffered data.
len   Number of bytes to write.

Returns:
The number of bytes written or -1 in case of an error.

int NutIfStreamWrite_P ( NUTDEVICE * dev,
PGM_P data,
int len )
 

Write program space data to a stream device.

Parameters:
dev   Identifies the device to write to. This pointer must have been retrieved by calling NutDeviceOpen().

Returns:
The number of bytes written or -1 in case of an error.


© 2000-2001 by egnite Software GmbH - visit http://www.ethernut.de/