1.2.4.4.7 SYS_CONSOLE_Write Function

C

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

Summary

Writes data to the console device.

Description

This function writes data to the console device. The function performs a deep-copy of the data passed in buf.

Preconditions

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

Parameters

ParamDescription
handleHandle to the console instance
bufBuffer holding the data to be written.
countNumber of bytes to write.

Returns

The return value indicates the number of bytes accepted by the function.

In case the return value is less than the count value, the application must try to send the remaining bytes in next attempt(s).

Returns -1 in case of any error.

Example

ssize_t nr;
char myBuffer[] = "message";
SYS_CONSOLE_HANDLE myConsoleHandle;

// myConsoleHandle is assumed to be a valid console handle
nr = SYS_CONSOLE_Write( myConsoleHandle, myBuffer, strlen(myBuffer) );
if (nr == -1)
{
    // Handle error
}
if (nr != strlen(myBuffer))
{
    // Try send the remaining data after some time.
}

Remarks

Application may check the free space available in the transmit buffer by calling the SYS_CONSOLE_WriteFreeBufferCountGet() API.