if(data==’q’) quit=1; /*if ‘q’ is received, exit the program*/
}
}
RestoreCom(port); /*uninstall the COM driver*/
Use the “port” variable to switch from COM1 to COM2, simply change
port=1
to
port=2
.
If the program is set to use COM1, the code can be altered as follows:
int quit=0, data;
InitLib(); /* Initiate the 7188xc library */
InstallCom1(115200L, 8, 0, 1); /*install the COM1 driver*/
while(!quit){
if(IsCom1()){ /*check if any data is in the COM1 input buffer*/
data=ReadCom1(); /*read data from COM1*/
ToCom1(data); /*send data via COM1*/
if(data==’q’) quit=1; /*if ‘q’ is received, exit the program*/
}
}
RestoreCom1(); /*uninstall the COM driver*/
4.6.1 To print from the COM port
The I-7188XC(D) library also supports functions such as
printf()
from
the standard C library to produce a formatted output.
The
printCom()
function can be used for all COM Ports, and
printCom1/2 can be sued for individual ports. Before using the
printCom()
function, the
InstallCom()
function must first be called. The
code is shown below:
I-7188XC Series User’s Manual(Ver.1.0, Apr/2007,7MH-21-10) ---
56
Содержание I-7188XC Series
Страница 87: ...I 7188XC Series User s Manual Ver 1 0 Apr 2007 7MH 21 10 87...
Страница 136: ...I 7188XC Series User s Manual Ver 1 0 Apr 2007 7MH 21 10 136...
Страница 142: ...Step 8 Make the project I 7188XC Series User s Manual Ver 1 0 Apr 2007 7MH 21 10 142...
Страница 149: ...Step 8 Rebuild the project I 7188XC Series User s Manual Ver 1 0 Apr 2007 7MH 21 10 149...