📄 commtran.lst
字号:
771 3 }
772 2 if(key_index==0)
773 2 {
774 3 SendResponse(COS_CLA_ERROR,1,buf);
775 3 }
776 2
777 2 len_index=ComBuffer[1]-1;
778 2 memset(buf,0x00,16);
779 2 memset(buf2,0x00,16);
780 2 i=0;
781 2 while(len_index>13)
782 2 {
783 3
784 3 buf[0]=0x12|Block_Index;
785 3 memcpy(buf+1,ComBuffer+3+i,13);
C51 COMPILER V4.01, COMMTRAN 19/08/04 14:33:24 PAGE 13
786 3 Status=Mf500PiccExchangeBlock(buf,16,buf2, &rec_bytelen, 1,5);
787 3 if(Status!=MI_OK)
788 3 {
789 4 SendResponse(0x80,1,buf);
790 4 return;
791 4 }
792 3 memset(buf2,0x00,16);
793 3 memset(buf,0x00,16);
794 3 len_index-=13;
795 3 i+=13;
796 3 }
797 2 buf[0]=0x02|Block_Index;
798 2 memcpy(buf+1,ComBuffer+3+i,len_index);
799 2 Status=Mf500PiccExchangeBlock(buf,len_index+3,buf2, &rec_bytelen,1, 5);
800 2
801 2 if(Status!=MI_OK)
802 2 {
803 3 SendResponse(0x80,1,buf);
804 3 return;
805 3 }
806 2
807 2 len_index=0;
808 2 while((buf2[0]==0x12)||(buf2[0]==0x13))
809 2 {
810 3 memcpy(ComBuffer+9+2+len_index,buf2+1,13);
811 3 len_index+=13;
812 3 memset(buf2,0xff,16); //2004.4.2
813 3 buf[0]=0xa2|Block_Index;
814 3 memset(buf2,0xff,16);
815 3 Status=Mf500PiccExchangeBlock(buf,3,buf2, &rec_bytelen,1, 5);
816 3 if(Status!=MI_OK)
817 3 {
818 4 SendResponse(0x80,1,buf);
819 4 return;
820 4 }
821 3 }
822 2 memset(buf,0xff,25);
823 2 //memcpy(buf,buf2,rec_bytelen);
824 2 if(rec_bytelen<5)
825 2 {
826 3 if((buf2[1]==0x00)&&(ComBuffer[9+2+len_index-1]==0x90))
827 3 {
828 4 sw1=0x90;
829 4 sw2=0x00;
830 4 ComBuffer[7+2]=sw1;
831 4 ComBuffer[8+2]=sw2;
832 4 SendResponse(0x01,len_index-1+3+17,buf);
833 4 return;
834 4 }
835 3 }
836 2 k=0;
837 2 j=0;
838 2 for(i=1;i<13;i++)
839 2 {
840 3 if((buf2[i]==0x90)&&(buf2[i+1]==0x00))
841 3 {
842 4 k=i;
843 4 j=1;
844 4 }
845 3 }
846 2 if(j==1)
847 2 {
848 3 i=k;
849 3 j=0;
850 3 }
851 2
C51 COMPILER V4.01, COMMTRAN 19/08/04 14:33:24 PAGE 14
852 2 if(i<13)
853 2 {
854 3 sw1=0x90;
855 3 sw2=0x00;
856 3 i--;
857 3 ComBuffer[7+2]=sw1;
858 3 ComBuffer[8+2]=sw2;
859 3 memcpy(ComBuffer+9+2+len_index,buf2+1,i);
860 3 len_index+=i;
861 3 }
862 2 else
863 2 {
864 3 sw1=buf2[1];
865 3 sw2=buf2[2];
866 3 ComBuffer[7+2]=sw1;
867 3 ComBuffer[8+2]=sw2;
868 3 len_index=0;
869 3 }
870 2 SendResponse(0x01,len_index+3+17,buf);
871 2 break;
872 2
873 2 case 0x58: //close card for pro
874 2 Status=deselect();
875 2 if(Status==MI_OK)
876 2 {
877 3 SendResponse(0x01,1,buf);
878 3 }
879 2 else
880 2 {
881 3 Status=deselect();
882 3 if(Status==MI_OK)
883 3 {
884 4 SendResponse(0x01,1,buf);
885 4 }
886 3 else SendResponse(0x80,1,buf);
887 3 }
888 2
889 2 break;
890 2 /**************************************************************************************/
891 2 case 0x98: //T=0; for hihgspeed sam card
892 2 W_DOG();
893 2 switch(ComBuffer[3])//check message's head
894 2 {
895 3 case 0x00:
896 3 case 0x04:
897 3 case 0x80:
898 3 case 0x84:
899 3 case 0xe0:
900 3 key_index=1; break;
901 3 default:
902 3 key_index=0;
903 3 }
904 2 if(key_index==0)
905 2 {
906 3 SendResponse(COS_CLA_ERROR,1,buf);
907 3 }
908 2 if(ComBuffer[1]==6)
909 2 {
910 3 len_index=1;
911 3 }
912 2 else len_index=0;
913 2
914 2 IO1=1;
915 2
916 2 len_x=ComBuffer[7]+2;
917 2 len_y=ComBuffer[4];
C51 COMPILER V4.01, COMMTRAN 19/08/04 14:33:24 PAGE 15
918 2 i=0;
919 2
920 2 I_send(ComBuffer[3]);
921 2 I_send(ComBuffer[4]);
922 2 I_send(ComBuffer[5]);
923 2 I_send(ComBuffer[6]);
924 2 I_send(ComBuffer[7]);
925 2
926 2 if(len_index==1)
927 2 {
928 3 sw1=I_receive();
929 3 if(sw1!=len_y)
930 3 {
931 4 sw2=I_receive();
932 4 buf[0]=sw1;
933 4 buf[1]=sw2;
934 4 SendResponse(0x01,3,buf);
935 4 return;
936 4 }
937 3
938 3 while(i<len_x)
939 3 {
940 4 CosBuffer[i]=I_receive();
941 4 i++;
942 4 }
943 3 memcpy(ComBuffer+9,CosBuffer,len_x);
944 3 SendResponse(0x01,i+1+17,buf);
945 3 return;
946 3 }
947 2
948 2 sw1=I_receive();
949 2 for(i=0;i<120;i++)
950 2 {
951 3 ;
952 3 }
953 2
954 2 IO1=1;
955 2 for(i=8;i<(ComBuffer[1]+2);i++)
956 2 {
957 3 I_send(ComBuffer[i]);
958 3 }
959 2
960 2 sw1=I_receive();
961 2 sw2=I_receive();
962 2 if(sw1!=0x61)
963 2 {
964 3 buf[0]=sw1;
965 3 buf[1]=sw2;
966 3 SendResponse(0x01,3,buf);
967 3 return;
968 3 }
969 2
970 2 for(i=0;i<60;i++)
971 2 {
972 3 ;
973 3 }
974 2
975 2 IO1=1;
976 2 len_y=sw2+2;
977 2 i=0;
978 2 I_send(0x00);
979 2 I_send(0xc0);
980 2 I_send(0x00);
981 2 I_send(0x00);
982 2 I_send(sw2);
983 2
C51 COMPILER V4.01, COMMTRAN 19/08/04 14:33:24 PAGE 16
984 2 sw1=I_receive();
985 2 while(i<len_y)
986 2 {
987 3 CosBuffer[i]=I_receive();
988 3 i++;
989 3 }
990 2 memcpy(ComBuffer+9,CosBuffer,len_y);
991 2 SendResponse(0x01,1+len_y+17,buf);
992 2
993 2 break;
994 2
995 2 /************************************************************/
996 2 case 0x99: //RESET SAM CARD
997 2 Reset1();
998 2 i=0;
999 2 while(1)
1000 2 {
1001 3 Status=I_receive1(ComBuffer+9+i);
1002 3 if(Status) break;
1003 3 i++;
1004 3 }
1005 2 if(i<5) //look as error
1006 2 {
1007 3 SendResponse(0x80,1+i+17,buf);
1008 3 return;
1009 3 }
1010 2 SendResponse(0x01,1+i+17,buf);
1011 2 break;
1012 2 /********************************************************************************/
1013 2 case 0x72: //T=0; T=1; IC COMMAND
1014 2 W_DOG();
1015 2 cardsequ=select_sen_refunc();
1016 2 ICProtol=ComBuffer[3+2];
1017 2
1018 2 if(ICProtol!=0x01)
1019 2 {
1020 3 switch(ComBuffer[4+2]) //check message's head
1021 3 {
1022 4 case 0x00:
1023 4 case 0x04:
1024 4 case 0x80:
1025 4 case 0x84:
1026 4 case 0xA0:
1027 4 case 0xe0:
1028 4 key_index=1; break;
1029 4 default:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -