sub_fifo_read

Top  Previous  Next
Got to SUB-20 page

Synopsis

int sub_fifo_read( sub_handle hndl, char* buf, int sz, int to_ms )

 

Function attempts to read sz bytes from IN FIFO into buffer in no more then to_ms time.

Parameters

buf - destination buffer

sz - buffer size. Considering internal FIFO structure it is highly recommended to use only 64 divisible sz values and corresponding buffer size. It will guarantee better performance and no buffer overflow error (-EFBIG).  

to_ms - timeout in milliseconds

 

Return Value

On success a non negative number of actually read bytes is returned. It can be less then or equal to sz. In case of error negative error code (defined in errno.h) will be returned and if applicable sub_errno will be set to the corresponding value. Possible error codes are

-ENOENT (-2)

USB failure

-EIO (-5)

USB failure

-ENOMEM (-12)

Memory failure

-EINVAL (-22)

Invalid parameter

-EFBIG (-27)

Buffer overflow. To prevent this error use 64 divisible sz

-ETIMEDOUT (-116)

Timeout

 

Known Issue

If IN FIFO contains exactly 64 or 128 bytes, attempt to read more then 64 or 128 bytes correspondingly with sub_fifo_read will cause to timeout (-116). As a workaround always call sub_fifo_read with sz=64.