![background image](http://html1.mh-extra.com/html/icp-das-usa/i-7188xb-series/i-7188xb-series_user-manual_3585678055.webp)
4.6 Using the COM Ports
The 7188XB(D) has two communication ports.
COM1 can act as either an RS-232 (Default) or RS-485 port
RS-232: TXD, RXD, RTS, CTS and GND
RS-485: D1+, D1- (Self-tuner ASIC inside)
COM2 is an RS-485 port (D2+, D2-, Self-tuner ASIC inside)
Before using the COM Port, the
InstallCom()
(or
InstallCom1/2
)
function must be called to install the driver for the COM Port.
Before exiting the program, the
RestoreCom()
(or
RestoreCom1/2
)
function must be called to uninstall the driver.
After calling the
InstallCom()
function, data can be read from the COM
Port, sent to the COM Port, printed from the COM Port and so on.
Before reading data from the COM port, the
IsCom()
function should be
used to check if any data has already been sent to the COM Port. If yes,
then the
ReadCom()
function should be used to read the data from
input buffer of the COM Port.
Before sending data to the COM Port, the
ClearCom()
function could be
used to make sure the output buffer of the COM Port is clear, then use
the
ToCom()
function to send data to the COM Port.
For example, the code to echo the data back to COM1 (RS-232) is
shown below.
int port=1; /*to use COM1*/
int quit=0, data;
InitLib(); /* Initiate the 7188xb library */
InstallCom(port, 115200L, 8, 0, 1); /*install the COM driver*/
while(!quit){
if(IsCom(port)){ /*check if any data is in the COM Port input buffer*/
data=ReadCom(port); /*read data from the COM Port*/
ToCom(port, data); /*send data via the COM Port*/
I-7188XB Series User’s Manual(Ver.1.0, Apr/2007,
7MH-020-10
) ---
55
Summary of Contents for I-7188XB Series
Page 88: ...I 7188XB Series User s Manual Ver 1 0 Apr 2007 7MH 020 10 88...
Page 138: ...I 7188XB Series User s Manual Ver 1 0 Apr 2007 7MH 020 10 138...
Page 144: ...Step 8 Make the project I 7188XB Series User s Manual Ver 1 0 Apr 2007 7MH 020 10 144...
Page 151: ...Step 8 Rebuild the project I 7188XB Series User s Manual Ver 1 0 Apr 2007 7MH 020 10 151...