A SERVICE OF

logo

iVIEW-100 Series user’s Manual, 2006, v2.0 ----- 101
7.7 How To Use COM1/2
The iVIEW-100 has 2 communication ports.
COM1 is an RS-232 port.
COM2 can be used as an RS-232 or RS-485 port.
7.7.1 How to use COM
Before using the COM port, user must call “InstallCom” (or InstallCom1/2) to
install the driver for the COM port.
Before exiting the program, user must call “RestoreCom” (or RestoreCom1/2)
to un-install the driver.
After calling “InstallCom”, the user could read COM data, send data to COM,
print COM data, and so on.
Before read data from COM, user should use “IsCom” to check if there any data
is already come in COM port. If yes, then use ReadCom” to read data from
input buffer.
Before send data to COM, user could use “ClearCom” to make sure the COM is
cleared, then use “ToCom” to send data to COM port.
For example, to echo the data back to the COM1:RS232 port, the code is shown
below.
int port=1;
/* for use COM1 */
int quit=0,data;
InstallCom(port,57600L,8,0,1);
/* install COM driver */
while(!quit){
if(IsCom(port)) {
/*check if any data is in from com-port*/
data=ReadCom(port);
/* read data from com-port */
ToCom(data);
/* send data to com-port */
If(data==’q’) quit=1;
/* if receive ‘q’, exit the program */
}
}
…………
/* here is for user’s program code*/
RestoreCom(port);
/* un-install COM driver */