⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shujucj.txt

📁 GPS数据采集程序 GPS数据采集程序
💻 TXT
字号:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#define	BYTE	unsigned char
#define	max_buffer 5000
#define 	COM1	0x3F8
#define	COM2	0x2F8
#define 	EOI	0x20
#define 	IER	1
#define 	IIR	2
#define 	LCR	3
#define 	MCR	4
#define 	LSR	5
#define 	MSR 	6
int want_exit;
unsigned int h;
unsigned char rx_buff[max_buffer+1];
static unsigned int head;
void (interrupt far *old_serial1) (void);
void interrupt far new_serial1()
{	unsigned int status=0;
	do{status=inportb(COM1+IIR);
	if(status=4)
	{rx_buff[head+1]=inportb(COM1); h=h++;}
	if(head==max_buffer)	 head=0;}
	while(status==4);
	disable();
	outportb(0x20,EOI);
	enable();
}
void init_serial com1(int brdl)
{	int tmp;
	old_serial1=getvect(0x0C);
	disable();
	outportb(COM1+IER,0x00);
	outportb(COM1+LCR,0x80);
	outportb(COM1,brdl);
	outportb(COM1+IER,0x00);
	outportb(COM1+MCR,0x09);
	outportb(COM1+LCR,0x03);
	setvect(COM1+IER,0x00);
	outportb(COM1+IER,0x01);
	tmp=inportb(0x21);
	tmp&=0xEF;
	outport(0x21,tmp);
	enable();
}
int get_byte()
{	BYTE db;
	static unsigned int tail;
	if(tail==head) return=1;
	else
	{ db=rx_buff[tail+1];
	   if(tail=max_buffer) tail=0;
	return(db);}
}
void proc_kbd(kch)
{	char kcc,kcd[4];
	kcc=' ';
	switch(toapper(kch))
	{ case 0x44; /*F10*/
	   gotoxy(1.25); printf("Sure(Y/N)?");
	   kcc=getch();
	   kcc=toapper(kcc);
	   printf("%c",kcc);
	   sleep(1);
	   if(kcc=='Y'){want_exit=1;}
	gotoxy(1.25);printf("                ");
	break;
	default;
	break;}
}
main()
{	int i,k,count,have_sync,confirm;
	char filename[30];
	char filename1[30];
	unsigned char msgbuff[1000];
	char kch;
	FILE *fin1;
	FILE *fin2;
	init_serial com1(l2);
	have_sync=0;
	want_exit=0;
	kch=' ';
	for(i=0;i<200;i++) msgbuff[i]=0x20;
	if((fin1=fopen("****.eph","wb+"))=NULL)
	{ printf(stderr,"cannot open the input file.\n");}
	if((fin2=fopen("****.obs","wb+"))=NULL)
	{ printf(stderr,"cannot open the input file.\n");}
	count=0;
	do{
kj: 	if(kbhit())
	{ kch=getch();proc_kbd(kch);}
	i=get_byte();
	if(i==-1)
	continue;
	if(i=='@')
	{
	{msgbuff[0]=1; printf("%c",i);
mm:	i=get_byte();
	if(i==-1) goto mm;
	if(i!='@') goto kj; msgbuff[1]=i;
	printf("%c",i);}
	}
pp:	i=get_byte();
	if(i==-1) goto pp;printf("%c",i);
	if((i!='B')&&(i!='E')) goto kj; msgbuff[2]=i;
	printf("%c",i);
qq: 	i=get_byte();
	if(==-1) goto qq;
	if(msgbuff[2]=='B') { if(i!='f') goto kj; msgbuff[3]=i;confirm=0;}
	if(msgbuff[2]=='E') { if(i!='g') goto kj; msgbuff[3]=i;confirm=1;}}
	have_sync=1;k=3;
	if(have_sync==1)
lk:	i=get_byte();
	if(i==-1) goto lk;
	k++; msgbuff[k]=i; printf("%c",i);
nn:	if(i!=0x0A) goto lk;}
	if(confirm==0) {if(k!=79) goto lk;}
	if(confirm==1) {if(k!=157) goto lk;}
	for(i=0;i<k+1;i++)
	{ printf("%x",msgbuff[i]);
	if(confirm==0) fputc(msgbuff[i],fin1);
	if(confirm==1) fputc(msgbuff[i],fin2);}
	count++;
	fprintf("%i%i\n",k,count);
retry:	have_sync=0;
	continue;}
	while(!want_exit);
end:	fclose(fin1);
	fclose(fin2);
	outportb(COM1+IER,0x00);
	setvect(0x0C,old_serial1);
	fprintf("All done.\r\n");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -