GetCom

Availability All terminals
Description This function reads a character from the receive buffer of the serial communications port that was opened last by ComOpen().
Syntax int GetCom( int timeout );
Arguments
int timeout
timeout is the time (in steps of 20ms) that the routine tries to get a character from the communications port before returning. For example, timeout = 10 specifies 200 milliseconds. When timeout = 0, the routine returns immediately.
Returns On success, when a character is available, GetCom() returns the received character.
On error -1 is returned.
Remarks - When no port is currently open, ERROR will be returned.
- Note that on the OPN-2500 ;amp OPN-6000 the default port (COM9) is automatically opened at start-up.
Example
#include <stdio.h>
#include "lib.h"

void main( void )
{
    int ch;

    ComOpen( COM9 );    // Open the USB-VCP port

    for(;;)
    {
        if( (ch = GetCom( 0 )) != -1)
        {
            PutCom( ch );
        }

        Idle();    // Very important to lower the power consumption
    }
}