/* printf.c ------ demo program for 7188 demo program for use function printCom4. the use of printCom,printCom1,printCom2,printCom3,printCom4 are all the same as C function printf. The internal buffer is 160 bytes, so user cannot use printCom(1/2/3/4) to print a message longer then 159 characters. printCom(1/2/3/4) are useful for user to send formated message to comport */ #include #include"..\lib\7188.h" main() { int i; float data; if(!Is7188()){ printf("printf.exe must run on 7188!"); return; } printf("Print message to COM4 using C function printf()\n"); data=1.2; for(i=0;i<10;i++,data+=1.1){ printf("Test %d (%04d) %.1f\n",i,i*999,data); /* use "\n" */ } InstallCom4(57600,8,0); /* before use printCom4 must call InstallCom4 */ printCom4("Now, Print message using printCom4()\n\r"); data=1.2; for(i=0;i<10;i++,data+=1.1){ printCom4("Test %d (%04d) %.1f\n\r",i,i*999,data); /* use "\n\r" */ } printCom4("Press any key to quit."); for(i=0;;i++){ if(IsCom4()){ ReadCom4(); break; } else { printCom4("\n\rTest %u",i); } } while(!IsCom4OutBufEmpty()) ; /* Wait all message sent out of COM4 */ RestoreCom4(); /* getch4(); */ }