4.6 Using the COM Ports
The 7188XC(D) has two communication ports.
COM1 can act as either an RS-232 or RS-485 port
RS-232: TXD, RXD, RTS, CTS and GND
RS-485: DATA+, DATA- (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 7188xc 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-7188XC Series User’s Manual(Ver.1.0, Apr/2007,7MH-21-10) ---
55
Summary of Contents for I-7188XC Series
Page 87: ...I 7188XC Series User s Manual Ver 1 0 Apr 2007 7MH 21 10 87...
Page 136: ...I 7188XC Series User s Manual Ver 1 0 Apr 2007 7MH 21 10 136...
Page 142: ...Step 8 Make the project I 7188XC Series User s Manual Ver 1 0 Apr 2007 7MH 21 10 142...
Page 149: ...Step 8 Rebuild the project I 7188XC Series User s Manual Ver 1 0 Apr 2007 7MH 21 10 149...