USB免驱全协议IC卡读写器 QT程序开发

电子说

1.3w人已加入

描述

  读取15693卡,IC读卡器如下入所示:

usb

15693卡片,通常指的是符合ISO/IEC 15693标准的非接触式智能卡或RFID卡。以下是对15693卡片的详细介绍:

一、基本概述
15693卡片是基于ISO/IEC 15693国际标准设计的非接触式智能卡,该标准定义了用于非接触式集成电路卡(即RFID卡)的物理特性、初始化及防冲突方法、传输协议以及传输规范。这种卡片通常用于门禁系统、图书管理、身份识别、物流追踪等多种应用场景。

二、技术特点
工作频率:15693卡片通常工作在13.56MHz的高频频段,这是RFID技术中常用的一个频段,具有较远的读写距离和较高的数据传输速率。
存储容量:根据卡片类型和芯片的不同,15693卡片的存储容量会有所差异。一些卡片可能具有较小的存储容量,如几百字节,而一些高级卡片则可能具有更大的存储容量,以满足更复杂的应用需求。
数据传输:15693卡片采用非接触式的数据传输方式,读写器通过发射电磁波来激活卡片,并与卡片进行数据传输。这种传输方式具有快速、准确、可靠的特点。
安全性:15693卡片通常具有多种安全机制,如密码保护、数据加密等,以确保卡片数据的安全性和完整性。这些安全机制可以有效地防止非法读写和数据篡改。
三、应用场景
门禁系统:15693卡片可以作为门禁系统的身份识别工具,用于控制进出特定区域的权限。
图书管理:在图书馆中,15693卡片可以用于借阅证、读者证等,方便读者借阅图书和管理个人信息。
身份识别:15693卡片还可以用于身份识别,如企业员工证、学生证等,用于验证身份和权限。
物流追踪:在物流领域,15693卡片可以用于追踪货物的运输状态和位置信息,提高物流管理的效率和准确性。
四、市场现状与发展趋势
目前,随着物联网技术的快速发展和普及,15693卡片作为RFID技术的重要组成部分,在各个领域得到了广泛的应用。未来,随着技术的不断进步和应用场景的不断拓展,15693卡片的市场需求将会持续增长。同时,随着人们对数据安全性的要求越来越高,15693卡片的安全机制也将不断完善,以更好地满足市场需求。

综上所述,15693卡片作为一种重要的非接触式智能卡或RFID卡,在各个领域具有广泛的应用前景和发展潜力。

QT小程序页面:

usb

QT代码:

 

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui- >setupUi(this);
}
 
MainWindow::~MainWindow()
{
    delete ui;
}
 
 
void MainWindow::on_pb_beep_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char status;
    status = mypcdbeep(30);
    if(status==0){
    }
    else
    {
        disperrinf(status);
    }
}
 
 
void MainWindow::on_pb_getdevnum_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char devicenumber[4];
    unsigned char status;
    status = mypcdgetdevicenumber(devicenumber);
    if(status==0){
        mypcdbeep(30);
        QMessageBox::information(NULL, "提示", QString::asprintf("设备编号:%03d-%03d-%03d-%03d", devicenumber[0],devicenumber[1],devicenumber[2],devicenumber[3]));
    }
    else
    {
        disperrinf(status);
    }
}
 
 
void MainWindow::on_pb_easyread_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char status;
    unsigned char ctrlword=0x00;    //读任何卡,不需指定卡号,读完后不静止该卡,可赋值NEEDSERIAL及NEEDHALT的组合模式,或为0
    unsigned char afi;
    unsigned char myuid[8];
    unsigned char startblock;
    unsigned char blocknum;
    unsigned char piccdatabuf[255];
 
    ui- >lineEdit_uid- >setText("");
    ui- >plainTextEdit_data- >setPlainText("");
 
    QString afistr=ui- >lineEdit_afi- >text().trimmed();
    if(afistr.length()==2 and checkinput(afistr)){
        bool ok;
        afi=afistr.toInt(&ok,16);
    }else{
        QMessageBox::critical(NULL, "提示","请输入2位16进制AFI!");
        ui- >lineEdit_afi- >setFocus();
        return;
    }
 
    startblock=ui- >spinBox_star- >value();
    blocknum=ui- >spinBox_num- >value();
 
    if(blocknum >12){
        QMessageBox::critical(NULL, "提示","一次最多只能读取12块数据!");
        return;
    }
 
    status = myiso15693readex(ctrlword,afi,startblock,blocknum,myuid,piccdatabuf);
    if(status==0){
        mypcdbeep(30);
        QString uidstr="";
        for(int i=0;i< 8;i++){
            uidstr=uidstr+QString::asprintf("%02X", myuid[i]);
        }
        ui- >lineEdit_uid- >setText(uidstr);
        QString datastr="";
        for(int i=1;i<=piccdatabuf[0];i++){
            datastr=datastr+QString::asprintf("%02X ", piccdatabuf[i]);
        }
        ui- >plainTextEdit_data- >setPlainText(datastr);
        QMessageBox::information(NULL, "提示", "读卡成功,卡片UID:"+uidstr);
    }
    else
    {
        if(status==46){
            QString uidstr="";
            for(int i=0;i< 8;i++){
                uidstr=uidstr+QString::asprintf("%02X", myuid[i]);
            }
            ui- >lineEdit_uid- >setText(uidstr);
            QMessageBox::information(NULL, "提示", "本次读取的块数超过卡片允许的一次读取最多块数,读取卡片UID:"+uidstr);
        }else{
            disperrinf(status);
        }
    }
}
 
 
void MainWindow::on_pb_easywrite_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char status;
    unsigned char ctrlword=0x00;    //读任何卡,不需指定卡号,读完后不静止该卡,可赋值NEEDSERIAL及NEEDHALT的组合模式,或为0
    unsigned char afi=0x00;
    unsigned char myuid[8];
    unsigned char startblock;
    unsigned char blocknum;
    unsigned char piccdatabuf[255];
    unsigned char eachblocksize;
 
    ui- >lineEdit_uid- >setText("");
 
    QString afistr=ui- >lineEdit_afi- >text().trimmed();
    if(afistr.length()==2 and checkinput(afistr)){
        bool ok;
        afi=afistr.toInt(&ok,16);
    }else{
        QMessageBox::critical(NULL, "提示","请输入2位16进制AFI!");
        return;
    }
 
    startblock=ui- >spinBox_star- >value();
    blocknum=ui- >spinBox_num- >value();
 
    if(blocknum >12){
        QMessageBox::critical(NULL, "提示","一次最多只能写12块数据!");
        return;
    }
 
    switch(ui- >comboBox_cardtype- >currentIndex()){
    case 0:
        eachblocksize=4;
        break;
    case 1:
        eachblocksize=8;
        break;
    default:
        eachblocksize=32;
        break;
    }
 
    piccdatabuf[0]=blocknum*eachblocksize;
 
    //检测写卡数据
    QChar ch;
    QString writinf = ui- >plainTextEdit_data- >toPlainText().trimmed();
    QString writinf1 = "";
    int m = 1;
    int n = 0;
    char s;
 
    if(writinf.length()< 1){
        QMessageBox::critical(NULL, "提示", "请输入正确的16进制写卡数据!");
        ui- >plainTextEdit_data- >setFocus();
        return;
    }
 
    ch = writinf.at(0);
    s = writinf.at(0).toLatin1();
    for(int i=0; i< writinf.length() ; i++)
    {
        ch = writinf.at(i);
        s = writinf.at(i).toLatin1();
        if((('0' <= s) && (s <= '9')) || (('A' <= s) && (s <= 'F')) || (('a' <= s) && (s <= 'f')))
        {
            writinf1 += ch;
            n++;
            if(n==2){
                bool ok;
                piccdatabuf[m++] = writinf1.toInt(&ok,16);
                writinf1 = "";
                n = 0;
                if(m >=49){
                    break;
                }
            }
        }
        else if(s == ' '){
 
        }
        else
        {
            QMessageBox::critical(NULL, "提示", "写卡数据错误,请输入正确的16进制数据!");
            ui- >plainTextEdit_data- >setFocus();
            return;
        }
    }
 
    if(m<=piccdatabuf[0]){
        QMessageBox::critical(NULL, "提示", "写卡数据不足,请输入"+QString::asprintf("错误代码:%d", piccdatabuf[0])+"个字节16进制数据!");
        ui- >plainTextEdit_data- >setFocus();
        return;
    }
 
    status = myiso15693writeex(ctrlword,afi,startblock,blocknum,myuid,piccdatabuf);
 
    if(status==0){
        mypcdbeep(30);
        QString uidstr="";
        for(int i=0;i< 8;i++){
            uidstr=uidstr+QString::asprintf("%02X", myuid[i]);
        }
        ui- >lineEdit_uid- >setText(uidstr);
        QMessageBox::information(NULL, "提示", "写卡成功,卡片UID:"+uidstr);
    }
    else
    {
        if(status==45){
            QString uidstr="";
            for(int i=0;i< 8;i++){
                uidstr=uidstr+QString::asprintf("%02X", myuid[i]);
            }
            ui- >lineEdit_uid- >setText(uidstr);
            QMessageBox::information(NULL, "提示", "每块字节数选错,卡片UID:"+uidstr);
        }else{
            disperrinf(status);
        }
    }
}
 
 
void MainWindow::on_pb_search1_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char status;
    unsigned char flags;
    unsigned char afi;
    unsigned char maskuid[8];   //卡号掩码,一般可以不理这个参数
    unsigned char masklen;
    unsigned char uid[9];
 
    ui- >lineEdit_uid- >setText("");
 
    ui- >lineEdit_flags- >setText("36");
    flags=54;
 
    QString afistr=ui- >lineEdit_afi- >text().trimmed();
    if(afistr.length()==2 and checkinput(afistr)){
        bool ok;
        afi=afistr.toInt(&ok,16);
    }else{
        QMessageBox::critical(NULL, "提示","请输入2位16进制AFI!");
        return;
    }
 
    QString masklstr=ui- >lineEdit_masklen- >text().trimmed();
    if(masklstr.length()==2 and checkinput(masklstr)){
        bool ok;
        masklen=masklstr.toInt(&ok,16);
    }else{
        QMessageBox::critical(NULL, "提示","请输入2位16进制掩码长度!");
        return;
    }
 
    status = myiso15693inventory(flags, afi, masklen, maskuid, uid);
    if(status==0){
        mypcdbeep(30);
        ui- >lineEdit_dsfid- >setText(QString::asprintf("%02X", uid[0]));
        QString uidstr="";
        for(int i=1;i< 9;i++){
            uidstr=uidstr+QString::asprintf("%02X", uid[i]);
        }
        ui- >lineEdit_uid- >setText(uidstr);
    }else{
        disperrinf(status);
    }
}
 
 
void MainWindow::on_pb_searchall_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char status;
    unsigned char flags;
    unsigned char afi;
    unsigned char maskuid[8];   //卡号掩码,一般可以不理这个参数
    unsigned char masklen;
    unsigned char uid[9];
    unsigned char revlen[1];
 
    ui- >lineEdit_uid- >setText("");
    ui- >comboBox_uid- >clear();
 
    ui- >lineEdit_flags- >setText("16");
    flags=22;
 
    QString afistr=ui- >lineEdit_afi- >text().trimmed();
    if(afistr.length()==2 and checkinput(afistr)){
        bool ok;
        afi=afistr.toInt(&ok,16);
    }else{
        QMessageBox::critical(NULL, "提示","请输入2位16进制AFI!");
        ui- >lineEdit_afi- >setFocus();
        return;
    }
 
    QString masklstr=ui- >lineEdit_masklen- >text().trimmed();
    if(masklstr.length()==2 and checkinput(masklstr)){
        bool ok;
        masklen=masklstr.toInt(&ok,16);
    }else{
        QMessageBox::critical(NULL, "提示","请输入2位16进制掩码长度!");
        return;
    }
 
    status = myiso15693inventory16(flags, afi, masklen, maskuid,revlen, uid);
    if(status==0){
        mypcdbeep(30);
        ui- >lineEdit_dsfid- >setText(QString::asprintf("%02X", uid[0]));
        QString uidstr="";
        for(int i=1;i< 9;i++){
            uidstr=uidstr+QString::asprintf("%02X", uid[i]);
        }
        ui- >lineEdit_uid- >setText(uidstr);
 
//        QStringList strlist;
 
        int j=0;
        while (j< revlen[0]){
            QString cardinfstr="DSFID:"+QString::asprintf("%02X", uid[j])+",UID:";
            for (int i=1;i< 9;i++){
                cardinfstr=cardinfstr+QString::asprintf("%02X", uid[j+i]);
            }
//            strlist.append(cardinfstr);
            ui- >comboBox_uid- >addItem(cardinfstr);
            j=j+9;
        }
//        model = new QStringListModel(strlist);      //QStringListModel将QStringList包装了起来
//        ui- >listView- >setModel(model);              //填充到listview
//        ui- >listView- >setEditTriggers(QAbstractItemView::NoEditTriggers);  //设置item内容不可编辑
    }else{
        disperrinf(status);
    }
}
 
 
void MainWindow::on_pb_quiet_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char status;
    unsigned char flags;
    unsigned char uid[8];
 
    ui- >lineEdit_flags- >setText("22");
    flags=34;
 
    QString uidstr=ui- >lineEdit_uid- >text().trimmed();
    if(uidstr.length()==16 and checkinput(uidstr)){
        bool ok;
        for(int i=0;i< 8;i++){
            uid[i]=QString(uidstr.mid(i*2,2)).toInt(&ok,16);
        }
    }else{
        QMessageBox::critical(NULL, "提示","请先寻找卡片或输入16位16进制UID!");
        ui- >lineEdit_uid- >setFocus();
        return;
    }
 
    status = myiso15693stayquiet(flags, uid);
    if(status==0){
        mypcdbeep(30);
        QMessageBox::information(NULL, "提示", "操作成功,卡片已静止!");
    }else{
        if(status==40){
            QMessageBox::critical(NULL, "提示","使卡进入静止(Quiet)状态失败!");
        }else{
            disperrinf(status);
        }
    }
}
 
 
void MainWindow::on_pb_select_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char status;
    unsigned char flags;
    unsigned char uid[8];
 
    ui- >lineEdit_flags- >setText("22");
    flags=34;
 
    QString uidstr=ui- >lineEdit_uid- >text().trimmed();
    if(uidstr.length()==16 and checkinput(uidstr)){
        bool ok;
        for(int i=0;i< 8;i++){
            uid[i]=QString(uidstr.mid(i*2,2)).toInt(&ok,16);
        }
    }else{
        QMessageBox::critical(NULL, "提示","请先寻找卡片或输入16位16进制UID!");
        ui- >lineEdit_uid- >setFocus();
        return;
    }
 
    status = myiso15693Select(flags, uid);
    if(status==0){
        mypcdbeep(30);
        QMessageBox::information(NULL, "提示", "操作成功,卡片已在选中状态!");
    }else{
        if(status==41){
            QMessageBox::critical(NULL, "提示","使卡进入选中状态失败!");
        }else{
            disperrinf(status);
        }
    }
}
 
 
void MainWindow::on_pb_restare_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char status;
    unsigned char flags;
    unsigned char uid[8];
 
    ui- >lineEdit_flags- >setText("22");
    flags=34;
 
    QString uidstr=ui- >lineEdit_uid- >text().trimmed();
    if(uidstr.length()==16 and checkinput(uidstr)){
        bool ok;
        for(int i=0;i< 8;i++){
            uid[i]=QString(uidstr.mid(i*2,2)).toInt(&ok,16);
        }
    }else{
        QMessageBox::critical(NULL, "提示","请先寻找卡片或输入16位16进制UID!");
        ui- >lineEdit_uid- >setFocus();
        return;
    }
 
    status = myiso15693resettoready(flags, uid);
    if(status==0){
        mypcdbeep(30);
        QMessageBox::information(NULL, "提示", "操作成功,卡片已从静止中重起到准备状态!");
    }else{
        if(status==42){
            QMessageBox::critical(NULL, "提示","让卡从静止中重起准备失败!");
        }else{
            disperrinf(status);
        }
    }
}
 
 
void MainWindow::on_pb_afi_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char status;
    unsigned char flags;
    unsigned char afi;
    unsigned char uid[8];
 
    ui- >lineEdit_flags- >setText("22");
    flags=34;
 
    QString afistr=ui- >lineEdit_afi- >text().trimmed();
    if(afistr.length()==2 and checkinput(afistr)){
        bool ok;
        afi=afistr.toInt(&ok,16);
    }else{
        QMessageBox::critical(NULL, "提示","请输入2位16进制AFI!");
        ui- >lineEdit_afi- >setFocus();
        return;
    }
 
    QString uidstr=ui- >lineEdit_uid- >text().trimmed();
    if(uidstr.length()==16 and checkinput(uidstr)){
        bool ok;
        for(int i=0;i< 8;i++){
            uid[i]=QString(uidstr.mid(i*2,2)).toInt(&ok,16);
        }
    }else{
        QMessageBox::critical(NULL, "提示","请先寻找卡片或输入16位16进制UID!");
        ui- >lineEdit_uid- >setFocus();
        return;
    }
 
    status = myiso15693writeafi(flags, afi,uid);
    if(status==0){
        mypcdbeep(30);
        QMessageBox::information(NULL, "提示", "写AIF操作成功!");
    }else{
        if(status==46){
            QMessageBox::critical(NULL, "提示","写AIF操作失败!");
        }else{
            disperrinf(status);
        }
    }
}
 
 
void MainWindow::on_pb_dsfid_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char status;
    unsigned char flags;
    unsigned char dsfid;
    unsigned char uid[8];
 
    ui- >lineEdit_flags- >setText("22");
    flags=34;
 
    QString dsfidstr=ui- >lineEdit_dsfid- >text().trimmed();
    if(dsfidstr.length()==2 and checkinput(dsfidstr)){
        bool ok;
        dsfid=dsfidstr.toInt(&ok,16);
    }else{
        QMessageBox::critical(NULL, "提示","请输入2位16进制dsfid!");
        ui- >lineEdit_dsfid- >setFocus();
        return;
    }
 
    QString uidstr=ui- >lineEdit_uid- >text().trimmed();
    if(uidstr.length()==16 and checkinput(uidstr)){
        bool ok;
        for(int i=0;i< 8;i++){
            uid[i]=QString(uidstr.mid(i*2,2)).toInt(&ok,16);
        }
    }else{
        QMessageBox::critical(NULL, "提示","请先寻找卡片或输入16位16进制UID!");
        ui- >lineEdit_uid- >setFocus();
        return;
    }
 
    status = myiso15693writedsfid(flags, dsfid,uid);
    if(status==0){
        mypcdbeep(30);
        QMessageBox::information(NULL, "提示", "写DSFID操作成功!");
    }else{
        if(status==41){
            QMessageBox::critical(NULL, "提示","写DSFID操作失败!");
        }else{
            disperrinf(status);
        }
    }
}
 
 
void MainWindow::on_pb_systeminf_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char status;
    unsigned char flags;
    unsigned char uid[8];
    unsigned char revlen[1];
    unsigned char revbuf[255];
 
    ui- >plainTextEdit_data- >setPlainText("");
 
    ui- >lineEdit_flags- >setText("22");
    flags=34;
 
    QString uidstr=ui- >lineEdit_uid- >text().trimmed();
    if(uidstr.length()==16 and checkinput(uidstr)){
        bool ok;
        for(int i=0;i< 8;i++){
            uid[i]=QString(uidstr.mid(i*2,2)).toInt(&ok,16);
        }
    }else{
        QMessageBox::critical(NULL, "提示","请先寻找卡片或输入16位16进制UID!");
        ui- >lineEdit_uid- >setFocus();
        return;
    }
 
    status = myiso15693readinfo(flags, uid,revlen,revbuf);
    if(status==0){
        mypcdbeep(30);
        int j=0;
        QString cardinfstr="";
        while (j< revlen[0]){
            cardinfstr=cardinfstr+QString::asprintf("%02X ", revbuf[j]);
            j++;
        }
        ui- >plainTextEdit_data- >setPlainText(cardinfstr);
        QMessageBox::information(NULL, "提示", "读取卡片系统信息成功!");
    }else{
        disperrinf(status);
    }
}
 
 
void MainWindow::on_pb_secure_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char status;
    unsigned char flags;
    unsigned char startblock;
    unsigned char blocknum;
    unsigned char uid[8];
    unsigned char revlen[1];
    unsigned char revbuf[255];
 
    ui- >plainTextEdit_data- >setPlainText("");
 
    ui- >lineEdit_flags- >setText("22");
    flags=34;
 
    startblock=ui- >spinBox_star- >value();
    blocknum=ui- >spinBox_num- >value();
 
    QString uidstr=ui- >lineEdit_uid- >text().trimmed();
    if(uidstr.length()==16 and checkinput(uidstr)){
        bool ok;
        for(int i=0;i< 8;i++){
            uid[i]=QString(uidstr.mid(i*2,2)).toInt(&ok,16);
        }
    }else{
        QMessageBox::critical(NULL, "提示","请先寻找卡片或输入16位16进制UID!");
        ui- >lineEdit_uid- >setFocus();
        return;
    }
 
    status = myiso15693readsecuritystate(flags, startblock,blocknum,uid,revlen,revbuf);
    if(status==0){
        mypcdbeep(30);
        int j=0;
        QString cardinfstr="";
        while (j< revlen[0]){
            cardinfstr=cardinfstr+QString::asprintf("%02X ", revbuf[j]);
            j++;
        }
        ui- >plainTextEdit_data- >setPlainText(cardinfstr);
        QMessageBox::information(NULL, "提示", "读取卡片系统信息成功!");
    }else{
        disperrinf(status);
    }
}
 
 
void MainWindow::on_pb_lockafi_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    int answ=QMessageBox::question (this, "警告", "你确定要锁定卡片的AFI吗 ?锁定后不可以再次修改!", QMessageBox::Ok, QMessageBox::Cancel);
    if (answ ==1024){
        unsigned char status;
        unsigned char flags;
        unsigned char uid[8];
 
        ui- >lineEdit_flags- >setText("22");
        flags=34;
 
        QString uidstr=ui- >lineEdit_uid- >text().trimmed();
        if(uidstr.length()==16 and checkinput(uidstr)){
            bool ok;
            for(int i=0;i< 8;i++){
                uid[i]=QString(uidstr.mid(i*2,2)).toInt(&ok,16);
            }
        }else{
            QMessageBox::critical(NULL, "提示","请先寻找卡片或输入16位16进制UID!");
            ui- >lineEdit_uid- >setFocus();
            return;
        }
 
        status = myiso15693lockafi(flags, uid);
        if(status==0){
            mypcdbeep(30);
            QMessageBox::information(NULL, "提示", "锁AFI操作成功!");
        }else{
            disperrinf(status);
        }
    }
}
 
 
void MainWindow::on_pb_lockdsfid_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    int answ=QMessageBox::question (this, "警告", "你确定要锁定卡片的DSFID吗 ?锁定后不可以再次修改!", QMessageBox::Ok, QMessageBox::Cancel);
    if (answ ==1024){
        unsigned char status;
        unsigned char flags;
        unsigned char uid[8];
 
        ui- >lineEdit_flags- >setText("22");
        flags=34;
 
        QString uidstr=ui- >lineEdit_uid- >text().trimmed();
        if(uidstr.length()==16 and checkinput(uidstr)){
            bool ok;
            for(int i=0;i< 8;i++){
                uid[i]=QString(uidstr.mid(i*2,2)).toInt(&ok,16);
            }
        }else{
            QMessageBox::critical(NULL, "提示","请先寻找卡片或输入16位16进制UID!");
            ui- >lineEdit_uid- >setFocus();
            return;
        }
 
        status = myiso15693lockdsfid(flags, uid);
        if(status==0){
            mypcdbeep(30);
            QMessageBox::information(NULL, "提示", "数据存储格式标识DSFID锁定成功!");
        }else{
            disperrinf(status);
        }
    }
}
 
 
void MainWindow::on_pb_lockdata_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    int answ=QMessageBox::question (this, "警告", "你确定要锁定卡片的数据块吗 ?锁定后不可以再次修改!", QMessageBox::Ok, QMessageBox::Cancel);
    if (answ ==1024){
        unsigned char status;
        unsigned char flags;
        unsigned char startblock;
        unsigned char uid[8];
 
        ui- >lineEdit_flags- >setText("22");
        flags=34;
 
        startblock=ui- >spinBox_star- >value();
 
        QString uidstr=ui- >lineEdit_uid- >text().trimmed();
        if(uidstr.length()==16 and checkinput(uidstr)){
            bool ok;
            for(int i=0;i< 8;i++){
                uid[i]=QString(uidstr.mid(i*2,2)).toInt(&ok,16);
            }
        }else{
            QMessageBox::critical(NULL, "提示","请先寻找卡片或输入16位16进制UID!");
            ui- >lineEdit_uid- >setFocus();
            return;
        }
 
        status = myiso15693lockblock(flags,startblock, uid);
        if(status==0){
            mypcdbeep(30);
            QMessageBox::information(NULL, "提示", "数据块锁定成功!");
        }else{
            disperrinf(status);
        }
    }
}
 
 
void MainWindow::on_pb_read_clicked()
{
    if(!checkdllos()){return;}      //判断运行目录内动态库文件是否存在
 
    unsigned char status;
    unsigned char flags;
    unsigned char startblock;
    unsigned char blocknum;
    unsigned char uid[8];
    unsigned char revlen[1];
    unsigned char revbuf[255];
 
    ui- >plainTextEdit_data- >setPlainText("");
 
    ui- >lineEdit_flags- >setText("22");
    flags=34;
 
    startblock=ui- >spinBox_star- >value();
    blocknum=startblock+ui- >spinBox_num- >value();
 
    QString uidstr=ui- >lineEdit_uid- >text().trimmed();
    if(uidstr.length()==16 and checkinput(uidstr)){
        bool ok;
        for(int i=0;i< 8;i++){
            uid[i]=QString(uidstr.mid(i*2,2)).toInt(&ok,16);
        }
    }else{
        QMessageBox::critical(NULL, "提示","请先寻找卡片或输入16位16进制UID!");
        ui- >lineEdit_uid- >setFocus();
        return;
    }
 
    QString blockdata="";
    while (startblocklineEdit_afi- >text().trimmed();
    if(afistr.length()==2 and checkinput(afistr)){
         bool ok;
         afi=afistr.toInt(&ok,16);
    }else{
         QMessageBox::critical(NULL, "提示","请输入2位16进制AFI!");
         ui- >lineEdit_afi- >setFocus();
         return;
    }
 
    QString uidstr=ui- >lineEdit_uid- >text().trimmed();
    if(uidstr.length()==16 and checkinput(uidstr)){
         for(int i=0;i< 9;i++){
            bool ok;
            newuid[i]=QString(uidstr.mid(i*2,2)).toInt(&ok,16);
         }
    }else{
         QMessageBox::critical(NULL, "提示","请输入16位16进制UID!");
         ui- >lineEdit_uid- >setFocus();
         return;
    }
 
    if(myiso15693writeuid!=NULL){
        status = myiso15693writeuid(ctrlword,afi,olduid,newuid);
 
        if(status==0){
             mypcdbeep(30);
             QMessageBox::information(NULL, "提示", "写卡成功,卡片UID:"+uidstr);
        }
        else
        {
             if(status==45){
                QMessageBox::critical(NULL, "提示", "写UID失败,此卡UID不可以改写!");
             }else{
                disperrinf(status);
             }
        }
    }else{
        QMessageBox::critical(NULL, "提示", "myiso15693writeuid函数未正确载入!");
    }
}
 
审核编辑 黄宇

 

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分