HD系列關(guān)于接觸式卡編程說明_第1頁
HD系列關(guān)于接觸式卡編程說明_第2頁
HD系列關(guān)于接觸式卡編程說明_第3頁
HD系列關(guān)于接觸式卡編程說明_第4頁
HD系列關(guān)于接觸式卡編程說明_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

1、HD系列關(guān)于接觸式卡編程說明作者:技術(shù)支持部 胡富云標(biāo)準(zhǔn)支持及接口介紹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) ;詳細(xì)介紹請參見基本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字節(jié)到crwBuf中set_console_english();clear_console();move_cursor(0, 0);for (m = 0; m < 6; m+)/顯示讀取的內(nèi)容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) /單字節(jié)取反回寫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) ;詳細(xì)介紹請參見基本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標(biāo)準(zhǔn),電壓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 標(biāo)準(zhǔn),電壓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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論