Practical FPGA Programming in C
Authors: Pellerin D. Thibault S.
Published year: 2005
Pages: 164-167/208
Buy this book on amazon.com >>

CO_STREAM_EOS

int co_stream_eos(co_stream stream);

Header File

co.h

Description

This function checks if a stream is at an end-of-stream condition. This function must be called from within a process run function.

Arguments

The argument for co_stream_eos is as follows :

co_stream stream

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


Return Value

Returns an integer value: 0 if no end-of-stream is detected , and 1 if there is an end-of-stream.

Notes

When co_stream_eos returns 1 (true), subsequent calls to co_stream_eos continue to return 1 until the reader closes the stream.


CO_STREAM_OPEN

co_error co_stream_open(co_stream stream,
                        mode_t mode,
                        co_type type);

Header File

co.h

Description

This function opens a stream. It must be called from within a process run function.

Arguments

The arguments for co_stream_open are as follows :

co_stream stream

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

mode_t mode

The stream's read/write mode. Valid modes are O_RDONLY and O_WRONLY . (There are no bidirectional streams.)

co_type type

The stream's data type. The type is normally expressed as a signed or unsigned integer of a specific width using the INT_TYPE(n) , UINT_TYPE(n) , or CHAR_TYPE macros.


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_invalid_arg

The stream argument is NULL ( CO_ENULL_PTR ) or the mode argument is neither O_RDONLY nor O_WRONLY ( CO_EINVALID_MODE ).

co_err_already_open

The stream is already open in this mode ( CO_EALREADY_OPEN ).



CO_STREAM_READ

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

Header File

co.h

Description

This function reads a data packet from a previously opened stream. This function must be called from within a process run function.

Arguments

The arguments for co_stream_read 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 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 read ( CO_ENOT_OPEN ).


Notes

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

The co_stream_read function blocks (waits) if the stream is empty or until the writer closes the stream.


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
Authors: Pellerin D. Thibault S.
Published year: 2005
Pages: 164-167/208
Buy this book on amazon.com >>

Similar books on Amazon