📄 main.c
字号:
#include <intrins.h>
#include <string.h>
#include ".\include\gk_head.h"
#include ".\include\gk_string.h"
#include ".\include\gk_serial_uart0.h"
#include ".\include\gk_timer0.h"
#include ".\include\gk_timer2.h"
#include ".\include\gk_sub_func.h"
//#include ".\include\asm.h"
#include "math.h"
/*
code unsigned char Serial_Pre[]={0xAA,0xAA,0x14,0xcd,0x01,0x05,0x64,0x00,0x00,0x00,0x00,0x00
,0x85,0x0c,0x00,0x00,0x00,0x00
};
*/
struct _aaaaaaaaa{
int aa[2];
int bb[2];
}aaaaaaaaa;
char *p;
//#define KEYIN XDATA[0xa01e]
//#define KEYOUT XDATA[0xa01e]
//char KEYIN ;
//char KEYOUT ;
Uchar xdata KEYIN _at_ 0xa000; // Define ADDRESS_PAGECTR at address 0xa000 space
Uchar xdata KEYOUT _at_ 0xa000; // Define ADDRESS_PAGECTR at address 0xa000 space
Uchar idata KEYOUT1 ;// _at_ 0xa0; // Define ADDRESS_PAGECTR at address 0xa000 space
typedef void (*voidfunc)();
// 税控卡,用户卡,管理卡部分
code char* ptax_app_dir = "TSAM01";
code char* puser_app_dir = "TID01";
code char* pmgr_app_dir = "CHECK01";
code char ptax_monitor_manager_data[] = {0xEF, 0x01};
code char ptax_basic_info[] = {0xEF, 0x02};
code char ptax_day_trade_record[] = {0xEF, 0x03};
code char ptax_declare_backup[] = {0xEF, 0x04};
code char ptax_check_storage[] = {0xEF, 0x05};
code char puser_monitor_manager_data[] = {0xEF, 0x01};
code char puser_basic_info[] = {0xEF, 0x02};
code char puser_tax_item[] = {0xEF, 0x03};
code char puser_declare_data_total[] = {0xEF, 0x04};
code char puser_check_buy_info[] = {0xEF, 0x05};
code char puser_machine_info[] = {0xEF, 0x06};
//code char puser_check_use_info[] = {,};
code char puser_check_distribute_tmp[] = {0xEF, 0x07};
code char puser_separate_check_serial[] = {0xEF, 0x08};
code char pmgr_audit_control[] = {0xEF, 0x01};
code char pmgr_basic_info[] = {0xEF, 0x02};
code char pmgr_audit[] = {0xEF, 0x03};
code char pcare_audit_control[] = {0x3F,0x11}; //审计日志维护权限文件
code char pcare_machine_info[] = {0x3F,0x12}; //授权卡机器信息
code char pcare_main_dir[] = {0x3F,0x00};
char recv_pro(char data1,char data2);
//void reverse_font2();
void reverse_font2(char *pFont,char *reverse_font);
void reverse_font3(char *pFont,char *reverse_font);
// IC卡部分
//////////////////////////////////////////////// 沙岩提供
/*
IC卡通讯协议,包头部分
*/
typedef struct _IC_CommandHead
{
//char start;
unsigned long cla;
//char type;
unsigned long ins;
//char len;
unsigned long p1;
//char time;
unsigned long p2;
}IC_HEAD;
/*
IC卡通讯协议,包尾部分
*/
typedef struct _IC_CommandTail
{
//char bcc;
unsigned long bcc;
char end[4];
//unsigned long end1;
//unsigned long end2;
}IC_TAIL;
void ic_update_controls(IC_HEAD* pHead);
int aaaaaa[10];
unsigned long number;
unsigned long check_sum=0;
int sub_function1();
int sub_function2(int);
static int kkkkk=0;
//2006-1-8 20:16
//定义PLU 的结构体为32字节长度 利于保存和处理
struct _PLU_STRUCT
{
Ulong index; //4 索引 并不是在存储区的位置索引
Ulong price; //4 单价
Uchar name[20]; //20 名称
// Uchar flag; //1 有效标志位
Uchar pandom[4]; // 保留
};
code struct _PLU_STRUCT PLU_ITEM[5]={{1,100,"1111",1,1,1},
{2,200,"2222",1,1,1},
{3,300,"3333",1,1,1},
{4,400,"4444",1,1,1},
{5,500,"5555",1,1,1}
};
int SDLC_Parse(unsigned char *p,int len)
{
unsigned char buf[1024];
unsigned char *p1;
unsigned char *p2;
int length=0;
p1=buf;
p2=p;
do
{
switch(*p)
{
case 0x19:
*p1=0x19;
p1++;
*p1=0x5c;
length++;
break;
case 0x99:
*p1=0x19;
p1++;
*p1=0x76;
length++;
break;
case 0x11:
*p1=0x19;
p1++;
*p1=0xa0;
length++;
break;
case 0x13:
*p1=0x19;
p1++;
*p1=0xa1;
length++;
break;
default:
*p1=*p;
break;
}
p1++;
p++;
length++;
len--;
}while(len!=0);
p1=buf;
p=p2;
*p=0x30;
*(p+1)=0x10;
memcpy(p+2,p1,length+2);
*(p+length+2)=0x19;
*(p+length+3)=0xb1;
return length+4;
}
//接收后完成数据格式转换
//p 接收到的数据首地址 完整的数据
//出口:转换后的数据长度
// 转换后的数据存放在 p中 覆盖原有的数据
int SDLC_Packet(unsigned char *p)
{
unsigned char buf[1000];
unsigned char *p1;
unsigned char flag=0;
unsigned char *p2=p;
int length=0;
// char* p1 = ap_malloc(256);
// ap_free(p1);
p1=buf;
do
{
if(*p==0x19)
{
p++;
switch(*p)
{
case 0x5c: //1
*p1=0x19;
break;
case 0x76: //2
*p1=0x99;
break;
case 0xa0: //3
*p1=0x11;
break;
case 0xa1: //4
*p1=0x13;
break;
case 0x5d: //5 2个字节
*p1=0x19;
p1++;
*p1=0x19;
length++;
break;
case 0x77: //6
*p1=0x99;
p1++;
*p1=0x99;
length++;
break;
case 0xa2: //7
*p1=0x11;
p1++;
*p1=0x11;
length++;
break;
case 0xa3: //8
*p1=0x13;
p1++;
*p1=0x13;
length++;
break;
case 0xa4: //9
*p1=0x19;
p1++;
*p1=0x99;
length++;
break;
case 0xa5: //10
*p1=0x19;
p1++;
*p1=0x11;
length++;
break;
case 0xa6: //11
*p1=0x19;
p1++;
*p1=0x13;
length++;
break;
case 0xa7: //12
*p1=0x99;
p1++;
*p1=0x19;
length++;
break;
case 0xa8: //13
*p1=0x99;
p1++;
*p1=0x11;
length++;
break;
case 0xa9: //14
*p1=0x99;
p1++;
*p1=0x13;
length++;
break;
case 0xaa: //15
*p1=0x11;
p1++;
*p1=0x19;
length++;
break;
case 0xab: //16
*p1=0x11;
p1++;
*p1=0x99;
length++;
break;
case 0xac: //17
*p1=0x11;
p1++;
*p1=0x13;
length++;
break;
case 0xad: //18
*p1=0x13;
p1++;
*p1=0x19;
length++;
break;
case 0xae: //19
*p1=0x13;
p1++;
*p1=0x99;
length++;
break;
case 0xaf: //20
*p1=0x13;
p1++;
*p1=0x11;
length++;
break;
case 0xb1:
flag=1;
break;
}
}
else
*p1=*p;
if(flag==0)
{
p1++;
p++;
length++;
}
}while(flag==0);
memcpy(p2,buf,length);
return length;
}
void Convert_Font()
{
static char buffer[600];
static char Font_Buf[18];
int j;
Font_Buf[0]=0x00;
Font_Buf[1]=0x00;
Font_Buf[2]=0x00;
Font_Buf[3]=0x00;
Font_Buf[4]=0x00;
Font_Buf[5]=0x0;
Font_Buf[6]=0x00;
Font_Buf[7]=0x0;
Font_Buf[8]=0x0;
Font_Buf[9]=0x00;
Font_Buf[10]=0x0;
Font_Buf[11]=0x00;
Font_Buf[12]=0x00;
Font_Buf[13]=0x00;
Font_Buf[14]=0x0;
Font_Buf[15]=0x3;
Font_Buf[16]=0xff;
Font_Buf[17]=0xff;
for(j=0;j<18;j++)
buffer[j]=0x00;
//在此读取字库文件
////////////////////////////////////
////////////////////////////////////
buffer[0]|=((Font_Buf[0]&0x80)?1:0)<<7; //第一个字节
buffer[0]|=((Font_Buf[2]&0x20)?1:0)<<6;
buffer[0]|=((Font_Buf[4]&0x08)?1:0)<<5;
buffer[0]|=((Font_Buf[6]&0x02)?1:0)<<4;
buffer[0]|=((Font_Buf[9]&0x80)?1:0)<<3;
buffer[0]|=((Font_Buf[11]&0x20)?1:0)<<2;
buffer[0]|=((Font_Buf[13]&0x08)?1:0)<<1;
buffer[0]|=(Font_Buf[15]&0x02)?1:0;
buffer[1]|=((Font_Buf[0]&0x40)?1:0)<<7;
buffer[1]|=((Font_Buf[2]&0x10)?1:0)<<6;
buffer[1]|=((Font_Buf[4]&0x04)?1:0)<<5;
buffer[1]|=((Font_Buf[6]&0x01)?1:0)<<4;
buffer[1]|=((Font_Buf[9]&0x40)?1:0)<<3;
buffer[1]|=((Font_Buf[11]&0x10)?1:0)<<2;
buffer[1]|=((Font_Buf[13]&0x04)?1:0)<<1;
buffer[1]|=(Font_Buf[15]&0x01)?1:0;
buffer[2]|=((Font_Buf[0]&0x20)?1:0)<<7;
buffer[2]|=((Font_Buf[2]&0x08)?1:0)<<6;
buffer[2]|=((Font_Buf[4]&0x02)?1:0)<<5;
buffer[2]|=((Font_Buf[7]&0x80)?1:0)<<4;
buffer[2]|=((Font_Buf[9]&0x20)?1:0)<<3;
buffer[2]|=((Font_Buf[11]&0x08)?1:0)<<2;
buffer[2]|=((Font_Buf[13]&0x02)?1:0)<<1;
buffer[2]|=(Font_Buf[16]&0x80)?1:0;
buffer[3]|=((Font_Buf[0]&0x10)?1:0)<<7;
buffer[3]|=((Font_Buf[2]&0x04)?1:0)<<6;
buffer[3]|=((Font_Buf[4]&0x01)?1:0)<<5;
buffer[3]|=((Font_Buf[7]&0x40)?1:0)<<4;
buffer[3]|=((Font_Buf[9]&0x10)?1:0)<<3;
buffer[3]|=((Font_Buf[11]&0x04)?1:0)<<2;
buffer[3]|=((Font_Buf[13]&0x01)?1:0)<<1;
buffer[3]|=(Font_Buf[16]&0x40)?1:0;
buffer[4]|=((Font_Buf[0]&0x08)?1:0)<<7;
buffer[4]|=((Font_Buf[2]&0x02)?1:0)<<6;
buffer[4]|=((Font_Buf[5]&0x80)?1:0)<<5;
buffer[4]|=((Font_Buf[7]&0x20)?1:0)<<4;
buffer[4]|=((Font_Buf[9]&0x08)?1:0)<<3;
buffer[4]|=((Font_Buf[11]&0x02)?1:0)<<2;
buffer[4]|=((Font_Buf[14]&0x80)?1:0)<<1;
buffer[4]|=(Font_Buf[16]&0x20)?1:0;
buffer[5]|=((Font_Buf[0]&0x04)?1:0)<<7;
buffer[5]|=((Font_Buf[2]&0x01)?1:0)<<6;
buffer[5]|=((Font_Buf[5]&0x40)?1:0)<<5;
buffer[5]|=((Font_Buf[7]&0x10)?1:0)<<4;
buffer[5]|=((Font_Buf[9]&0x04)?1:0)<<3;
buffer[5]|=((Font_Buf[11]&0x01)?1:0)<<2;
buffer[5]|=((Font_Buf[14]&0x40)?1:0)<<1;
buffer[5]|=(Font_Buf[16]&0x10)?1:0;
buffer[6]|=((Font_Buf[0]&0x02)?1:0)<<7;
buffer[6]|=((Font_Buf[3]&0x80)?1:0)<<6;
buffer[6]|=((Font_Buf[5]&0x20)?1:0)<<5;
buffer[6]|=((Font_Buf[7]&0x08)?1:0)<<4;
buffer[6]|=((Font_Buf[9]&0x02)?1:0)<<3;
buffer[6]|=((Font_Buf[12]&0x80)?1:0)<<2;
buffer[6]|=((Font_Buf[14]&0x20)?1:0)<<1;
buffer[6]|=(Font_Buf[16]&0x08)?1:0;
buffer[7]|=((Font_Buf[0]&0x01)?1:0)<<7;
buffer[7]|=((Font_Buf[3]&0x40)?1:0)<<6;
buffer[7]|=((Font_Buf[5]&0x10)?1:0)<<5;
buffer[7]|=((Font_Buf[7]&0x04)?1:0)<<4;
buffer[7]|=((Font_Buf[9]&0x01)?1:0)<<3;
buffer[7]|=((Font_Buf[12]&0x40)?1:0)<<2;
buffer[7]|=((Font_Buf[14]&0x10)?1:0)<<1;
buffer[7]|=(Font_Buf[16]&0x04)?1:0;
buffer[8]|=((Font_Buf[1]&0x80)?1:0)<<7;
buffer[8]|=((Font_Buf[2]&0x20)?1:0)<<6;
buffer[8]|=((Font_Buf[5]&0x08)?1:0)<<5;
buffer[8]|=((Font_Buf[7]&0x02)?1:0)<<4;
buffer[8]|=((Font_Buf[10]&0x80)?1:0)<<3;
buffer[8]|=((Font_Buf[12]&0x20)?1:0)<<2;
buffer[8]|=((Font_Buf[14]&0x08)?1:0)<<1;
buffer[8]|=(Font_Buf[16]&0x02)?1:0;
buffer[9]|=((Font_Buf[1]&0x40)?1:0)<<7;
buffer[9]|=((Font_Buf[2]&0x10)?1:0)<<6;
buffer[9]|=((Font_Buf[5]&0x04)?1:0)<<5;
buffer[9]|=((Font_Buf[7]&0x01)?1:0)<<4;
buffer[9]|=((Font_Buf[10]&0x40)?1:0)<<3;
buffer[9]|=((Font_Buf[12]&0x10)?1:0)<<2;
buffer[9]|=((Font_Buf[14]&0x04)?1:0)<<1;
buffer[9]|=(Font_Buf[16]&0x01)?1:0;
buffer[10]|=((Font_Buf[1]&0x20)?1:0)<<7;
buffer[10]|=((Font_Buf[3]&0x08)?1:0)<<6;
buffer[10]|=((Font_Buf[5]&0x02)?1:0)<<5;
buffer[10]|=((Font_Buf[8]&0x80)?1:0)<<4;
buffer[10]|=((Font_Buf[10]&0x20)?1:0)<<3;
buffer[10]|=((Font_Buf[12]&0x08)?1:0)<<2;
buffer[10]|=((Font_Buf[14]&0x02)?1:0)<<1;
buffer[10]|=(Font_Buf[17]&0x80)?1:0;
buffer[11]|=((Font_Buf[1]&0x10)?1:0)<<7;
buffer[11]|=((Font_Buf[3]&0x04)?1:0)<<6;
buffer[11]|=((Font_Buf[5]&0x01)?1:0)<<5;
buffer[11]|=((Font_Buf[8]&0x40)?1:0)<<4;
buffer[11]|=((Font_Buf[10]&0x10)?1:0)<<3;
buffer[11]|=((Font_Buf[12]&0x04)?1:0)<<2;
buffer[11]|=((Font_Buf[14]&0x01)?1:0)<<1;
buffer[11]|=(Font_Buf[17]&0x40)?1:0;
buffer[12]|=((Font_Buf[1]&0x08)?1:0)<<7;
buffer[12]|=((Font_Buf[3]&0x02)?1:0)<<6;
buffer[12]|=((Font_Buf[6]&0x80)?1:0)<<5;
buffer[12]|=((Font_Buf[8]&0x20)?1:0)<<4;
buffer[12]|=((Font_Buf[10]&0x08)?1:0)<<3;
buffer[12]|=((Font_Buf[12]&0x02)?1:0)<<2;
buffer[12]|=((Font_Buf[13]&0x04)?1:0)<<1;
buffer[12]|=(Font_Buf[17]&0x20)?1:0;
buffer[13]|=((Font_Buf[1]&0x04)?1:0)<<7;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -