gcc-linaro-5.3.1 arm-linux-gnueabi ubuntu64 linux身份证读卡器开发包源码

问题汇总:

  1. linux 操作系统是32位还是64位?
    32位
  2. 硬件架构是 x86, arm, mips?
    arm
  3. 你们开发板运行的程序是交叉编译码生成的吗? 交叉编译的环境是什么样的?(ubuntu32/ubuntu64/win32/win64 具体版本)
    ubuntu64
  4. 如果不是交叉编译, 是否是像树莓派这种开发板 直接在开发板编译的?
    交叉编译
  5. 编译链是什么
    gcc-linaro-5.3.1 arm-linux-gnueabi
  6. 身份证读卡器支持什么接口的?
    支持USB 和RS232串口
    0.接入东信EST-100身份证读卡器到Linux系统

安装步骤:
0.接入东信EST-100身份证读卡器到Linux系统
1.切换到root用户:sudo su
1.1输入系统密码:
1.2解压目标文件并进入到该文件夹路径中
2.指定库文件路径:export LD_LIBRARY_PATH=$PWD/lib
3.进入到main 文件路径:cd main
4.编译:make
5.执行程序: ./main


#include "../inc/est100.h"
#include <string.h>
#include <stdio.h>


static long 	handle;


//print a line of characters
static void printchar(char ch, int len)
{
	while(len--)
	{
			printf("%c", ch);
	}
	printf("\n");
}

static void printchar_txt(char ch, char *pText)
{
	printf("%c\t%s\n", ch, pText);
}

static void printByteArray(char *Tag, unsigned char *pSrc, int ilen)
{
	int		i = 0;

	printf( "%s", Tag );
	while( i<ilen )
	{
			printf( "%02X ", pSrc[i] );
			i++;
	}
	printf( "\n" );
}

static void ShowToEdit(const char* tag, const char* msg)
{
	printf( "%s\t%s\n", tag, msg );
}

static void CertCard_Test()
{
	int					nRt, i;
	char pName[70]={0};
	char pSex[10]={0};
	char pNation[10]={0};
	char pBirth[50]={0};
	char pAddress[100]={0};
	char pCertNo[50]={0};
	char pDepartment[100]={0};
	char pEffectData[50]={0};
	char pExpire[20]={0};
	char pErrMsg[50]={0};
	
	char pEnName[150] = { 0 };
	char pEnNation[50] = { 0 };
	char pAuthorCode[150] = { 0 };
	char pCardVersion[150] = { 0 };

	char pTXZHM[50] = { 0 };
	char pTXZQFCS[10] = { 0 };
	
	nRt = PICC_ReadIDCard(handle);
	if ( nRt != 0 )
	{
		printf( "ReadCertCard fail! nRet=%d\n", nRt );
		return;
	}

	if(GetCardType() == 0)
	{
		GetName(pName);
		GetSex(pSex);
		GetNation(pNation);
		GetBirth(pBirth);
		GetAddress(pAddress);
		GetCertNo(pCertNo);
		GetDepartemt(pDepartment);
		GetEffectDate(pEffectData);
		GetExpireDate(pExpire);

		ShowToEdit( "姓名:", (pName));
		ShowToEdit( "性别:", (pSex));
		ShowToEdit( "民族:", (pNation));
		ShowToEdit( "出生日期:", (pBirth));
		ShowToEdit( "地址:", (pAddress));
		ShowToEdit( "身份证号:", (pCertNo));
		ShowToEdit( "签发机关:", (pDepartment));
		ShowToEdit( "有效起始日期:", (pEffectData));
		ShowToEdit( "有效截止日期:", (pExpire));
		
	}
	if(GetCardType() == 1)
	{
		GetName(pName);
		GetEnName(pEnName);
		GetSex(pSex);
		GetNationalityCode(pEnNation);
		GetBirth(pBirth);
		GetCertNo(pCertNo);
		GetEffectDate(pEffectData);
		GetExpireDate(pExpire);
		GetCardVersion(pCardVersion);

		ShowToEdit( "中文姓名:", (pName));
		ShowToEdit( "英文姓名:", (pEnName));
		ShowToEdit( "性别:", (pSex));
		ShowToEdit( "国籍代码:", (pEnNation));
		ShowToEdit( "永久居留证号码:", (pCertNo));	
		ShowToEdit( "出生日期:", (pBirth));
		ShowToEdit( "证件签发日期:", (pEffectData));
		ShowToEdit( "证件终止日期:", (pExpire));
		ShowToEdit( "证件版本:", (pCardVersion));
	}
	if(GetCardType() == 2)
	{
		GetName(pName);
		GetSex(pSex);
		
		GetBirth(pBirth);
		GetAddress(pAddress);
		GetCertNo(pCertNo);
		GetDepartemt(pDepartment);
		GetEffectDate(pEffectData);
		GetExpireDate(pExpire);
		GetTXZHM(pTXZHM);
		GetTXZQFCS(pTXZQFCS);

		ShowToEdit( "姓名:", (pName));
		ShowToEdit( "性别:", (pSex));
		ShowToEdit( "出生日期:", (pBirth));
		ShowToEdit( "地址:", (pAddress));
		ShowToEdit( "身份证号:", (pCertNo));
		ShowToEdit( "签发机关:", (pDepartment));
		ShowToEdit( "有效起始日期:", (pEffectData));
		ShowToEdit( "有效截止日期:", (pExpire));
		ShowToEdit( "通行证号码:", (pTXZHM));
		ShowToEdit( "通行证签发次数:", (pTXZQFCS));
	}
	char szPhotoPath[255] = { 0 };
	sprintf(szPhotoPath, "../list/%s.bmp", pCertNo);

	GetBmpFile("../lib/libwlt.so", szPhotoPath);

}



static void ICC_CPUCard_Test()
{
		int				nRt, i;
		unsigned char 	slot	 = 0x01;
		unsigned char 	cmd[255] = { 0 };
		unsigned char	resp[255]= { 0 };
		unsigned char	ATR[60]	 = { 0 };
		int				lenth_of_cmd;
		
		// Get 8 byte Random
		cmd[0] = 0x00;
		cmd[1] = 0x84;
		cmd[2] = 0x00;
		cmd[3] = 0x00;
		cmd[4] = 0x08;
		lenth_of_cmd = 5;

		//CPU Card PowerOn
		nRt = ICC_Reader_pre_PowerOn( handle, slot, resp );
		if( nRt < 0 )
		{
				printf( "CPU Card PowerOn fail! ret=%d\n", nRt );
				return;
		}
		
		printByteArray( "ATR: ", resp, nRt );

		printByteArray( "CMD: ", cmd, lenth_of_cmd );

		//Send APDU CMD
		memset( resp, 0, 250 );
		nRt = ICC_Reader_Application( handle, slot, lenth_of_cmd, cmd, resp );
		if( nRt < 0 )
		{
				printf( "send APDU CMD fail! ret=%d\n", nRt );
				return;
		}

		printByteArray( "Resp: ", resp, nRt );
}


static void PICC_CPUCard_Test()
{
	int             nRt, i;
	unsigned char   uid[15]  = { 0 };
	unsigned char   cmd[255] = { 0 };
	unsigned char   resp[255]= { 0 };
	unsigned char   ATR[60]  = { 0 };
	int             lenth_of_cmd;
	
	// Get 8 byte Random
	cmd[0] = 0x00;
	cmd[1] = 0x84;
	cmd[2] = 0x00;
	cmd[3] = 0x00;
	cmd[4] = 0x08;
	lenth_of_cmd = 5;

	//CPU Card PowerOn
	if( PICC_Reader_SetTypeA( handle ) != 0 )
	{
		printf( "PICC_Reader_SetTypeA fail! ret=%d\n", nRt );
		return;
	}

	if( PICC_Reader_Request( handle ) != 0 )
	{
		printf( "PICC_Reader_Request fail! ret=%d\n", nRt );
		return;
	}

	if( PICC_Reader_anticoll( handle, uid ) != 0 )
	{
		printf( "PICC_Reader_anticoll fail! ret=%d\n", nRt );
		return;
	}

	if( PICC_Reader_Select( handle, 0x41 ) != 0 )
	{
		printf( "PICC_Reader_Select fail! ret=%d\n", nRt );
		return;
	}

	nRt = PICC_Reader_PowerOnTypeA( handle, resp );
	if( nRt < 0 )
	{
		printf( "TypeA CPU Card PowerOn fail! ret=%d\n", nRt );
		return;
	}

	printByteArray( "ATR: ", resp, nRt );

	printByteArray( "CMD: ", cmd, lenth_of_cmd );

	memset( resp, 0, 250 );
	nRt = PICC_Reader_Application( handle, lenth_of_cmd, cmd, resp );
	if( nRt < 0 )
	{
		printf( "send APDU CMD fail! ret=%d\n", nRt );
		return;
	}
	printByteArray( "Resp: ", resp, nRt );
}


static void M1Card_Test()
{
	int             nRt, i;
	unsigned char   uid[15]		= { 0 };
	unsigned char   password[7] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 };
	unsigned char   resp[255]	= { 0 };
	unsigned char	addr		= 0x04;
	unsigned char	sncr		= 0x01;
	unsigned char	mode		= 0x60;

	

	//CPU Card PowerOn
	if( PICC_Reader_SetTypeA( handle ) != 0 )
	{
		printf( "PICC_Reader_SetTypeA fail! ret=%d\n", nRt );
		return;
	}

	if( PICC_Reader_Request( handle ) != 0 )
	{
		printf( "PICC_Reader_Request fail! ret=%d\n", nRt );
		return;
	}

	if( PICC_Reader_anticoll( handle, uid ) != 0 )
	{
		printf( "PICC_Reader_anticoll fail! ret=%d\n", nRt );
		return;
	}

	if( PICC_Reader_Select( handle, 0x41 ) != 0 )
	{
		printf( "PICC_Reader_Select fail! ret=%d\n", nRt );
		return;
	}

	printByteArray( "UID: ", uid, 4 );

	nRt = PICC_Reader_Authentication_Pass( handle, mode, sncr, password );
	if ( nRt != 0 )
	{
		printf( "PICC_Reader_Authentication_Pass fail! ret=%d\n", nRt );
		return;
	}

	nRt = PICC_Reader_Read( handle, addr, resp );
	if( nRt != 0 )
	{
		printf( "PICC_Reader_Read fail! ret=%d\n", nRt );
		return;
	}
	printByteArray( "Data: ", resp, 16 );
}



int main(void)
{
	
	long 	nRt;
	int		nval;
	
	handle = ICC_Reader_Open( "USB1" );
	if( handle < 0 )
	{
		printf( "open fail! \n" );
		return 0;
	}

	printchar( '#', 80 );
	printchar_txt( '#', "please choose the action you want:" );
	printchar_txt( '#', "1.Select ICC CPU Card." );
	printchar_txt( '#', "2.Select PICC CPU(A) Card." );
	printchar_txt( '#', "3.Select M1 Card." );
	printchar_txt( '#', "4.Select CertCard." );
	printchar( '#', 80 );

	scanf( "%d", &nval );
	

	switch( nval )
	{
			case 1:
				{
						printf( "\tICC_CPU_CARD.\n" );
						ICC_CPUCard_Test();
				}
				break;
			case 2:
				{
						printf( "\tPICC_CPU(A)_CARD.\n" );
						PICC_CPUCard_Test();
				}
				break;
			case 3:
				{
						printf( "\tM1_CARD.\n" );
						M1Card_Test();
				}
				break;
			case 4:
				{
						printf( "\tCertCard.\n" );
						CertCard_Test();
				}
				break;
			default:
					printf( "enter err!\n" );
					break;
	}

	ICC_PosBeep( handle, 10 );
	ICC_Reader_Close(handle);
	return 0;
}









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值