EST-100/EST-100GS/EST-J13X系列Linux开发包(含身份证、社保卡、CPU、M1、磁条卡、银行卡等卡)
广东东信智能科技有限公司DONSEE系列多功能身份证社保卡读卡器Linux系统接口SDK开发包,支持 EST-100、EST-100GS、EST-J13X、EST-100G、EST-100U等机型,功能包括身份证信息读取、社保卡信息读取、IC卡、CPU卡读取,仅供开发人员和测试人员使用。
Linux开发包下载地址:
Linux开发包功能说明:
1、ICC CPU Card:接触式CPU卡
2、PICC CPU(A) Card:非接触式CPU卡
3、M1 Card:M1卡
4、CertCard:身份证卡
如需其他Linux开发包,可以联系张工:13922210502
需要注意的是,Linux 种类众多,分Arm架构和X86 X64构架,不同构架开发包有所不同,Arm的如果是交叉编译,还需要提供交叉编译链。
要提供的信息:
1. linux 操作系统是32位还是64位?
2. 硬件架构是 x86, arm, mips?
3. 你们开发板运行的程序是交叉编译码生成的吗? 交叉编译的环境是什么样的?(ubuntu32/ubuntu64/win32/win64 具体版本)
4. 如果不是交叉编译, 是否是像树莓派这种开发板 直接在开发板编译的?
要提供的文件:
1. 如果是交叉编译
1)请提供交叉编译用的工具链
2)请列出工具链的使用方法(请注明 gcc 在工具链中的具体目录)
2. 如果是类似树莓派这种在板子上编译的,请提供开发板
目前主要编译过以下编译链环境:
32位gcc-linaro arm-linux-gnueabi
海思麒麟32位
arm-arago-linux-gnueabi
gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu
gcc-linaro-5.3-20170216
gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu
gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf
arm_linux_4.8_arm-nuvoton-linux-uclibceabi
gcc-linaro-aarch64-linux-gnu-4.9-2014.07_linux
#include "donsee.h"
int main()
{
long t_nHandle = -99;
int i = 0;
char pszError[128];
unsigned char Response[1024] = {0};
long t_nRe;
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("********************************************************\n");
int t_nIndex;
scanf("%d", &t_nIndex);
if (t_nIndex == 0) //测试版本号和蜂鸣器
{
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
t_nRe = Donsee_Version(Response);
printf("设备版本号:%s\n", Response);
Donsee_Beep(t_nHandle, 0x16);
Donsee_Close();
}
if (t_nIndex == 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;
char t_arrMsg[256];
// nType [in]:设置身份证读卡类型:0,文本信息;1,文本+照片;2,文本+照片+指纹
// nMode [in]:设置读卡模式:0,读卡1次、拿开后放上重读;1,连续读卡
int nType = 1;
int nMode = 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("读身份证失败\n");
Donsee_Close();
return -2;
}
else
{
Donsee_Beep(t_nHandle, 0x16);
printf("读身份证成功\n");
printf(("中文姓名:%s\n"), idInfo.name);
printf(("英文姓名:%s\n"), idInfo.ENfullname);
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(("证件版本:%s\n"), idInfo.certVersion);
printf(("通行证号:%s\n"), idInfo.passNu);
printf(("签发数次:%s\n"), idInfo.signCount);
// printf(("照片文件名:%s\n"), t_cValue);
// printf("1024相片原始数据:\n");
// int i ;
// for ( i = 0; i < 1024; i++)
//{
// printf("%02X ", idInfo.Photo[i]);
//}
// printf("\n");
// if (nType == 2)
//{
// printf("1024指纹数据:\n");
// for ( i = 0; i < 1024; i++)
// {
// ;//printf("%02X ", (unsigned char)idInfo.figData[i]);
// }
// }
Donsee_Close();
}
}
if (t_nIndex == 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("读社保卡失败,MSG:%s\n", pszError);
Donsee_Close();
return -2;
}
else
{
Donsee_Beep(t_nHandle, 0x16);
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();
}
}
if (t_nIndex == 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);
}
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", 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", 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_Beep(t_nHandle, 0x16);
Donsee_Close();
}
if (t_nIndex == 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 设置失败\n") ;
Donsee_Close() ;
return false;
}
long t_nReq = Donsee_ICRequest();
{
printf("TypeA 请求失败\n") ;
Donsee_Close() ;
return false;
}
long t_nAtl = Donsee_ICAnticoll(t_arrDataUID);
{
printf("TypeA 防碰撞失败\n") ;
Donsee_Close() ;
return false;
}
printf("TypeA_Anticoll:%s\n", t_arrDataUID);
long t_nSel = Donsee_ICSelect(0x41);
{
printf("TypeA 选卡失败\n") ;
Donsee_Close() ;
return false;
}
t_nRe = Donsee_PowerOnTypeA(t_arrDataRe);
{
printf("TypeA 上电失败") ;
Donsee_Close() ;
return false;
}
printf("TypeA_ATR:%s\n", t_arrDataRe);
memset(Response, 0, 1024);
printf("TypeA-APDU发送:0084000008\n");
t_nRe = Donsee_APDUType("0084000008", Response);
printf("TypeA-APDU返回:%s\n", Response);
Donsee_Beep(t_nHandle, 0x16);
Donsee_Close();
}
if (t_nIndex == 5) //测试银行卡
{
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
char t_szBankNo[128] = "";
char *p, *q;
unsigned char tmp;
t_nRe = Donsee_GetBankCardNo(t_szBankNo);
if (t_nRe != 0)
printf("读取银行卡号失败\n");
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(t_nHandle, 0x16);
}
Donsee_Close();
}
if (t_nIndex == 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
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_Beep(t_nHandle, 0x16);
Donsee_Close();
}
if (t_nIndex == 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_ColdPowerOn(0x01, Response);
printf("cpu冷复位:%s\n", Response);
memset(Response, 0, 1024);
t_nRe = Donsee_HotPowerOn(0x01, Response);
printf("cpu热复位:%s\n", Response);
memset(Response, 0, 1024);
t_nRe = Donsee_PowerOn(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);
Donsee_Beep(t_nHandle, 0x16);
Donsee_Close();
}
if (t_nIndex == 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(t_nHandle, 0x16);
Donsee_Close();
}
if (t_nIndex == 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(t_nHandle, 0x16);
Donsee_Close();
}
if (t_nIndex == 10) //测试北京通卡
{
t_nHandle = Donsee_Open("USB");
if (t_nHandle != 0)
{
printf("连接读卡器失败,t_nRe = %ld\n", t_nHandle);
return -1;
}
BJT_IDINFO idInfo;
char t_arrMsg[256];
memset(&idInfo, 0, sizeof(BJT_IDINFO));
t_nRe = Donsee_ReadBJTIDCard(&idInfo, t_arrMsg);
if (t_nRe != 0)
{
printf("读取北京通失败\n");
Donsee_Close();
return -2;
}
else
Donsee_Beep(t_nHandle, 0x16);
printf("读取北京通成功\n");
printf(("姓名:%s\n"), idInfo.name);
printf(("性 别:%s\n"), idInfo.sex);
printf(("北京通号:%s\n"), idInfo.cardnumber);
printf(("卡片类型:%s\n"), idInfo.nType);
printf(("证件名称:%s\n"), idInfo.cardName);
printf(("发卡机构:%s\n"), idInfo.organs);
t_nRe = Donsee_ReadBJTIDCard_Photo("./bjt.jpg", t_arrMsg);
if (t_nRe != 0)
{
printf("读取北京通头像失败\n");
Donsee_Close();
return -2;
}
else
printf("读取北京通头像成功\n");
Donsee_Close();
}
if (t_nIndex == 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();
}
}
以下没有删除,主要是保留备份,请勿使用。