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 7188xb 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-7188XB(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-7188XB Series User’s Manual(Ver.1.0, Apr/2007,
7MH-020-10
) ---
56
Содержание I-7188XB Series
Страница 88: ...I 7188XB Series User s Manual Ver 1 0 Apr 2007 7MH 020 10 88...
Страница 138: ...I 7188XB Series User s Manual Ver 1 0 Apr 2007 7MH 020 10 138...
Страница 144: ...Step 8 Make the project I 7188XB Series User s Manual Ver 1 0 Apr 2007 7MH 020 10 144...
Страница 151: ...Step 8 Rebuild the project I 7188XB Series User s Manual Ver 1 0 Apr 2007 7MH 020 10 151...