C Language Development Kit/Functions/ComOpen
From OptiWiki
| Description | Opens a port for serial communication. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Syntax | int comopen(unsigned int port); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Arguments | port specifies which serial communications port is to be opened. See the table below for details.
unsigned int port
The baudrate, the number of data bits, the parity mode, the number of stopbits and the handshaking modes, can all be selected via a systemsetting() call. comopen() uses the current settings when opening a communications port. The default settings of the handheld terminal are:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Returns |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Remarks | When a comport is opened the power consumption may increase, so use the comclose() function when serial communication is no longer needed.
When you have opened a communication port with comopen(), and then you open a second communication port with comopen() the first port is closed automatically. The functions getcom() and putcom(), will use the port opened by comopen(). Note: Only the PHL1700 has a difference between COM1 and COM2. The rest of the terminals do support COM1 and COM2, but there is no difference between them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 = getcom( 0 )) != -1) { putchar( ch ); putcom( ch ); } if( (ch = getchar()) != EOF) { putchar( ch ); putcom( ch ); } idle(); // Very important to lower the power consumption } } |
