#include #include #include #include #include #define COM1 0 #define COM2 1 #define DATA_READY 0x100 #define COM_2400 0xA0 #define COM_NOPARITY 0x00 #define COM_CHR7 0x02 #define COM_STOP2 0x04 #define SETTINGS ( COM_2400 | COM_NOPARITY | COM_CHR7 | COM_STOP2 ) /* #define COM1 1 #define TRUE 1 #define FALSE 0 #define SETTINGS (_COM_9600 | _COM_CHR7 | _COM_STOP2 | _COM_NOPARITY) */ unsigned long data_in[256]; void main() { unsigned in,out, cnt, c ; int term, tmr1, tmr2, tmr3, tmr4; char filename[20]; FILE *fp; struct time t; clrscr(); bioscom(0, SETTINGS, COM1); /* RS232C ÃʱâÈ­ */ printf("Sampling Count : \n"); printf("file name : \n"); printf("term(sec) : \n"); printf("=======================\n"); gotoxy(18, 1); scanf("%d", &in); gotoxy(13, 2); scanf("%s", &filename); gotoxy(13,3); scanf("%d", &term); gettime(&t); tmr1 = t.ti_min * 60 + t.ti_sec; tmr3 = tmr1; gotoxy(1,5); printf("Data receive\n"); printf("The current time is: %d\n", tmr1); for (cnt = 0; cnt < in; cnt++) { while (1) { gettime(&t); tmr4 = t.ti_min *60 + t.ti_sec; if(tmr4-tmr3 >= term) { tmr3 = tmr4; break; } } while( (bioscom(3, 0, COM1) & DATA_READY)==0 ); /*¼ö½Å ´ë±â */ out = bioscom(2,0,COM1); /* ¼ö½Å */ data_in[cnt] = out; // printf("."); printf("%d \t", out); if (kbhit()) { // Űº¸µåÀÇ ÀÔ·ÂÀÌ ÀÖÀ¸¸é 1 ±×·¸Áö ¾ÊÀ¸¸é 0À» µÇµÉ¸®´Â ÇÔ¼ö if (getch() == '\x1B') break; //16Áø¼ö 1B, Áï ESC ÄÚµå } } gettime(&t); tmr2 = t.ti_min * 60 + t.ti_sec; printf("\n"); printf("The current time is : %d\n", tmr2); printf("%d, %d\n", in, tmr2-tmr1); printf("\naverage time : %2.3f\n", ((float)(tmr2-tmr1)) / ((float)in)); printf("** press ENTER to data save."); getch(); fp = fopen(filename,"w"); for(cnt = 0; cnt