CO_STREAM_READ_NB


 co_error co_stream_read_nb(co_stream stream,                            void *buffer,                            size_t buffersize); 

Header File

co.h

Description

This function reads a data packet from a previously opened stream but does not block if the stream is empty. This function must be called from within a process run function.

Arguments

The arguments for co_stream_read_nb are as follows:

co_stream stream

A pointer to a stream as passed on the process argument list.

void *buffer

A pointer to the destination variable where read data will be stored. The destination address is typically a local variable or array element.

size_t buffersize

The size of the destination buffer, in bytes. This number must be at least as large as the stream's packet width (in bytes), as specified by co_stream_create.


Return Value

Possible return values are listed, with the resulting value of co_errno shown in parentheses:

co_err_none

Success (CO_ENOERROR).

co_err_eos

Encountered an end-of-stream token (CO_EEOS).

co_err_invalid_arg

The stream argument is NULL (CO_ENULL_PTR) or the buffersize argument is smaller than the stream's packet width in bytes (CO_EINVALID_STREAM_WIDTH).

co_err_not_open

The stream is not open for reading (CO_ENOT_OPEN).


Notes

The co_stream_read_nb function must be used only on streams that have been opened with mode O_RDONLY.

The co_stream_read_nb function does not block if the stream is empty. You must therefore check for a co_err_none return value to determine that a data value has been successfully read from the stream.



    Practical FPGA Programming in C
    Practical FPGA Programming in C
    ISBN: 0131543180
    EAN: 2147483647
    Year: 2005
    Pages: 208

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net