📄 lb_in1.c
字号:
#include <math.h>
#include <stdio.h>
#include <bios.h>
#include <time.h>
#include <conio.h>
#include <dos.h>
#include <string.h>
#include <stdlib.h>
#include <graphics.h>
#include <fcntl.h>
#include <io.h>
#define pai 3.1415926
#define keyQ 0x1051
#define keyq 0x1071
#define keyESC 0x011b
long int l1,l2,l3,l4;
float fd,dd;
int jm,ci,cj,ck,cm,stri[80];
unsigned char str1[80],cc4,cc5,cc6,buf[30][20];
float f1,f2,f3,f4,f5,f6,f7,f8,f9,f11;
char *cpt1,*cpt2;
int *intpt;
unsigned int kf8,kf9,kfa,kfb,kfc,kfd,kfe;
unsigned char cc,c1,c2,c3,cc1,cc2,cc3,hw,hr,vw,vr,str[80],cstr[12];
float roll,pitch,yaw,acx,acy,acz,tempv,time2;
char str2[]="#BA4H=16T*11\r\n"; /* 14 */
char str3[]="#BA4H?*40\r\n"; /* 11 */
int far *ipt=(int far *)0x00400000; /* 400000:com1 400002:com2 */
int far *ipt2=(int far *)0x00400002;
FILE *fp1,*fp2,*fpr;
int xlg10,xlg,xf2,ok;
long int count,count1,count2,xlgs,xlgs0;
int getkey2();
char getchr();
union union1
{ int i;
unsigned int k;
struct struct1
{ unsigned char i_l;
unsigned char i_h;
}s1;
}un;
union union1 un3;
union union2
{ long int l;
struct struct2
{ unsigned int l_l;
unsigned int l_h;
}s2;
struct struct3
{ unsigned char c0;
unsigned char c1;
unsigned char c2;
unsigned char c3;
}s3;
}un2;
void main()
{ long int js;
int i,j;
fd=pai/180;
dd=180/pai;
fp1=fopen("gl1.dat","w+");
fp2=fopen("gl10.dat","w+");
clrscr();
printf("19200: com1(0)/com2(1):");
scanf("%c",&cc);
printf("cc=%c",cc);
getch();
if(cc=='1') {++ipt; kf8=*ipt;}
else kf8=*ipt;
printf(" %2x",kf8);
getch();
kf9=kf8+1;
kfa=kf9+1;
kfb=kfa+1;
kfc=kfb+1;
kfd=kfc+1;
kfe=kfd+1;
outportb(kfb,0x80); /* 8250 start */
outportb(kf8,0x06); /* 06:19.2K 000c 9600b/s 18: 4800 */
outportb(kf9,0x00); /* 0003 38400b/s */
outportb(kfb,0x03); /* 03:10bit,2b addrres mode 11 bit */
outportb(kfc,0x08); /* RS485 RST:d1 0(in)/1(out) 3b data */
outportb(kf9,0x00);
dlay2();
outportb(kfb,0x03); /* data mode 10 bit */
dlay2();
callfk();
gotoxy(10,15);
jm=0;
count=0;
while(jm!=keyQ&&jm!=keyq&&jm!=keyESC) {
jm=getkey2();
if(calljj()!=0) {
printf("no\n"); }
else {
c1=cc;
cc=inportb(kf8);
str1[i]=cc;
if(++i>=11) {
i=0;
printf("%8ld ",++count);
for(j=0;j<11;++j) {
printf("%2x ",str1[j]);
}
c2=0;
for(j=0;j<10;++j) c2=c2+str1[j];
if(c2==str1[10]) ok=1;
else ok=0;
un.s1.i_l=str1[2];
un.s1.i_h=str1[3];
xlg10=un.i;
un.s1.i_l=str1[4];
un.s1.i_h=str1[5];
xf2=un.i;
un2.s3.c0=str1[6];
un2.s3.c1=str1[7];
un2.s3.c2=str1[8];
un2.s3.c3=str1[9];
xlgs=un2.l;
if(count>200) {
fprintf(fp2,"%8ld %6d %8ld %4d %2d\n",count-200,xlg10,xlgs,xf2,ok);
}
printf("%6d %8ld %4d %2d\n",xlg10,xlgs,xf2,ok);
count1=count/100;
if(count1!=count2) {
xlg=(int)(xlgs-xlgs0);
if(count1>2) fprintf(fp1,"%8ld %6d %4d\n",count1-2,xlg,xf2);
count2=count1;
xlgs0=xlgs;
}
}
if(c1==0xa5&&cc==0x5a) {
str1[0]=0xa5;
str1[1]=0x5a;
i=2;
}
}
continue;
callfk();
outportb(kf8,++c1);
printf("%2x ",c1);
continue;
}
fclose(fp1);
fclose(fp2);
}
int callfk()
{ long int i;
i=0;
while(i<50000l)
{ c3=inportb(kfd)&0x20;
if((char)c3!=(char)0) break;
++i;
}
if(i<50000l) return(0);
else return(1);
}
int calljj()
{ long int i;
i=0;
while(i<500000l)
{ c3=inportb(kfd)&0x01;
if((char)c3!=(char)0) break;
++i;
}
if(i<500000l) return(0);
else return(1);
}
void out_com(char cc)
{ outportb(kfc,0x0b); /* RS485 RST:d1 1(out)/0(in) */
callfk();
outportb(kf8,cc);
outportb(kfc,0x08);
}
dlay2()
{
int i,j;
for(i=0;i<5000;++i) j=i;
}
int getkey2()
{
int far *ptr;
if(*((int far *)0x0040001a)==*((int far *)0x0040001c)) return(0);
ptr=(long int)_ES*0x10000+(long int)(*((int far *)0x0040001a));
*((int far *)0x0040001a)=*((int far *)0x0040001c);
return(*ptr);
}
char getchr()
{
while(1){
jm=getkey2();
if(jm!=0) break;
}
return((char)jm);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -