📄 main.lst
字号:
296 1 ChangeHexToDbb(tmpData,CommArray,13);
297 1
298 1 for(i = 0; i < 27; i++)
299 1 {
300 2 SoftUART_PutByte(CommArray[i]);
301 2 }
302 1
303 1 //--------------------------------------------------------------------
C51 COMPILER V7.50 MAIN 08/29/2005 14:36:53 PAGE 6
304 1 // Right: 0x60 0x11 DATA0 … DATA15 0x00 BCC 0x03
305 1 // recieve 41 byte 20 * 2 + 1 = 41
306 1 // Error: 0x60 0x01 ERRNO BCC 0x03
307 1 // recieve 9 byte 4 * 2 + 1 = 9
308 1 //--------------------------------------------------------------------
309 1
310 1 for(i = 0; i < 41; i++)
311 1 {
312 2 CommArray[i] = SoftUART_GetByte();
313 2 if(CommArray[i] == 0x03) break;
314 2 }
315 1
316 1 if(CommArray[0] != '6') return 1;
317 1 if(i < 10) return 1;
318 1
319 1 ChangeDbbToHex(&CommArray[4],tmpData,32);
320 1
321 1 for(i = 0; i < 16; i++) CardData[i] = tmpData[i];
322 1
323 1 //--------------------------------------------------------------------
324 1
325 1 return 0;
326 1
327 1 }
328
329 BYTE WriteCard(BYTE BlockNo,BYTE KeyType,BYTE *CardKey,BYTE *CardData)
330 {
331 1 BYTE i;
332 1
333 1 //--------------------------------------------------------------------
334 1 // Command: 0x60 0x1A 0x01 0x63 KEYTYPE BlockNo KEY0 … KEY5 DATA0 … DATA15 BCC 0x03
335 1 // send 59 byte 29 * 2 + 1 = 59
336 1 //--------------------------------------------------------------------
337 1
338 1 tmpData[0] = 0x60;
339 1 tmpData[1] = 0x1A;
340 1 tmpData[2] = 0x01;
341 1 tmpData[3] = 0x63;
342 1 tmpData[4] = KeyType;
343 1 tmpData[5] = BlockNo;
344 1 for(i = 0; i < 6; i++) tmpData[6 + i] = CardKey[i];
345 1 for(i = 0; i < 16; i++) tmpData[12 + i] = CardData[i];
346 1
347 1 tmpData[28] = XORCheck(tmpData,28);
348 1
349 1 ChangeHexToDbb(tmpData,CommArray,29);
350 1
351 1 for(i = 0; i < 59; i++)
352 1 {
353 2 SoftUART_PutByte(CommArray[i]);
354 2 }
355 1
356 1 //--------------------------------------------------------------------
357 1 // Right: 0x60 0x01 0x00 BCC 0x03
358 1 // recieve 9 byte 4 * 2 + 1 = 9
359 1 // Error: 0x60 0x01 ERRNO BCC 0x03
360 1 // recieve 9 byte 4 * 2 + 1 = 9
361 1 //--------------------------------------------------------------------
362 1
363 1 for(i = 0; i < 9; i++)
364 1 {
365 2 CommArray[i] = SoftUART_GetByte();
C51 COMPILER V7.50 MAIN 08/29/2005 14:36:53 PAGE 7
366 2 if(CommArray[i] == 0x03) break;
367 2 }
368 1
369 1 if(CommArray[0] != '6') return 1;
370 1
371 1 ChangeDbbToHex(&CommArray[4],tmpData,2);
372 1
373 1 return tmpData[0];
374 1
375 1 //--------------------------------------------------------------------
376 1
377 1 }
378
379 BYTE FormatPurse(BYTE BlockNo,BYTE KeyType,BYTE *CardKey,BYTE *Value)
380 {
381 1 BYTE i;
382 1
383 1 //--------------------------------------------------------------------
384 1 // Command: 0x60 0x0E 0x01 0x64 KEYTYPE BlockNo KEY0 … KEY5 Value0 …Value3 BCC 0x03
385 1 // send 35 byte 17 * 2 + 1 = 35
386 1 //--------------------------------------------------------------------
387 1
388 1 tmpData[0] = 0x60;
389 1 tmpData[1] = 0x0E;
390 1 tmpData[2] = 0x01;
391 1 tmpData[3] = 0x64;
392 1 tmpData[4] = KeyType;
393 1 tmpData[5] = BlockNo;
394 1 for(i = 0; i < 6; i++) tmpData[6 + i] = CardKey[i];
395 1 for(i = 0; i < 4; i++) tmpData[12 + i] = Value[i];
396 1
397 1 tmpData[16] = XORCheck(tmpData,16);
398 1
399 1 ChangeHexToDbb(tmpData,CommArray,17);
400 1
401 1 for(i = 0; i < 35; i++)
402 1 {
403 2 SoftUART_PutByte(CommArray[i]);
404 2 }
405 1
406 1 //--------------------------------------------------------------------
407 1 // Right: 0x60 0x01 0x00 BCC 0x03
408 1 // recieve 9 byte 4 * 2 + 1 = 9
409 1 // Error: 0x60 0x01 ERRNO BCC 0x03
410 1 // recieve 9 byte 4 * 2 + 1 = 9
411 1 //--------------------------------------------------------------------
412 1
413 1 for(i = 0; i < 9; i++)
414 1 {
415 2 CommArray[i] = SoftUART_GetByte();
416 2 if(CommArray[i] == 0x03) break;
417 2 }
418 1
419 1 if(CommArray[0] != '6') return 1;
420 1
421 1 ChangeDbbToHex(&CommArray[4],tmpData,2);
422 1
423 1 return tmpData[0];
424 1
425 1 //--------------------------------------------------------------------
426 1
427 1 }
C51 COMPILER V7.50 MAIN 08/29/2005 14:36:53 PAGE 8
428
429 BYTE Increase(BYTE BlockNo,BYTE KeyType,BYTE *CardKey,BYTE *Value)
430 {
431 1 BYTE i;
432 1
433 1 //--------------------------------------------------------------------
434 1 // Command: 0x60 0x0E 0x01 0x65 KEYTYPE BlockNo KEY0 … KEY5 Value0 …Value3 BCC 0x03
435 1 // send 35 byte 17 * 2 + 1 = 35
436 1 //--------------------------------------------------------------------
437 1
438 1 tmpData[0] = 0x60;
439 1 tmpData[1] = 0x0E;
440 1 tmpData[2] = 0x01;
441 1 tmpData[3] = 0x65;
442 1 tmpData[4] = KeyType;
443 1 tmpData[5] = BlockNo;
444 1 for(i = 0; i < 6; i++) tmpData[6 + i] = CardKey[i];
445 1 for(i = 0; i < 4; i++) tmpData[12 + i] = Value[i];
446 1
447 1 tmpData[16] = XORCheck(tmpData,16);
448 1
449 1 ChangeHexToDbb(tmpData,CommArray,17);
450 1
451 1 for(i = 0; i < 35; i++)
452 1 {
453 2 SoftUART_PutByte(CommArray[i]);
454 2 }
455 1
456 1 //--------------------------------------------------------------------
457 1 // Right: 0x60 0x01 0x00 BCC 0x03
458 1 // recieve 9 byte 4 * 2 + 1 = 9
459 1 // Error: 0x60 0x01 ERRNO BCC 0x03
460 1 // recieve 9 byte 4 * 2 + 1 = 9
461 1 //--------------------------------------------------------------------
462 1
463 1 for(i = 0; i < 9; i++)
464 1 {
465 2 CommArray[i] = SoftUART_GetByte();
466 2 if(CommArray[i] == 0x03) break;
467 2 }
468 1
469 1 if(CommArray[0] != '6') return 1;
470 1
471 1 ChangeDbbToHex(&CommArray[4],tmpData,2);
472 1
473 1 return tmpData[0];
474 1
475 1 //--------------------------------------------------------------------
476 1
477 1 }
478
479 BYTE Decrease(BYTE BlockNo,BYTE KeyType,BYTE *CardKey,BYTE *Value)
480 {
481 1 BYTE i;
482 1
483 1 //--------------------------------------------------------------------
484 1 // Command: 0x60 0x0E 0x01 0x66 KEYTYPE BlockNo KEY0 … KEY5 Value0 …Value3 BCC 0x03
485 1 // send 35 byte 17 * 2 + 1 = 35
486 1 //--------------------------------------------------------------------
487 1
488 1 tmpData[0] = 0x60;
489 1 tmpData[1] = 0x0E;
C51 COMPILER V7.50 MAIN 08/29/2005 14:36:53 PAGE 9
490 1 tmpData[2] = 0x01;
491 1 tmpData[3] = 0x66;
492 1 tmpData[4] = KeyType;
493 1 tmpData[5] = BlockNo;
494 1 for(i = 0; i < 6; i++) tmpData[6 + i] = CardKey[i];
495 1 for(i = 0; i < 4; i++) tmpData[12 + i] = Value[i];
496 1
497 1 tmpData[16] = XORCheck(tmpData,16);
498 1
499 1 ChangeHexToDbb(tmpData,CommArray,17);
500 1
501 1 for(i = 0; i < 35; i++)
502 1 {
503 2 SoftUART_PutByte(CommArray[i]);
504 2 }
505 1
506 1 //--------------------------------------------------------------------
507 1 // Right: 0x60 0x01 0x00 BCC 0x03
508 1 // recieve 9 byte 4 * 2 + 1 = 9
509 1 // Error: 0x60 0x01 ERRNO BCC 0x03
510 1 // recieve 9 byte 4 * 2 + 1 = 9
511 1 //--------------------------------------------------------------------
512 1
513 1 for(i = 0; i < 9; i++)
514 1 {
515 2 CommArray[i] = SoftUART_GetByte();
516 2 if(CommArray[i] == 0x03) break;
517 2 }
518 1
519 1 if(CommArray[0] != '6') return 1;
520 1
521 1 ChangeDbbToHex(&CommArray[4],tmpData,2);
522 1
523 1 return tmpData[0];
524 1
525 1 //--------------------------------------------------------------------
526 1
527 1 }
528
529 BYTE ReadPurse(BYTE BlockNo,BYTE KeyType,BYTE *CardKey,BYTE *Balance)
530 {
531 1 BYTE i;
532 1
533 1 //--------------------------------------------------------------------
534 1 // Command: 0x60 0x0A 0x01 0x67 KEYTYPE BlockNo KEY0 … KEY5 BCC 0x03
535 1 // send 27 byte 13 * 2 + 1 = 27
536 1 //--------------------------------------------------------------------
537 1
538 1 tmpData[0] = 0x60;
539 1 tmpData[1] = 0x0A;
540 1 tmpData[2] = 0x01;
541 1 tmpData[3] = 0x67;
542 1 tmpData[4] = KeyType;
543 1 tmpData[5] = BlockNo;
544 1 for(i = 0; i < 6; i++) tmpData[6 + i] = CardKey[i];
545 1
546 1 tmpData[12] = XORCheck(tmpData,12);
547 1
548 1 ChangeHexToDbb(tmpData,CommArray,13);
549 1
550 1 for(i = 0; i < 27; i++)
551 1 {
C51 COMPILER V7.50 MAIN 08/29/2005 14:36:53 PAGE 10
552 2 SoftUART_PutByte(CommArray[i]);
553 2 }
554 1
555 1 //--------------------------------------------------------------------
556 1 // Right: 0x60 0x05 Balance0 …Balance3 0x00 BCC 0x03
557 1 // recieve 17 byte 8 * 2 + 1 = 17
558 1 // Error: 0x60 0x01 ERRNO BCC 0x03
559 1 // recieve 9 byte 4 * 2 + 1 = 9
560 1 //--------------------------------------------------------------------
561 1
562 1 for(i = 0; i < 17; i++)
563 1 {
564 2 CommArray[i] = SoftUART_GetByte();
565 2 if(CommArray[i] == 0x03) break;
566 2 }
567 1
568 1 if(CommArray[0] != '6') return 1;
569 1 if(i < 10) return 1;
570 1
571 1 ChangeDbbToHex(&CommArray[4],tmpData,8);
572 1
573 1 for(i = 0; i < 4; i++) Balance[i] = tmpData[i];
574 1
575 1 //--------------------------------------------------------------------
576 1
577 1 return 0;
578 1 }
579
580 //--------------------------------------------------------------------
581
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1988 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 87
IDATA SIZE = 96 16
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -