




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、HD系列关于接触式卡编程说明作者:技术支持部 胡富云标准支持及接口介绍HD系列的III型机与IV型机支持接触式IC读写ICC_memcard_atr() activates the designated Synchronous IC card and waits for itsATR.short ICC_memcard_atr(unsigned char * dbuf,unsigned char * len,unsigned short vol_index) ;1、4428接触式存储卡Read_4428_With_PB( )Read data bytes of 4428 and their a
2、ssociated protection bits.short Read_4428_With_PB(unsigned short StartPos,unsigned short NOB,char * Bfr,char * PB_Bfr) ;Read_4428_NO_PBRead data bytes of 4428 card.short Read_4428_NO_PB (unsigned short StartPos,unsigned short NOB,char * Bfr) ;Write_4428( )Write one byte of data and associated protec
3、tion bit (if required) into 4428.short Write_4428 (unsigned short StartPos,char DestByte,char PBSetFlag) ;Verify_4428_PSC( )Verify the 2-byte PSC of 4428short Verify_4428_PSC (char PSC1,char PSC2) ;详细介绍请参见基本API说明示例:if (ICC_sock_check(ICC_SOCK_MAIN) = ICC_SOCK_CARD_PRESENT)/检测到卡片ICC_interface_power(I
4、CC_POWER_ON);/卡座上电ICC_select_sock(ICC_SOCK_MAIN);/选择主卡座rcode = ICC_memcard_atr(abuff, &alen, ICC_VOLTAGE_5);/存储卡ATRif (!rcode)if (*(unsigned long *)abuff) = ATR_SLE4428)/4428卡if (Verify_4428_PSC(0xFF, 0xFF)/密码校验ErrorBeep(0);DispStr_CE(0, 1, "卡片密码校验错误", DISP_POSITION | DISP_CLRSCR);goto
5、 Card4428Error;elsememset(crwBuf, 0, 64);Read_4428_With_PB(0x20, 0x30, crwBuf, stmp); /从起始地址20H读30H字节到crwBuf中set_console_english();clear_console();move_cursor(0, 0);for (m = 0; m < 6; m+)/显示读取的内容for (n = 0; n < 8; n+)goto_xy(n * 16, m);printf("%02X", crwBufm * 8 + n);for(m = 0; m <
6、; 48; m +)if(Write_4428(0x20 + m, crwBufm, 0) /单字节取反回写ErrorBeep(0);DispStr_CE(0, 1, "写卡失败", DISP_POSITION | DISP_CLRSCR);goto Card4428Error;RightBeep();goto_xy(0, 7);printf("press any to return");goto Card4428OK;elseErrorBeep(0);DispStr_CE(0, 1, "非4428接触卡", DISP_POSITIO
7、N | DISP_CLRSCR);goto Card4428Error;2、4442接触式存储卡Read_4442_NO_PB( )This function reads data bytes of 4442 card without protection bits.short Read_4442_NO_PB (unsigned short StartPos,unsigned short NOB,char * Bfr) ;Read_4442_PB( )Read all the protection bits of 4442.short Read_4442_PB (char * PB_Bfr)
8、;Write_4442( )Write 1 byte data to 4442. If required write protection bit.short Write_4442 (unsigned short StartPos,char DestByte,char PBSetFlag) ;Verify_4442_PSC( )Verify the 3-byte PSC of 4442short Verify_4442_PSC (char PSC1,char PSC2,char PSC3) ;详细介绍请参见基本API说明,4442卡与4428卡编程类似。3、SAM卡接触式智能卡ICC_cpuc
9、ard_ATR () activates the designated asynchronous IC card and waits for itsATR.short ICC_cpucard_ATR (unsigned char * dbuf,unsigned char * len,unsigned short clk_index,unsigned short vol_index,unsigned short ATR_FiDi,unsigned short flags) ;ATR CheckThese functions check if the ATR of the card is comp
10、atible with ISO7816-3 & EMV orPBOC (Peoples Bank of China) standards. Card communication parameters are setaccording to the standards if so. This function also checks if the protocol type specified inthe card ATR is available in this version of hardware.short EMV_ISO_atr_check (unsigned char * p
11、Buff,unsigned char len) ;short PBOC_atr_check (unsigned char * pBuff,unsigned char len) ;ICC_CPU_get_param() reads the internal control parameters of the card in currentsocket.typ_cpucard_param * ICC_cpucard_get_param (void) ;short ICC_cpucard_set_param (typ_cpucard_param * pSrc) ;short ICC_cpucard_
12、PTS(unsigned char * pPTS_request,unsigned short len_PTS_request,unsigned char * pPTS_responce,unsigned char * len_PTS_response) ;Data Exchange For T=0ICC_T0_TPDU() is a TPDU exchange subroutine for T=0 CPU card.short ICC_T0_TPDU(short isIn,short CLA,short INS,short P1,short P2,short P3,unsigned char
13、 * databuff,unsigned short * pSW);Data Exchange For T=1ICC_TO_frame() is a frame exchange subroutine for T=1 CPU card.short ICC_T1_frame(unsigned char * pfrm_send,unsigned short len_send,unsigned char * pfrm_rx,unsigned short * len_rx) ;示例9600init_sam_9600(SAM_0015)int rcode, i;unsigned short rc, SW
14、;unsigned char abuff256, tbuff256,alen, ch;typ_cpucard_param tcp;ICC_interface_power(ICC_POWER_ON);ICC_select_sock(ICC_SOCK_SAM);memset(abuff, 0, sizeof(abuff);for(i = 0; i < 5; i+)rcode = ICC_cpucard_ATR(abuff, &alen, ICC_CLOCK_4M, ICC_VOLTAGE_5, 0x11, 1);/ATR,此处为以4M的时钟频率,9600标准,电压5Vif(rcode
15、 = 0)EMV_ISO_atr_check(abuff, alen);/给SAM卡加速break;rc = ICC_T0_TPDU(1, 0, 0xb0, 0x95, 0, 16, tbuff, &SW);/进行T=0的通讯if (rc)return 0x00950000;elseif (SW = 0x9000)memset(SAM_0015, 0, 20);memcpy(SAM_0015, tbuff, 16);elsereturn 0x00950000 | SW;38400unsigned char init_sam_38400(SAM_0015)unsigned short r
16、code = 1;unsigned char abuff200;unsigned char alen, ch, i;unsigned short rc, SW;unsigned char tbuff256, bcdBuffer256;typ_long2char tmplc;typ_cpucard_param tcp;ICC_select_sock(ICC_SOCK_MAIN);memset(abuff, 0, sizeof(abuff);for(i = 0; i < 5; i+)rcode = ICC_cpucard_ATR(abuff, &alen, ICC_CLOCK_4M, ICC_VOLTAGE_5, 0x13, ICC_CPUC_ATR_FLAG_LONGATR);/ATR,此处为以4M的时钟频率,38400 标准,电压5Vif(rcode = 0)break;if(rcode != 0)return 1;/以下部分为对SAM卡进行通讯加速ch = PBOC_atr_check(abuff, alen);if(ch=0)return 2;tcp = *ICC_cpucard_get_param();tcp.Fi = 1;tcp.Di
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年原乙酸三甲酯合作协议书
- 2025年高效余热回收装置合作协议书
- 农业生产中精准信息技术合作实施协议
- 智能农业解决方案供应与维护协议
- 制造业离职证明及再就业指南(7篇)
- 2025年哈密危运资格证考试题
- 农村耕地长期流转合同书
- 2025年碳酸甲乙酯合作协议书
- 农业技术推广合同
- 别墅建筑工程承包协议
- 蜱虫预防卡通
- 股骨干骨折知识
- 非遗文化产业发展-深度研究
- 2024年认证行业法律法规及认证基础知识答案
- 基于大数据的社区健康监测-深度研究
- 丙酸铬、淀粉酶对黄羽肉鸡生长性能、抗氧化和肠道健康的影响
- 光伏发电新能源课件
- 《无人机电力巡检红外图像分析技术规范》
- 2025年广东省高中学业水平考试综合测评卷(二)政治试题(含解析)
- 老旧小区改造给排水施工方案
- 医院员工保密协议书模板2025年
评论
0/150
提交评论