📄 sim.lst
字号:
1055 3 if(statecode==0x6A83)
1056 3 {
1057 4 LcdDisplay(16,0,"未找到对应信息!",1);
1058 4 Hint(32,0,"非本机用户卡!",1);
1059 4 return 0;
1060 4 }
1061 3 for(i=0;i<8;i++)
1062 3 if(RxdBuf[i] != dat[i])
1063 3 {
1064 4 k=1;break;
1065 4 }
1066 3 if(k==0)return 1;
1067 3 else {j++;k=0;}
1068 3 }
1069 2 }
1070 1 else
1071 1 {
1072 2 I2cRead(TaxpayerNo,8,RxdBuf);
1073 2 for(i=0;i<8;i++) //比较纳税人编码
1074 2 if(RxdBuf[i] != dat[i])
1075 2 {
1076 3 LcdDisplay(16,0,"纳税人编码不一致!",1);
1077 3 LcdDisplay(32,0,"非本机用户卡!",1);
1078 3 return 0;
1079 3 }
1080 2 }
1081 1 return 1;
1082 1 }
1083
1084 uchar FiscalIdentify(uchar x)
1085 {
1086 1 uchar i,dat[10];
1087 1
1088 1 I2cRead(MachineNo,8,dat);
1089 1 SimRstCold(0);
1090 1 RxdBuf[0]=0x2F;
1091 1 RxdBuf[1]=0x02;
1092 1 SelectFile(0x00,0x00,0x02,RxdBuf,0);
1093 1 ReadBinary(0x82,0,18,0); //读取机器编号
1094 1
1095 1 if(RxdBuf[0]!=0)
1096 1 {
1097 2 LcdDisplay(16,0,"没有检测到税控卡!",3);
1098 2 Hint(32,0,"请检查卡的类型是否正确!",1);
1099 2 return 0;
1100 2 }
1101 1
1102 1 for(i=0;i<8;i++) //比较机器编号
1103 1 if(dat[i]!=RxdBuf[i+10]) //多一个返回的命令字
1104 1 {
1105 2 LcdDisplay(16,0,"机器编号不一致!",3);
1106 2 LcdDisplay(32,0,"非本机税控卡!",0);
C51 COMPILER V8.01 SIM 03/28/2006 09:48:50 PAGE 19
1107 2 return 0;
1108 2 }
1109 1 if(x==0)
1110 1 {
1111 2 if(RxdBuf[1]==0)
1112 2 {//卡已经注册
1113 3 LcdDisplay(16,0,"本税控卡已经注册!",3);
1114 3 LcdDisplay(32,0,"不能再次注册!",0);
1115 3 return 0;
1116 3 }
1117 2 }
1118 1 else
1119 1 {
1120 2 if(RxdBuf[1]==1)
1121 2 {//卡没有注册
1122 3 LcdDisplay(16,0,"本税控卡没有注册!",3);
1123 3 return 0;
1124 3 }
1125 2 }
1126 1 return 1;
1127 1 }
1128
1129 uchar UpdataUser()
1130 {
1131 1 // gyt2 *xp;
1132 1 uchar n=0x50;
1133 1
1134 1 // UserIdentify(1);
1135 1 // RxdBuf[0]=0xEF;
1136 1 // RxdBuf[1]=0x08;
1137 1 // SelectFile(0x00,0x00,0x02,RxdBuf,1);
1138 1 // ReadBinary(0x88,0,2,1);
1139 1 // if(xp->dat!=0xFFFF)
1140 1 // {
1141 1 // xp=&RxdBuf[1];
1142 1 // n=xp->dat*2+2;
1143 1 // if(n>0x50)n=0x50;
1144 1 // }
1145 1 // else n=0x50;
1146 1 ReadBinary(0x88,0,n,1);
1147 1 I2cWrite(MultiUserInfo,n,RxdBuf);
1148 1 return 1;
1149 1 }
1150
1151 uchar UpdateTaxIndex()
1152 {
1153 1 uint adr;
1154 1 uchar i,j,dat[50],str[8];
1155 1
1156 1 RxdBuf[0]=0xEF;
1157 1 RxdBuf[1]=0x03;
1158 1 SelectFile(0x00,0x00,0x02,RxdBuf,1);
1159 1 adr=TaxItemsIndex;
1160 1 for(i=0;i<6;i++)
1161 1 {//读出税种税目索引文件并写入Flash
1162 2 j=ReadRecord(0,i+1,0x04,47,1);
1163 2 str[i]=RxdBuf[0];
1164 2 for(j=0;j<47;j++)dat[j]=RxdBuf[j];
1165 2 I2cWrite(adr,47,dat);
1166 2 adr+=47;
1167 2 }
1168 1 I2cWrite(IntradayIndex,6,str); //日缓冲区税种税目索引号
C51 COMPILER V8.01 SIM 03/28/2006 09:48:50 PAGE 20
1169 1 I2cWrite(DecTaxIndex,6,str); //申报数据缓冲区税种税目索引号
1170 1 I2cWrite(IndexItems,6,str);
1171 1 return 1;
1172 1 }
1173
1174 uchar UpdateControls()
1175 {//MAC2是从用户卡中读出的
1176 1 uint statecode;
1177 1 uchar i,j,k,dat[30],str[8];
1178 1 bit flg;
1179 1 //---------------------------------------------------------------------------------------------
1180 1 ReadBinary(0x82,57,40,0); //检查纳税人单位名称是否一致
1181 1 for(i=0;i<40;i++)dat[i]=RxdBuf[i];
1182 1 RxdBuf[0]=0xEF;
1183 1 RxdBuf[1]=0x02;
1184 1 SelectFile(0x00,0x00,0x02,RxdBuf,1);
1185 1 ReadBinary(0x82,21,40,1);
1186 1 flg=0;
1187 1 for(i=0;i<40;i++)
1188 1 {
1189 2 if(dat[i]!=RxdBuf[i])flg=1;
1190 2 break;
1191 2 }
1192 1 if(flg==0)
1193 1 I2cWrite(TaxpayerName,40,dat); //如果一致,更新纳税人单位名称
1194 1 //-----------------------------------------------------------------------------------------
1195 1 if(PwrFlg!=0)while(1);
1196 1 UpdateTaxIndex(); //考虑拔卡,则本部分应该在发送完税命令前进行
1197 1 //-----------------------------------------------------------------------------------------
1198 1 if(PwrFlg!=0)while(1);
1199 1 //查找与本机税控卡对应的数据文件
1200 1 // ReadBinary(0x82,2,8,0);
1201 1 // for(i=0;i<8;i++)str[i]=RxdBuf[i];
1202 1 I2cRead(FiscalCardNo,8,str);
1203 1 j=1;k=0;
1204 1 while(1)
1205 1 {
1206 2 statecode=ReadRecord(0,j,0x0C,37,1); //读取用户卡的税控卡编号
1207 2 if(statecode==0x6A83)
1208 2 {
1209 3 LcdDisplay(16,0,"未找到对应信息!",1);
1210 3 LcdDisplay(32,0,"非本机用户卡!",1);
1211 3 return 0;
1212 3 }
1213 2 for(i=0;i<8;i++)
1214 2 if(RxdBuf[i] != str[i])
1215 2 {
1216 3 k=1;
1217 3 }
1218 2 if(k==0)break;
1219 2 else {j++;k=0;}
1220 2 }
1221 1 for(i=0;i<29;i++)dat[i]=RxdBuf[i+8];
1222 1 //------------------------------------------------------------------------------
1223 1 if(PwrFlg!=0)while(1);
1224 1 RxdBuf[0]=0xEF;
1225 1 RxdBuf[1]=0x01;
1226 1 SelectFile(0x00,0x00,0x02,RxdBuf,0);
1227 1 if(PwrFlg!=0)while(1);
1228 1 VerifyFiscalPin();
1229 1
1230 1 TxdBuf[0]=0xC0; //UpdateControls
C51 COMPILER V8.01 SIM 03/28/2006 09:48:50 PAGE 21
1231 1 TxdBuf[1]=0xF6;
1232 1 TxdBuf[2]=0x00;
1233 1 TxdBuf[3]=0x00;
1234 1 TxdBuf[4]=0x1D; //29
1235 1 for(i=0;i<0x1D;i++)
1236 1 TxdBuf[5+i]=dat[i]; //0x1D+5=34
1237 1 statecode=SimCmd(34,0);
1238 1 if(statecode != 0x9000)
1239 1 {
1240 2 if(statecode==0x9303)AppBlockHint(0,1);
1241 2 ErrorHint("税控卡监控数据更新出错!",statecode);
1242 2 } //读取税种税目索引号、明细申报标志与税控码密钥标识符共23字节
1243 1 ReadBinary(0x81,0,23,0); //读取开票截止日期、单张发票金额限额、发票累计金额限额、退票累计金额限额
1244 1 for(i=0;i<23;i++)
1245 1 dat[i]=RxdBuf[i];
1246 1 I2cWrite(InvoiceEndData,23,dat);
1247 1 // ReadBinary(0x82,46,8,0); //需要更新吗?
1248 1 // for(i=0;i<8;i++)dat[i]=RxdBuf[i];
1249 1 // I2cWrite(AppStartTime,8,dat); //更新应用启用日期、应用有效日期
1250 1 dat[0]=0;
1251 1 I2cWrite(DeclareFlg,1,dat); //更新报税标志
1252 1 return 1;
1253 1 }
1254
1255 void FiscalCashRegisterIni()
1256 {
1257 1 uchar i,dat[20],str[120];
1258 1 uint statecode;
1259 1
1260 1 //----------------------------------------------------------------------------
1261 1 UpdateTaxIndex();
1262 1 UpdataUser();
1263 1 //----------------------------------------------------------------------------
1264 1
1265 1 TxdBuf[0]=0xC0;
1266 1 TxdBuf[1]=0xF0; //GET_REGISTER_NB
1267 1 TxdBuf[2]=0x00;
1268 1 TxdBuf[3]=0x00;
1269 1 TxdBuf[4]=0x10;
1270 1 statecode=SimCmd(5,0); //向税控卡发送
1271 1 if(statecode != 0x9000)
1272 1 {
1273 2 if(statecode==0x9303)AppBlockHint(0,1);
1274 2 ErrorHint("取税控卡编号出错!",statecode);
1275 2 }
1276 1 for(i=0;i<16;i++)dat[i]=RxdBuf[i];
1277 1 if(PwrFlg!=0)while(1);
1278 1 RxdBuf[0]=0xEF;
1279 1 RxdBuf[1]=0x01;
1280 1 SelectFile(0x00,0x00,0x02,RxdBuf,1);
1281 1 if(PwrFlg!=0)while(1);
1282 1 TxdBuf[0]=0xC0;
1283 1 TxdBuf[1]=0xE4; //REGISTER_SIGN
1284 1 TxdBuf[2]=0x00;
1285 1 TxdBuf[3]=0x00;
1286 1 TxdBuf[4]=0x10;
1287 1 for(i=0;i<16;i++)
1288 1 TxdBuf[5+i]=dat[i];
1289 1 TxdBuf[21]=0x04;
1290 1 statecode=SimCmd(22,1);
1291 1 if(statecode != 0x6104)
1292 1 {
C51 COMPILER V8.01 SIM 03/28/2006 09:48:50 PAGE 22
1293 2 if(statecode==0x9303)AppBlockHint(1,1);
1294 2 ErrorHint("注册签字错误!",statecode);
1295 2 }
1296 1 statecode=GetResponse(4,1);
1297 1 if(statecode != 0x9000)
1298 1 {
1299 2 ErrorHint("返回MAC2出错!",statecode);
1300 2 }
1301 1 for(i=0;i<4;i++)dat[i]=RxdBuf[i];
1302 1 if(PwrFlg!=0)while(1);
1303 1 TxdBuf[0]=0xC0;
1304 1 TxdBuf[1]=0xF1; //TERMINAL_REGISTER
1305 1 TxdBuf[2]=0;
1306 1 TxdBuf[3]=0;
1307 1 TxdBuf[4]=0x04;
1308 1 for(i=0;i<4;i++)
1309 1 TxdBuf[5+i]=dat[i];
1310 1 statecode=SimCmd(9,0); //天喻
1311 1 if(statecode != 0x6108)
1312 1 {
1313 2 if(statecode==0x9303)AppBlockHint(0,1);
1314 2 ErrorHint("结束注册出错!",statecode);
1315 2 }
1316 1 statecode=GetResponse(8,0);
1317 1 if(statecode != 0x9000)
1318 1 {
1319 2 ErrorHint("获取使用口令出错!",statecode);
1320 2 }
1321 1 for(i=0;i<8;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -