身份证阅读器ARM版本Linux环境SO库编译指南
1、安装libusb库:sudo apt-get install libusb-1.0-0-dev。1、执行 sudo cp donsee.rules /etc/udev/rules.d/2、执行 sudo udevadm control --reload。4、选择ARM linux环境对应的libdonsee.so库。2、安装gcc:sudo apt install gcc。3:安装g++:su

【国产系统、Linux系统操作步骤】
一、修改设备usb权限规则:
1、执行 sudo cp donsee.rules /etc/udev/rules.d/
2、执行 sudo udevadm control --reload
3、完成前两部后,插拔设备即可
二、安装环境:
1、安装libusb库:sudo apt-get install libusb-1.0-0-dev
2、安装gcc:sudo apt install gcc
3:安装g++:sudo apt install g++
三、获取 libdonsee.so 依赖库
1、sudo chmod 777 ./libdonsee.sh
2、 ./libdonsee.sh
3、然后lib文件夹会生成所需依赖库
4、选择ARM linux环境对应的libdonsee.so库
四、运行测试
./output

#include "donsee.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> //usleep
int main()
{
long t_nHandle = -99;
int i = 0;
char pszError[128];
unsigned char Response[1024] = {0};
long t_nRe;
char t_pszMsg[1024] = "";
char pOutInfo[1024] = "";
unsigned char tmp;
char t_arrMsg[256];
char pKey[68]="6E4DA8CF90D5BE7B0102030405060708|A072D45DA1D9A3810102030405060708|";
printf("********************************************************\n");
printf("请输入数字选择需要测试的功能:\n");
printf("0、测试蜂鸣器和版本号\n");
printf("1、测试 身份证\n");
printf("2、测试 社保卡\n");
printf("3、测试 M1 卡\n");
printf("4、测试 非接触CPU卡\n");
printf("5、测试 银行卡\n");
printf("6、测试 15693卡\n");
printf("7、测试 接触CPU卡\n");
printf("8、测试 磁条卡\n");
printf("9、测试 4442卡\n");
printf("10、测试 北京通卡\n");
printf("11、关闭射频天线\n");
printf("12、Donsee_iReadCardBas\n");
printf("13、Donsee_iReadCardBas_HSM_Step1\n");
printf("14、Donsee_iReadCardBas_HSM_Step2(需要自己写代码调用)\n");
printf("101、轮询测试读身份证\n");
printf("********************************************************\n");
int t_nIndex;
scanf("%d", &t_nIndex);
switch (t_nIndex)
{
case 0: // 测试版本号和蜂鸣器
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
t_nRe = Donsee_Version(Response);
if(t_nRe == 0)
printf("设备版本号:%s\n", Response);
t_nRe = Donsee_WRSerial(0x01,t_arrMsg);
if(t_nRe == 0)
printf("读卡器系列号:%s\n", t_arrMsg);
Donsee_Beep();
Donsee_Close();
break;
case 1: // 测试身份证
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
memset(Response, 0, 1024);
// t_nRe = Donsee_ReadIDCardUid(Response); //身份证Uid,有需要的可以这里获取
// printf("Donsee_ReadIDCardUid返回:%s\n", Response);
IDINFO idInfo;
// nType [in]:设置身份证读卡类型:0,文本信息;1,文本+照片;2,文本+照片+指纹
// nMode [in]:设置读卡模式:0,读卡1次、拿开后放上重读;1,连续读卡,此功能未实现,填1就行
int nType = 1;
int nMode = 1; // 此功能未实现,填1就行
memset(&idInfo, 0, sizeof(IDINFO));
char t_szPath[256] = "IDPhoto.bmp";
// char t_szPath[256] = "";
// char t_szPath[256] = NULL;
t_nRe = Donsee_ReadIDCard(nType, nMode, t_szPath, &idInfo, t_arrMsg);
if (t_nRe != 0)
{
printf("读身份证失败,t_nRe = %ld\n", t_nRe);
Donsee_Close();
return -2;
}
else
{
Donsee_Beep();
// Donsee_Beep();
printf("读身份证成功\n");
if (
strcmp(idInfo.certType, "Y") == 0)
{
printf(("中文姓名:%s\n"), idInfo.name);
printf(("性 别:%s\n"), idInfo.sex);
printf(("换证次数:%s\n"), idInfo.changCount);
printf(("出身日期:%s\n"), idInfo.birthday);
printf(("英文姓名:%s\n"), idInfo.ENfullname);
printf(("永久居住证号:%s\n"), idInfo.number);
printf(("有效期开始:%s\n"), idInfo.signdate);
printf(("有效期结束:%s\n"), idInfo.validterm);
printf(("英文姓名(备用):%s\n"), idInfo.ENfullnameOther);
printf(("国籍代码:%s/%s\n"), idInfo.Nationality, idInfo.people);
printf(("证件标识:%s\n"), idInfo.certType);
printf(("既往关联码:%s\n"), idInfo.oldNumber);
}
else if (strcmp(idInfo.certType, "I") == 0)
{
printf(("英文姓名:%s\n"), idInfo.ENfullname);
printf(("性 别:%s\n"), idInfo.sex);
printf(("永久居住证号:%s\n"), idInfo.number);
printf(("国籍代码:%s\n"), idInfo.Nationality);
printf(("中文姓名:%s\n"), idInfo.name);
printf(("有效期开始:%s\n"), idInfo.signdate);
printf(("有效期结束:%s\n"), idInfo.validterm);
printf(("出身日期:%s\n"), idInfo.birthday);
printf(("证件版本:%s\n"), idInfo.certVersion);
printf(("初次受理机关:%s\n"), idInfo.organs);
printf(("证件标识:%s\n"), idInfo.certType);
}
else if (strcmp(idInfo.certType, "J") == 0)
{
printf(("姓 名:%s\n"), idInfo.name);
printf(("性 别:%s\n"), idInfo.sex);
printf(("出身日期:%s\n"), idInfo.birthday);
printf(("住 址:%s\n"), idInfo.address);
printf(("公民身份证号:%s\n"), idInfo.number);
printf(("签发机关:%s\n"), idInfo.organs);
printf(("有效期开始:%s\n"), idInfo.signdate);
printf(("有效期结束:%s\n"), idInfo.validterm);
printf(("通行证号:%s\n"), idInfo.passNu);
printf(("签发数次:%s\n"), idInfo.signCount);
printf(("证件标识:%s\n"), idInfo.certType);
}
else // 除 Y I J三种证件之外的其他证件,一律规视为居民身份证
{
printf(("姓 名:%s\n"), idInfo.name);
printf(("性 别:%s\n"), idInfo.sex);
printf(("民 族:%s\n"), idInfo.people);
printf(("出身日期:%s\n"), idInfo.birthday);
printf(("住 址:%s\n"), idInfo.address);
printf(("公民身份证号:%s\n"), idInfo.number);
printf(("签发机关:%s\n"), idInfo.organs);
printf(("有效期开始:%s\n"), idInfo.signdate);
printf(("有效期结束:%s\n"), idInfo.validterm);
printf(("证件标识:%s\n"), idInfo.certType);
}
// printf(("1024相片原始数据:%s\n"), idInfo.Photo);
// printf(("1024指纹原始数据:%s\n"), idInfo.figData);
Donsee_Close();
}
break;
case 2: // 测试社保卡,三代社保卡需要Psam秘钥才能读取,二代卡不需要(只能插卡读取)
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
SSCard_IDINFO cardInfo;
memset(&cardInfo, 0, sizeof(cardInfo));
long t_nRead = Donsee_ReadSSCard(0x11, &cardInfo, pszError);
if (t_nRead != 0)
{
printf("读社保卡失败,t_nRe:%ld , %s\n", t_nRead,pszError);
Donsee_Close();
return -2;
}
else
{
Donsee_Beep();
printf("读社保卡成功\n");
printf("姓名:%s\n", cardInfo.name);
printf("性别:%s\n", cardInfo.sex);
printf("民族:%s\n", cardInfo.nation);
printf("出生日期:%s\n", cardInfo.birthday);
printf("发证日期:%s\n", cardInfo.signdate);
printf("有效日期:%s\n", cardInfo.validterm);
printf("卡号:%s\n", cardInfo.cardnumber);
printf("社会保障号码(身份证号):%s\n", cardInfo.idnumber);
printf("城市代码:%s\n", cardInfo.city);
printf("社保卡版本:%s\n", cardInfo.cardveVrsion);
Donsee_Close();
}
break;
case 3: // 测试M1卡
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
char t_chMsgM1[256] = "";
// t_nRe = Donsee_ReadICUid(t_chMsgM1); //功能未实现
// if (t_nRe == 0)
//{
// printf("M1 卡 获取UID成功,UID:%s\n", t_chMsgM1);
// }
// M1寻卡
t_nRe = Donsee_ICRequest();
if (t_nRe != 0)
{
printf("M1 卡片请求 失败,返回值:%ld\n", t_nRe);
}
t_nRe = Donsee_ICAnticoll(t_chMsgM1); // 防碰撞可以出来uid,M1和cpu卡都支持
if (t_nRe != 0)
{
printf("M1 卡片防碰撞 失败,返回值:%ld\n", t_nRe);
}
t_nRe = Donsee_ICSelect(0x41);
if (t_nRe != 0)
{
printf("TypeA 卡片选择 失败,返回值:%ld\n", t_nRe);
}
else{
Donsee_Beep();
printf("M1 寻卡成功");
printf("M1 卡 获取UID成功,UID:%s\n", t_chMsgM1);
}
int t_nKeyMode = 0x60; // KeyA
int t_nAdd = 5;
t_nRe = Donsee_M1VerifyPass(t_nKeyMode, t_nAdd / 4, "FFFFFFFFFFFF");
if (t_nRe != 0)
{
printf("M1 卡片 Donsee_M1VerifyPass 密钥认证 失败,返回值:%ld \n", t_nRe);
}
else
printf("M1 卡 Donsee_M1VerifyPass 密钥认证 成功\n");
unsigned char t_chKey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
t_nRe = Donsee_M1VerifyPassHex(t_nKeyMode, t_nAdd / 4, t_chKey);
if (t_nRe != 0)
{
printf("M1 卡片 Donsee_M1VerifyPassHex 密钥认证 失败,返回值:%ld \n", t_nRe);
}
else
printf("M1 卡 Donsee_M1VerifyPassHex 密钥认证 成功\n");
char t_pszReadData[128] = "";
t_nRe = Donsee_M1Read(t_nAdd, t_pszReadData);
if (t_nRe != 0)
{
printf("M1 卡片读卡 失败,返回值:%ld\n", t_nRe);
}
else
printf("M1 卡 读取第 %d 块数据 成功,Data:%s\n", t_nAdd, t_pszReadData);
t_nRe = Donsee_M1Write(t_nAdd, "0102030405060708090001020304050A");
if (t_nRe != 0)
{
printf("M1 卡片写卡 失败,返回值:%ld\n", t_nRe);
}
else
printf("M1 卡 写入第 %d 块数据: 0102030405060708090001020304050A, 成功\n", t_nAdd);
memset(t_pszReadData, 0, 128);
t_nRe = Donsee_M1Read(t_nAdd, t_pszReadData);
if (t_nRe != 0)
{
printf("M1 卡片读卡 失败,返回值:%ld\n", t_nRe);
}
else
printf("M1 卡 读取第 %d 块数据 成功,Data:%s\n", t_nAdd, t_pszReadData);
unsigned long t_nValue = 256;
t_nRe = Donsee_M1Initval(t_nAdd, t_nValue);
if (t_nRe != 0)
{
printf("M1 卡片初始化值 失败,返回值:%ld\n", t_nRe);
}
else
printf("M1 卡 卡片初始化第 %d 块 值 成功\n", t_nAdd);
t_nRe = Donsee_M1Increment(t_nAdd, 100);
if (t_nRe != 0)
{
printf("M1 卡片增值 失败,返回值:%ld\n", t_nRe);
}
else
printf("M1 卡 卡片增值 第 %d 块 成功\n", t_nAdd);
t_nRe = Donsee_M1Decrement(t_nAdd, 20);
if (t_nRe != 0)
{
printf("M1 卡片减值 失败,返回值:%ld\n", t_nRe);
}
else
printf("M1 卡 卡片减值第 %d 块 成功\n", t_nAdd);
t_nRe = Donsee_M1Readval(t_nAdd, &t_nValue);
if (t_nRe != 0)
{
printf("M1 卡片读值 失败,返回值:%ld\n", t_nRe);
}
else
printf("M1 卡 卡片读值 %d 块 成功,Value = %ld\n", t_nAdd, t_nValue);
t_nRe = Donsee_M1LoadKey(t_nKeyMode, t_nAdd / 4, "FFFFFFFFFFFF");
if (t_nRe != 0)
{
printf("M1 卡片加载密钥 失败,返回值:%ld\n", t_nRe);
}
else
printf("M1 卡 卡片加载到密钥 第%d扇区 成功\n", t_nAdd / 4);
t_nRe = Donsee_M1Verify(t_nKeyMode, t_nAdd / 4);
if (t_nRe != 0)
{
printf("M1 卡片认证加载密钥 第%d扇区 失败,返回值:%ld\n", t_nAdd / 4, t_nRe);
}
else
printf("M1 卡 卡片认证加载密钥 第%d扇区 成功\n", t_nAdd / 4);
Donsee_Close();
break;
case 4: // 测试非接触式CPU卡
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
char t_arrDataRe[32] = {0};
char t_arrDataUID[8] = {0};
long t_nSet = Donsee_SetTypeA();
if (t_nSet != 0)
{
printf("TypeA 设置失败,t_nRe = %ld\n", t_nSet);
Donsee_Close();
return -1;
}
long t_nReq = Donsee_ICRequest();
if (t_nReq != 0)
{
printf("TypeA 请求失败,t_nRe = %ld\n", t_nReq);
Donsee_Close();
return 1;
}
long t_nAtl = Donsee_ICAnticoll(t_arrDataUID);
if (t_nAtl != 0)
{
printf("TypeA 防碰撞失败,t_nRe = %ld\n", t_nAtl);
Donsee_Close();
return 1;
}
printf("TypeA_Anticoll:%s\n", t_arrDataUID);
long t_nSel = Donsee_ICSelect(0x41);
if (t_nSel != 0)
{
printf("TypeA 选卡失败,t_nRe = %ld\n", t_nSel);
Donsee_Close();
return 1;
}
t_nRe = Donsee_PowerOnTypeA(t_arrDataRe);
if (t_nRe != 0)
{
printf("TypeA 上电失败,t_nRe = %ld\n", t_nRe);
Donsee_Close();
return 1;
}
printf("TypeA_ATR:%s\n", t_arrDataRe);
memset(Response, 0, 1024);
printf("TypeA-APDU发送:0084000008\n");
t_nRe = Donsee_APDUType("0084000008", Response);
if (t_nRe != 0)
{
printf("APDU执行失败,t_nRe = %ld\n", t_nRe);
Donsee_Close();
return 1;
}
printf("APDU成功:%s\n", Response);
Donsee_Beep();
Donsee_Close();
break;
case 5: // 测试银行卡
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
char t_szBankNo[256] = "";
char *p, *q;
t_nRe = Donsee_GetBankCardNo(t_szBankNo);
if (t_nRe != 0)
printf("读取银行卡号失败,t_nRe = %ld\n", t_nRe);
else
{
tmp = (unsigned char)(strchr(t_szBankNo, 'D') - t_szBankNo);
q = (tmp > 0) ? strndup(t_szBankNo, tmp) : strdup(t_szBankNo);
printf("读取银行卡号成功:%s\n", q);
Donsee_Beep();
}
Donsee_Close();
break;
case 6: // 测试15693卡
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
char t_chMsg15693[256] = "";
t_nRe = Donsee_15693_Find(t_chMsg15693);
if (t_nRe != 0)
{
printf("15693 寻卡失败,返回值:%ld\n", t_nRe);
}
else
{
//Donsee_Beep();
printf("15693 寻卡成功,UID:%s\n", t_chMsg15693);
}
t_nRe = Donsee_15693_Info(t_chMsg15693);
if (t_nRe != 0)
{
printf("15693 卡信息获取失败,返回值:%ld\n", t_nRe);
}
else
printf("15693 卡信息获取成功,CardInfo:%s\n", t_chMsg15693);
unsigned char t_nBlkAdd = 0x00;
memset(t_chMsg15693, 0, 256);
t_nRe = Donsee_15693_Read(t_nBlkAdd, t_chMsg15693);
if (t_nRe != 0)
{
printf("15693 卡读卡失败,返回值:%ld\n", t_nRe);
}
else
printf("15693 卡读卡成功,Data:%s\n", t_chMsg15693);
t_nRe = Donsee_15693_Write(t_nBlkAdd, "88898685");
if (t_nRe != 0)
{
printf("15693 卡写卡失败,返回值:%ld\n", t_nRe);
}
else
printf("15693 卡写卡成功,Data:88898685\n");
memset(t_chMsg15693, 0, 256);
t_nRe = Donsee_15693_Read(t_nBlkAdd, t_chMsg15693);
if (t_nRe != 0)
{
printf("15693 卡读卡失败,返回值:%ld\n", t_nRe);
}
else
printf("15693 卡读卡成功,Data:%s\n", t_chMsg15693);
Donsee_Close();
break;
case 7: // 测试接触式CPU卡
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
memset(Response, 0, 1024);
t_nRe = Donsee_PowerOn(0x01, Response);
if(t_nRe == 0 )
printf("cpu复位成功:%s\n", Response);
else
{
printf("cpu复位失败,t_nRe = %ld\n", t_nRe);
}
/*
t_nRe = Donsee_ColdPowerOn(0x01, Response);
if(t_nRe == 0 )
printf("cpu冷复位:%s\n", Response);
else
{
printf("cpu冷复位失败,t_nRe = %ld\n", t_nRe);
return ;
}
memset(Response, 0, 1024);
t_nRe = Donsee_HotPowerOn(0x01, Response);
printf("cpu热复位:%s\n", Response);
*/
memset(Response, 0, 1024);
printf("cpu-APDU发送:0084000008\n");
t_nRe = Donsee_APDU(0x01, "0084000008", Response);
//printf("cpu-APDU返回:%s\n", Response);
if(t_nRe == 0 )
{
Donsee_Beep();
printf("APDU成功:%s\n", Response);
}
else
{
printf("APDU失败,t_nRe = %ld\n", t_nRe);
}
Donsee_Close();
break;
case 8: // 测试磁条卡
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
unsigned char t_nTime = 15;
int t_nTrack = 2;
char t_pszTrackData[512] = "";
t_nRe = Donsee_ReadMagCard(t_nTime, t_nTrack, t_pszTrackData);
if (t_nRe != 0)
{
printf("磁条卡刷卡失败,返回值:%ld\n", t_nRe);
}
else
printf("磁条卡刷卡成功,TrackData:%s\n", t_pszTrackData);
// 设置主动输出
unsigned char szConfig[3] = {0x02, 0x00, 0x01};
// t_nRe = Donsee_ReadMagType(0x00,szConfig) ;
// if (t_nRe != 0)
// printf("磁条卡设置主动输出失败,返回值:%ld\n", t_nRe);
// else
// printf("磁条卡设置主动输出成功\n");
// 设置被动输出
// t_nRe = Donsee_ReadMagType(0x01,szConfig) ;
// if (t_nRe != 0)
// printf("磁条卡设置被动输出失败,返回值:%ld\n", t_nRe);
// else
// printf("磁条卡设置被动输出成功\n");
Donsee_Beep();
Donsee_Close();
break;
case 9: // 测试4442卡
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
char t_chMsg4442[256] = "";
t_nRe = Donsee_4442_PowerOn(t_chMsg4442);
if (t_nRe == 0)
{
printf("4442 卡 上电成功,UID:%s\n", t_chMsg4442);
}
int t_nCount;
t_nRe = Donsee_4442_ReadCount(&t_nCount);
if (t_nRe == 0)
{
printf("4442 卡 密钥认证剩余次数:%d次\n", t_nCount);
}
memset(t_chMsg4442, 0, 256);
t_nRe = Donsee_4442_Read(32, 16, t_chMsg4442);
if (t_nRe == 0)
{
printf("4442 卡 读卡成功,Data:%s\n", t_chMsg4442);
}
t_nRe = Donsee_4442_Verify("FFFFFF");
if (t_nRe == 0)
{
printf("4442 卡 密钥认证成功\n");
}
t_nRe = Donsee_4442_Write(32, 16, "AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDD");
if (t_nRe == 0)
{
printf("4442 卡 写卡成功,Data:AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDD\n");
}
t_nRe = Donsee_4442_Read(32, 16, t_chMsg4442);
if (t_nRe == 0)
{
printf("4442 卡 读卡成功,Data:%s\n", t_chMsg4442);
}
t_nRe = Donsee_4442_WriteProtect(0, 16, "AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDD");
if (t_nRe == 0)
{
printf("4442 卡 写卡保护成功,Data:AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDD\n");
}
t_nRe = Donsee_4442_ReadProtect(0, 16, t_chMsg4442);
if (t_nRe == 0)
{
printf("4442 卡 读卡保护成功,Data:%s\n", t_chMsg4442);
}
t_nRe = Donsee_4442_PowerOff();
if (t_nRe == 0)
{
printf("4442 卡 下电成功\n");
}
Donsee_Beep();
Donsee_Close();
break;
case 10: // 测试北京通卡
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
BJT_IDINFO bjt_idInfo;
memset(&bjt_idInfo, 0, sizeof(BJT_IDINFO));
t_nRe = Donsee_ReadBJTIDCard(&bjt_idInfo, t_arrMsg);
if (t_nRe != 0)
{
printf("读取北京通失败\n");
Donsee_Close();
return -2;
}
else
Donsee_Beep();
printf("读取北京通成功\n");
printf(("姓名:%s\n"), bjt_idInfo.name);
printf(("性 别:%s\n"), bjt_idInfo.sex);
printf(("北京通号:%s\n"), bjt_idInfo.cardnumber);
printf(("卡片类型:%s\n"), bjt_idInfo.nType);
printf(("证件名称:%s\n"), bjt_idInfo.cardName);
printf(("发卡机构:%s\n"), bjt_idInfo.organs);
t_nRe = Donsee_ReadBJTIDCard_Photo("./bjtPhoto.jpg", t_arrMsg);
if (t_nRe != 0)
{
printf("读取北京通头像失败\n");
Donsee_Close();
return -2;
}
else
printf("读取北京通头像成功\n");
Donsee_Close();
break;
case 11: // 关闭射频天线
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
Donsee_SwitchRF(0); // 0 关闭天线,1 打开天线
Donsee_Close();
break;
case 12: // 测试Donsee_iReadCardBas
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
t_nRe = Donsee_iReadCardBas(3, pOutInfo);
if (t_nRe != 0)
printf("Donsee_iReadCardBas 读取失败 t_nRe = %ld\n", t_nRe);
else
{
printf("Donsee_iReadCardBas 读取成功:\n%s\n", pOutInfo);
}
// Donsee_Close();
break;
case 13: // 测试step1
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
t_nRe = Donsee_iReadCardBas_HSM_Step1(3, pOutInfo);
if (t_nRe != 0)
printf("Donsee_iReadCardBas_HSM_Step1 读取失败 t_nRe = %ld\n", t_nRe);
else
{
printf("Donsee_iReadCardBas_HSM_Step1 读取成功:\n%s\n", pOutInfo);
}
// Donsee_Close();
break;
case 14: // 测试step2
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
t_nRe = Donsee_iReadCardBas_HSM_Step2(pKey, pOutInfo);
if (t_nRe != 0)
printf("Donsee_iReadCardBas_HSM_Step2 读取失败 t_nRe = %ld\n", t_nRe);
else
{
printf("Donsee_iReadCardBas_HSM_Step2 读取成功:\n%s\n", pOutInfo);
}
// Donsee_Close();
break;
case 15: // 测试Donsee_iReadCardBas_base
//t_nRe = Donsee_iReadCardBas_base(3, pOutInfo);
if (t_nRe != 0)
printf("Donsee_iReadCardBas_base 获取数据 失败\n");
else
{
printf("Donsee_iReadCardBas_base 获取数据 成功:\n%s\n", pOutInfo);
}
// Donsee_Close();
break;
case 101: // 自动读身份证
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
break;
}
for (i=0; i<100 ;i++ )
{
IDINFO idInfo;
// nType [in]:设置身份证读卡类型:0,文本信息;1,文本+照片;2,文本+照片+指纹
// nMode [in]:设置读卡模式:0,读卡1次、拿开后放上重读;1,连续读卡,此功能未实现,填1就行
int nType = 1;
int nMode = 1; // 此功能未实现,填1就行
memset(&idInfo, 0, sizeof(IDINFO));
char t_szPath[256] = "IDPhoto.bmp";
t_nRe = Donsee_ReadIDCard(nType, nMode, t_szPath, &idInfo, t_arrMsg);
if (t_nRe != 0)
{
printf("读身份证失败################################### t_nRe = %ld \n", t_nRe);
}
else
{
Donsee_Beep();
printf("读身份证成功###################################\n");
if (strcmp(idInfo.certType, "Y") == 0)
{
printf(("中文姓名:%s\n"), idInfo.name);
printf(("性 别:%s\n"), idInfo.sex);
printf(("换证次数:%s\n"), idInfo.changCount);
printf(("出身日期:%s\n"), idInfo.birthday);
printf(("英文姓名:%s\n"), idInfo.ENfullname);
printf(("永久居住证号:%s\n"), idInfo.number);
printf(("有效期开始:%s\n"), idInfo.signdate);
printf(("有效期结束:%s\n"), idInfo.validterm);
printf(("英文姓名(备用):%s\n"), idInfo.ENfullnameOther);
printf(("国籍代码:%s/%s\n"), idInfo.Nationality, idInfo.people);
printf(("证件标识:%s\n"), idInfo.certType);
printf(("既往关联码:%s\n"), idInfo.oldNumber);
}
else if (strcmp(idInfo.certType, "I") == 0)
{
printf(("英文姓名:%s\n"), idInfo.ENfullname);
printf(("性 别:%s\n"), idInfo.sex);
printf(("永久居住证号:%s\n"), idInfo.number);
printf(("国籍代码:%s\n"), idInfo.Nationality);
printf(("中文姓名:%s\n"), idInfo.name);
printf(("有效期开始:%s\n"), idInfo.signdate);
printf(("有效期结束:%s\n"), idInfo.validterm);
printf(("出身日期:%s\n"), idInfo.birthday);
printf(("证件版本:%s\n"), idInfo.certVersion);
printf(("初次受理机关:%s\n"), idInfo.organs);
printf(("证件标识:%s\n"), idInfo.certType);
}
else if (strcmp(idInfo.certType, "J") == 0)
{
printf(("姓 名:%s\n"), idInfo.name);
printf(("性 别:%s\n"), idInfo.sex);
printf(("出身日期:%s\n"), idInfo.birthday);
printf(("住 址:%s\n"), idInfo.address);
printf(("公民身份证号:%s\n"), idInfo.number);
printf(("签发机关:%s\n"), idInfo.organs);
printf(("有效期开始:%s\n"), idInfo.signdate);
printf(("有效期结束:%s\n"), idInfo.validterm);
printf(("通行证号:%s\n"), idInfo.passNu);
printf(("签发数次:%s\n"), idInfo.signCount);
printf(("证件标识:%s\n"), idInfo.certType);
}
else // 除 Y I J三种证件之外的其他证件,一律规视为居民身份证
{
printf(("姓 名:%s\n"), idInfo.name);
printf(("性 别:%s\n"), idInfo.sex);
printf(("民 族:%s\n"), idInfo.people);
printf(("出身日期:%s\n"), idInfo.birthday);
printf(("住 址:%s\n"), idInfo.address);
printf(("公民身份证号:%s\n"), idInfo.number);
printf(("签发机关:%s\n"), idInfo.organs);
printf(("有效期开始:%s\n"), idInfo.signdate);
printf(("有效期结束:%s\n"), idInfo.validterm);
printf(("证件标识:%s\n"), idInfo.certType);
}
}
usleep(1000*100) ;//100ms
}
Donsee_Close();
printf("自动读卡100次结束###################################\n");
break;
default:
printf("输入有误,请输入数字\n");
break;
}
}
火山引擎开发者社区是火山引擎打造的AI技术生态平台,聚焦Agent与大模型开发,提供豆包系列模型(图像/视频/视觉)、智能分析与会话工具,并配套评测集、动手实验室及行业案例库。社区通过技术沙龙、挑战赛等活动促进开发者成长,新用户可领50万Tokens权益,助力构建智能应用。
更多推荐

所有评论(0)