C Language Development Kit/Functions/PutCom2

From OptiWiki

Jump to: navigation, search
Description putcom2() transmits a character through the specified serial communications port.
Syntax
int putcom2(unsigned int port, int c);
Arguments
unsigned int port
port specifies which serial communications port is to be opened. See the table below for details.
int c
c is the character that is to be transmitted


Terminal Supported ports Description
OPH100x COM1 Cradle CRD1001 or IrDA dongle
COM2 Same as COM1
Returns OK or ERROR.
Remarks When the COM port was not opened previously, ERROR will be returned.
Example
#include "lib.h"
#include <stdio.h>
 
void main( void )
{
    int ch;
 
    comopen( COM2 );    // Open the COM port for the cradle.
 
    while( 1 )
    {
        if( (ch = getcom2( COM2, 0 )) != -1)
        {
            putchar( ch );
            putcom2( COM2, ch );
        }
 
        if( (ch = getchar()) != EOF)
        {
            putchar( ch );
            putcom2( COM2, ch );
        }
        idle();    // Very important to lower the power consumption
    }
}


Views
Personal tools