1.2.4.4.6 SYS_CONSOLE_Read Function

C

ssize_t SYS_CONSOLE_Read(
    const SYS_CONSOLE_HANDLE handle,
    void* buf,
    size_t count
)

Summary

Reads data from the console device.

Description

This function reads the data from the console device.

If the data is not read out from the internal receive buffer by calling the SYS_CONSOLE_Read API at regular intervals, there is a possibility of the receive buffer becoming full. As a result, the new data may be lost. Hence, the application must call the SYS_CONSOLE_Read API at regular intervals to avoid buffer overflow condition.

The SYS_CONSOLE_ReadCountGet() and the SYS_CONSOLE_ReadFreeBufferCountGet() APIs may be used to know the number of unread bytes available in the receive buffer and the amount of free space available in the receive buffer respectively.

Preconditions

The SYS_CONSOLE_Initialize function should have been called before calling this function.

Parameters

ParamDescription
handleHandle to the console instance
bufBuffer to hold the read data.
countNumber of bytes to read.

Returns

Return value indicates the number of bytes actually read. Returns -1 in case of any error.

Example

ssize_t nr; //indicates the actual number of bytes read
char myBuffer[MY_BUFFER_SIZE];
SYS_CONSOLE_HANDLE myConsoleHandle;

// myConsoleHandle is assumed to be pointing to a valid console handle
nr = SYS_CONSOLE_Read( myConsoleHandle, myBuffer, MY_BUFFER_SIZE );
if (nr == -1)
{
    // Handle error
}

Remarks

None