电子钱包初始化程序。
Card_Data2[17] 要写入数据的数组缓冲
Section 要进行电子钱包初始化的块区- memset(Card_Data2,0,17);
- Card_Data2[15] = ~0x05;
- Card_Data2[14] = 0x05;
- Card_Data2[13] = ~0x05;
- Card_Data2[12] = 0x05;
- Card_Data2[4] = 0XFF;
- Card_Data2[5] = 0XFF;
- Card_Data2[6] = 0XFF;
- Card_Data2[7] = 0XFF;
- status = PcdWrite(Section*4+1,Card_Data2); //写入0XAA,0X01,0X01……
- 电子钱包充值
- Last_Money_Vual[4] 充值前电子钱包的数值
- Money_Vual[4] 要充值的充值数值
- Now_Money_Vual[4] 充值后的钱包数值
- status = PcdRead(Section*4+1,Card_Data2);
- if(status == MI_OK)
- {
- Last_Money_Vual[0]= Card_Data2[3];
- Last_Money_Vual[1]= Card_Data2[2];
- Last_Money_Vual[2]= Card_Data2[1];
- Last_Money_Vual[3]= Card_Data2[0];
- status = PcdValue (0xc1,Section*4+1,Money_Vual); 主要操作 (充值)
- if(status == MI_OK)
- {
- status = PcdRead(Section*4+1,Card_Data2); //再一次把它读取出来16字节的卡片数据
- if(status == MI_OK)
- {
- Now_Money_Vual[0]= Card_Data2[3];
- Now_Money_Vual[1]= Card_Data2[2];
- Now_Money_Vual[2]= Card_Data2[1];
- Now_Money_Vual[3]= Card_Data2[0];
-
- }
- }
- }
- 电子钱包扣款
- Last_Money_Vual[4] 充值前电子钱包的数值
- Money_Vual[4] 要充值的充值数值
- Now_Money_Vual[4] 充值后的钱包数值
- status = PcdRead(Section*4+1,Card_Data2);
- if(status == MI_OK)
- {
- Last_Money_Vual[0]= Card_Data2[3];
- Last_Money_Vual[1]= Card_Data2[2];
- Last_Money_Vual[2]= Card_Data2[1];
- Last_Money_Vual[3]= Card_Data2[0];
- status = PcdValue (0xc0,Section*4+1,Money_Vual); 主要操作(扣款)
- if(status == MI_OK)
- {
- status = PcdRead(Section*4+1,Card_Data2); //再一次把它读取出来16字节的卡片数据
- if(status == MI_OK)
- {
- Now_Money_Vual[0]= Card_Data2[3];
- Now_Money_Vual[1]= Card_Data2[2];
- Now_Money_Vual[2]= Card_Data2[1];
- Now_Money_Vual[3]= Card_Data2[0];
-
- }
- }
- }
|