📄 xjizho2.c
字号:
/* xjizho2.c from XJIZHO1.c */
/* use com2(0x3f8L),9600, */
#include "dos.h"
void l_table(void);
void trans1();
void trans2();
void view();
void view1();
void comm3(void);
void comm4(void);
void comm8(void);
void comm7(void);
void comm6(void);
void comm5(void);
int initserial (long int baud_rate,char parity,int serialno);
union p{unsigned char v[530];
};
union p c;
int i,n,j,num,num1;
long unsigned int r;
int t;
unsigned char tbut[20];
unsigned int crc16();
unsigned int crc;
main()
{
/* read data*/
comm5();
initserial (9600,'n',1);
start: for(num=1;num<2;num++) {
delay(15);
outp(0x3f8+3,0x07);
s: if((inp(0x3f8+5))&0x20)
{
n=0;
s10: if((inp(0x3f8+5))&0x20)
{
outp(0x3f8,tbut[n]);
n++;
if (n<8) {goto s10;}
com1();
}
else goto s10;
}
else goto s;
}
l_table();
clearv2400();
goto start;
}
com1()
{
n=0;
trans1();
}
void trans1()
{
r=0;
for(i=0;i<121;i++) {
t2: if(!((inp(0x3f8+5))&0x01))
{
r++;
if(r>380000) {goto sss;}
else goto t2;
}
else c.v[i]=inp(0x3f8);
}
sss: ;
}
void l_table(void)
{
clrscr();
l_data_1();
sleep(20);
}
l_data_1()
{
i=0;n=0;
i=n;gotoxy(9,4);view1();
i=n+6;gotoxy(9,5);view1();
i=n+12;gotoxy(9,6);view1();
i=n+18;gotoxy(9,7);view1();
i=n+24;gotoxy(9,8);view1();
i=n+30;gotoxy(9,9);view1();
i=n+36;gotoxy(9,10);view1();
i=n+42;gotoxy(9,11);view1();
i=n+48;gotoxy(9,12);view1();
i=n+54;gotoxy(9,13);view1();
i=n+60;gotoxy(9,14);view1();
i=n+66;gotoxy(9,15);view1();
i=n+72;gotoxy(9,16);view1();
i=n+78;gotoxy(9,17);view1();
i=n+84;gotoxy(9,18);view1();
i=n+90;gotoxy(9,19);view1();
i=n+96;gotoxy(9,20);view1();
i=n+102;gotoxy(9,21);view1();
i=n+108;gotoxy(9,22);view1();
i=n+114;gotoxy(9,23);view1();
i=n+120;gotoxy(9,24);view1();
i=n+126;gotoxy(9,25);view1();
}
void view1()
{
printf("%4x%4x%4x%4x%4x%4x",c.v[i],c.v[i+1],c.v[i+2],c.v[i+3],c.v[i+4],
c.v[i+5]);
}
int initserial (long int baud_rate,char parity,int serialno)
{
union {
struct {
unsigned char lobyte;
unsigned char hibyte;
}byte;
struct {
unsigned baud_factor; }whole;
}bytes;
unsigned char x;
outp(0x3f8+3,0x80);bytes.whole.baud_factor=1843200L/((long)baud_rate<<4);
outp(0x3f8+0,bytes.byte.lobyte);
outp(0x3f8+1,bytes.byte.hibyte);
outp(0x3f8+4,0x03);
outp(0x3f8+1,0x00);
switch(parity) {
case 'e':
case 'E': x=0x2b; break;
case 'o':
case 'O': x=0x3b; break;
case 'n':
case 'N': x=0x03; break;
default: return(-1);
}
outp(0x3f8+3,x);
}
clearv2400()
{
for (t=0;t<525;t++){
c.v[t]=0;}
}
/*CRC Generation Function */
unsigned int crc16(unsigned char *str,unsigned int num)
{
int i,j;
unsigned int c,crc=0xffff;
for (i=0;i<num;i++)
{ c=str[i]&0x00ff;
crc^=c;
for (j=0;j<8;j++)
{
if (crc&0x0001)
{
crc>>=1;
crc^=0xa001;
}
else
crc>>=1;
}
}
return(crc);
}
void comm3(void) /* format 1.3.2*/
{
tbut[0]=0x07;
tbut[1]=0x04;
tbut[2]=0x00;
tbut[3]=0x50;
tbut[4]=0x00;
tbut[5]=0x01;
crc=crc16(tbut,6);
tbut[6]=crc%256;
tbut[7]=crc/256;
}
void comm4(void) /* format 1.4.1*/
{
tbut[0]=0x07;
tbut[1]=0x06;
tbut[2]=0x00;
tbut[3]=0x50;
tbut[4]=0x07;
tbut[5]=0x07;
crc=crc16(tbut,6);
tbut[6]=crc%256;
tbut[7]=crc/256;
}
void comm5(void) /* */
{
tbut[0]=0x07;
tbut[1]=0x03;
tbut[2]=0x00;
tbut[3]=0x00;
tbut[4]=0x00;
tbut[5]=0x60;
crc=crc16(tbut,6);
tbut[6]=crc%256;
tbut[7]=crc/256;
}
void comm6(void) /* */
{
tbut[0]=0x07;
tbut[1]=0x03;
tbut[2]=0x00;
tbut[3]=0xc0;
tbut[4]=0x00;
tbut[5]=0x60;
crc=crc16(tbut,6);
tbut[6]=crc%256;
tbut[7]=crc/256;
}
void comm7(void) /* */
{
tbut[0]=0x07;
tbut[1]=0x03;
tbut[2]=0x01;
tbut[3]=0x80;
tbut[4]=0x00;
tbut[5]=0x60;
crc=crc16(tbut,6);
tbut[6]=crc%256;
tbut[7]=crc/256;
}
void comm8(void) /* */
{
tbut[0]=0x07;
tbut[1]=0x03;
tbut[2]=0x02;
tbut[3]=0x40;
tbut[4]=0x00;
tbut[5]=0x60;
crc=crc16(tbut,6);
tbut[6]=crc%256;
tbut[7]=crc/256;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -