zoukankan      html  css  js  c++  java
  • T5557 读写卡详解

    T5557的基本信息就不在这里详细介绍,不了解的可以去看T5557的收据手册。

    一上来直接开始讲操作

     存在七种操作,我们重点介绍四种,Standard Write,Protected Write,Direct access(PWD = 0)和Direct access(PWD = 1)。

    Standard Write和Direct access(PWD = 0)在T5557卡没有设置密码模式(Page0的Block0的第28位PWD设置为0)的时候使用,此为无密码模式,修改卡内的数据无需任何权限。

    Protected Write和Direct access(PWD = 1)在T5557卡密码模式Page0的Block0的第28位PWD设置为1)下使用,此为有密码模式,修改卡内数据需要验证密码的正确性。

    下面将详细介绍用白卡完成以上的四种操作。

    拿到白卡的第一步是配置Page0的Block0配置寄存器(Mode Register)详见Figure 3,默认值为‘00 08 80 E8’h,表示RF/32、曼彻斯特编码,无密码模式。

    需要将模式寄存器的修改为‘00 14 80 00’h,表示RF/64、曼彻斯特编码。如需设置密码求将第28位设置为1。

    初始化函数如下:

    void Card_initialization()//初始化卡片
    {
    Start_Gap();
    SendOpcode(StandardWrite10); //10 2
    SendLock(LOCK00); //0 1
    SendByte(InitT55xxDataArr[0]); // 4
    SendByte(InitT55xxDataArr[1]); // 4
    SendByte(InitT55xxDataArr[2]); // 4
    SendByte(InitT55xxDataArr[3]); // 4
    SendAddress(BLOCK0);
    }

    Standard Write:

    ///////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////
    // 函数名: Standard_Write_T5577(uchar lock,uchar opcode,uchar data_arr[4],uchar block)
    // 参 数: lock为要发送的锁定位,block为待写入数据的块编号数 ,opcode为待发送的操作码,data_arr[4]为要发送的4字节数据
    void Standard_Write_T5577(unsigned char opcode,unsigned char lock,unsigned char data_arr[4],unsigned char block)
    {
    Start_Gap();
    SendOpcode(opcode); //10 2
    SendLock(lock); //0 1
    SendByte(data_arr[0]); // 4
    SendByte(data_arr[1]); // 4
    SendByte(data_arr[2]); // 4
    SendByte(data_arr[3]); // 4
    SendAddress(block); // 3
    }

    Protected Write:

    void Protect_Write_T5577(unsigned char opcode,unsigned char lock,unsigned char data_arr[4],unsigned char block)
    {
    Start_Gap();
    SendOpcode(opcode); //10 2
    SendPassword();
    SendLock(lock); //0 1
    SendByte(data_arr[0]); // 4
    SendByte(data_arr[1]); // 4
    SendByte(data_arr[2]); // 4
    SendByte(data_arr[3]); // 4
    SendAddress(block); // 3
    }

    Direct access(PWD = 0):

    void Read_0_Page_block(unsigned char block) //块读0页
    {
    Start_Gap();
    SendOpcode(StandardWrite10); //10 2
    SendLock(0X00); //0 1
    SendAddress(block);

    }

    Direct access(PWD = 1):

    void Protect_Read_0_Page_block(unsigned char block) //保护读读0页 此时PWD需要设置为1
    {
    Start_Gap();
    SendOpcode(StandardWrite10); //10 2
    SendPassword(); //此密码根据卡号匹配数据库获得
    SendLock(0X00); //0 1
    SendAddress(block);

    }

  • 相关阅读:
    winform 单选框, 图像控件,图像列表,状态栏,定时器,绘图
    学习资料链接,csdn博客
    c# 基本控件,窗口程序
    Gmap.net 怎么导入离线地图
    修改MFC主窗口界面标题和图标的方法
    vc6.0缓冲区
    vc6.0编译出错,删除多余的文件,清空重新编译
    Tomcat插件与Jetty插件在MyEclipse中的配置
    div里面的内容超出自身高度时,显示省略号
    aptana studio 3 自动换行(无需插件)
  • 原文地址:https://www.cnblogs.com/zhousong918/p/9358376.html
Copyright © 2011-2022 走看看