确认接收到的信息:
void MainWindow::Analyze_c1(QHostAddress ip,quint16 port,unsigned char databuff[], qint64 buflen)
{
DisableSendAgain(ip, port,databuff,buflen);
QString IPAddress=QString::asprintf("%d", databuff[1])+"."+QString::asprintf("%d", databuff[2])+"."+QString::asprintf("%d", databuff[3])+"."+QString::asprintf("%d", databuff[4]);
QString DeviceNumber=QString::asprintf("%05d",databuff[5]+databuff[6]*256);
QString FrameNumber=QString::asprintf("%05d",databuff[7]+databuff[8]*256);
QString CardnoHexZ=QString::asprintf("%02X%02X%02X%02X", databuff[10],databuff[11],databuff[12],databuff[13]);
QString CardnoHexF=QString::asprintf("%02X%02X%02X%02X", databuff[13],databuff[12],databuff[11],databuff[10]);
bool status;
QString Cardno8H10D=QString::asprintf("%010u",CardnoHexF.toUInt(&status,16));
QString SerialNumber="";
for (int i=14;itextEdit_M1UID->setText(CardnoHexZ);
if(ui->checkBox_Resp->isChecked()){Respondinfo(getsysdatetime()+"卡号:"+Cardno8H10D,ip,port,DeviceNumber);}
}
这段代码定义了一个名为 DisableSendAgain
的成员函数,该函数是 MainWindow
类的一个成员。这个函数用于发送一个特定的数据帧到指定的IP地址和端口,并在发送后更新一个列表(可能是GUI的一部分)。
解析读取IC卡卡号:
void MainWindow::Analyze_c1(QHostAddress ip,quint16 port,unsigned char databuff[], qint64 buflen)
{
DisableSendAgain(ip, port,databuff,buflen);
QString IPAddress=QString::asprintf("%d", databuff[1])+"."+QString::asprintf("%d", databuff[2])+"."+QString::asprintf("%d", databuff[3])+"."+QString::asprintf("%d", databuff[4]);
QString DeviceNumber=QString::asprintf("%05d",databuff[5]+databuff[6]*256);
QString FrameNumber=QString::asprintf("%05d",databuff[7]+databuff[8]*256);
QString CardnoHexZ=QString::asprintf("%02X%02X%02X%02X", databuff[10],databuff[11],databuff[12],databuff[13]);
QString CardnoHexF=QString::asprintf("%02X%02X%02X%02X", databuff[13],databuff[12],databuff[11],databuff[10]);
bool status;
QString Cardno8H10D=QString::asprintf("%010u",CardnoHexF.toUInt(&status,16));
QString SerialNumber="";
for (int i=14;itextEdit_M1UID->setText(CardnoHexZ);
if(ui->checkBox_Resp->isChecked()){Respondinfo(getsysdatetime()+"卡号:"+Cardno8H10D,ip,port,DeviceNumber);}
}
主动读取扇区数据的返回:
void MainWindow::Analyze_c3(QHostAddress ip,quint16 port,unsigned char databuff[], qint64 buflen)
{
QString IPAddress=QString::asprintf("%d", databuff[1])+"."+QString::asprintf("%d", databuff[2])+"."+QString::asprintf("%d", databuff[3])+"."+QString::asprintf("%d", databuff[4]);
QString DeviceNumber=QString::asprintf("%05d",databuff[5]+databuff[6]*256);
QString CardnoHex="";
for (int i=12;i<16;i++){
CardnoHex=CardnoHex+QString::asprintf("%02X", databuff[i]);
}
int j=databuff[10]*48;
int m=databuff[11]*48;
for(int i=0;i=databuff[9]){
m=databuff[9]*48;
QString DataHex="";
for (int i=0;itextEdit_data->setPlainText(DataHex);
QString DispInf="读取M1卡扇区数据成功,设备IP:"+IPAddress+",机号:"+DeviceNumber+",16进制卡号:"+CardnoHex;
listadditems(1,DispInf);
ui->textEdit_M1UID->setText(CardnoHex);
if(ui->checkBox_Resp->isChecked()){Respondinfo(getsysdatetime()+"卡号:"+CardnoHex,ip,port,DeviceNumber);}
}
}