ComOpen

Availability All terminals
Description Opens a port for communication.
Syntax int ComOpen( int port );
Arguments
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
0 The port was opened normally.
-1 The port number was invalid.
-3 The port could not be opened, because the cradle did not respond
> 0 The currently opened COM port, if the argument value was -1.
< -10 A Bluetooth connection could not be established.
Remarks

When a comport is opened the power consumption may increase, so use the ComClose() function when communication is no longer needed.

When you have opened a communication port with ComOpen() this port is automatically closed when another communication port is opened using ComOpen().

The functions GetCom() and PutCom(), will use the port opened by ComOpen().

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
    }
}