GetCom2

Availability All terminals
Description This function reads a character from the receive buffer of the communications port that was specified. The difference between this function and GetCom() is that you can specify the port here, where GetCom() uses the last port that was opened.
Syntax int GetCom2( int port, int timeout );
Arguments
int port, int timeout
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.
int port
port specifies which communications port is to be opened. See the table below for details.

Terminal Supported ports Description
OPN-2500 & OPN-6000 COM0
COM1
COM7
COM8
COM9
COM10
COM11
COM12
COM13
COM14
COM15
COM16
COM17
COM18
USB-VCP (Opticon 1D COM-Port)
USB-CDC (Opticon 2D COM-Port)
USB-CDC (OptiConnect)
USB-CDC (Opticon 2D COM-Port)
USB-HID (Human Interface device)
USB-MSD (Mass Storage)
Bluetooth HID (No white list)
Bluetooth HID (White list)
Bluetooth LE UART & OptiConnect (No white list)
Bluetooth LE UART & OptiConnect (White list)
Bluetooth LE OptiConnect(No white list)
Bluetooth LE OptiConnect (White list)
Bluetooth LE UART (No white list)
Bluetooth LE UART (White list)
Returns On success, when a character is available, GetCom2() returns the received character.
On error -1 is returned.
Remarks When the specified port is currently not opened, ERROR will be returned.
Example
#include <stdio.h>
#include "lib.h"

void main( void )
{
    int ch;

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

    for(;;)
    {
        if( (ch = GetCom2(COM9, 0)) != -1)
        {
            PutCom2(COM9, ch);
        }

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