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

Streaming I/O
[I/O Management]

Buffered stream device support. More...

Functions

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

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

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

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

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


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.

Deprecated:
Use fflush() in new programs.
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 directly or indirectly calling NutDeviceOpen().
Returns:
0 on success, -1 on failures.

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 end of line character or until the number of characters read is equal to the specified maximum or until a timeout occurs, whichever comes first.

Deprecated:
Use fgets() in new programs.
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 zero terminated string. End of line characters are not stored.
size Specifies the size of the buffer. The maximum number of characters read is one less because of the terminating null character.
Returns:
The number of bytes read or -1 in case of an error. Receiving no character is being considered an error.

int NutIfStreamRead NUTDEVICE   dev,
char *    data,
int    size
 

Read from a stream device.

Deprecated:
Use _read() or fread() in new programs.
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. Set to null to flush the input buffer.
size Size of the buffer. Ignored if the data pointer is null.
Returns:
The number of bytes read, 0 on timeouts and broken connections 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.

Deprecated:
Use _write() or fwrite() in new programs.
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.

Deprecated:
Use _write_P() or fwrite_P() in new programs.
Parameters:
dev Identifies the device to write to. This pointer must have been retrieved by calling NutDeviceOpen().
data Pointer to data in program space to be written.
len Number of bytes to write.
Returns:
The number of bytes written or -1 in case of an error.


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