Jump to main content

##

# 1.2.4.4.11 SYS_CONSOLE_WriteFreeBufferCountGet Function

## C

    ssize_t SYS_CONSOLE_WriteFreeBufferCountGet(const SYS_CONSOLE_HANDLE handle)

## Summary

Returns the amount of free space in bytes in the transmit buffer.

## Description

This function indicates the number of bytes of free space available in the transmit buffer.

## Preconditions

The SYS_CONSOLE_Initialize function should have been called before calling this function. In some cases, application may call this API to know the amount of free buffer space available in the transmit buffer before calling SYS_CONSOLE_Write() API.

## Parameters

Param | Description
--- | ---
handle | Handle to the console instance

## Returns

The return value indicates the number of bytes of free space available in the transmit buffer. Returns -1 in case of any error.

## Example

    ssize_t nFreeSpace;
    char myBuffer[100];
    SYS_CONSOLE_HANDLE myConsoleHandle;

    // Get the number of bytes of free space available in the transmit buffer.
    nFreeSpace = SYS_CONSOLE_WriteFreeBufferCountGet(myConsoleHandle);

    if ((nFreeSpace >= sizeof(myBuffer)) && (nFreeSpace!= -1))
    {
        // Write the application buffer
        SYS_CONSOLE_Write( myConsoleHandle, myBuffer, sizeof(myBuffer) );
    }

## Remarks

None.