http://hi.baidu.com/zhaofeng068318/blog/item/9329ec094f9c78d862d986a2.html
参考 ISO7816 智能卡标准.chm---7916 patr3 Structures and content 1,atr的整体构成:最多不超过32个字节 A reset operation results in the answer from the card consisting of the initial character TS followed by at most 32 characters in the following order: - T0 ................... Format character (Mandatory) - TAi, TBi, TCi, TDi ... Interface characters (Optional) - T1, T2, ... ,TK ...... Historical characters (Optional) - TCK .................. Check character (Conditional) Reset | | _________________________________________ _______ _________ | | | | | | | | | | | | | | | | | '-->| TS| T0|TA1|TB1|TC1|TD1|TA2|TB2|TC2|TD2| ......... | T1| ... | TK|TCK| |___|___|___|___|___|___|___|___|___|___|_ _|___|_ _|__ |___| TS : Initial character TO : Format character TAi : Interface character [ codes FI,DI ] TBi : Interface character [ codes II,PI1 ] TCi : Interface character [ codes N ] TDi : Interface character [ codes Yi+1, T ] T1, ... , TK : Historical characters (max,15) TCK : Check character Figure : General configuration of the Answer to Reset 2,atr的第一个字节TS,也就是atr[0]的位说明: The two possible values of TS (ten consecutive bits from start to bi and corresponding hexadecimal value) are - Inverse convention : (Z)ZZAAAAAZ - Direct convention : (Z)ZZAZZZAAZ Start ba bb bc bd be bf bg bh bi Z ____ _______ ___________ ______ | | | | | Z Z Z | | | | (Z)| A | Z Z | A | or | | Z (Z) A |___| |___|_A___A___A_|___|___| Figure : Initial character TS 上面是对TS也就是atr的第一个字节atr[0]的说明: 当TS的逻辑电平时A时,atr[0]=3B,正向传输; 当TS的逻辑电平时Z时,atr[0]=3F,反向传输。 3,atr的第二个字节atr[1],也就是T0的位说明: 主要是其中的b1-b4组成的K,来说明历史字节数。这4个为最大可以表示15,这个K表明在这个字节后面还跟有K个历史字节,除开这K个 历史字节后才是真正的atr数据。 Format character T0 - The most significant half byte (b5, b6, b7, b8) is named Y1 and indicates with a logic level ONE the presence of subsequent characters TA1, TB1, TC1, TD1 respectively. - The least significant half byte (b4 to b1) is named K and indicates the number (0 to 15) of historical characters. ,----,----,----,----,----,----,----,----, | b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 | '----'----'----'----'----'----'----'----' :<------- Y1 ------>:<-------- K ------>: Y1 : indicator for the presence of the interface characters TA1 is transmitted when b5=1 TB1 is transmitted when b6=1 TC1 is transmitted when b7=1 TD1 is transmitted when b8=1 K : number of hitorical characters Figure : Informations provided by T0 4,协议类型说明字节:TAi, TBi, TCi (i=1, 2, 3, ... ) indicate the protocol parameters 此段代码就是根据上面的协议来解析atr数据的,可以仔细参考 nRet = eis_smartcard_reset(index, atr); |