帮同学宣传一下http://shop57644665.taobao.com/

Ref.11.11
SIM卡在系统中连接如下图

Answer To Reset (ATR)
当手机reset SIM时,SIM卡会返回一些信息给手机,这些信息中包含SIM卡对应的一些信息和参数。具体对应可参考ISO/IEC 7816-3
TS:Initial character 高低电平,LSB MSB传输顺序的约定。
T0:Format character 表示接口字符的个数和历史字节的数量。
TA1:Interface character 表示有增强的波特率,公式 3571200 / ( Fi / Di )
TB1:Interface character表示编程电流 I /电压 P,高2位表示电流I,低6位表示电压P
TC1:Interface character 额外保护时间
TD1: Interface character  通讯协议
TA2: 协议T=0 不使用
TB2:不使用。
TC2:额外保护时间
TDi,TAi, TBi, TCi(i>1)
T1,…,TK : Historical characters
TCK: Check character

SIM卡中的内容
SIM卡类似一个文件夹,拥有多个目录和目录下的文件。目录和文件都有一个独立的对应标识。
Master File (MF): The unique mandatory file containing access conditions and optionally DFs and/or EFs.
Dedicated File (DF): A file containing access conditions and, optionally, Elementary Files (EFs) or other Dedicated Files (DFs).
Elementary File (EF): A file containing access conditions and data and no other files.

File identifier
The first byte identifies the type of file, and for GSM is:
- ‘3F’: Master File;
- ‘7F’: 1st level Dedicated File;
- ‘5F’: 2nd level Dedicated File;
- ‘2F’: Elementary File under the Master File;
- ‘6F’: Elementary File under a 1st level Dedicated File;
- ‘4F’: Elementary File under 2nd level Dedicated File.

Dedicated File (DF)
Two 1st level DFs are defined in this specification:
- DFGSM which contains the applications for both GSM and/or DCS 1800;
- DFTELECOM which contains telecom service features.

Elementary File (EF)
An Elementary File (EF) is composed of a header and a body part. The following three structures of an EF are used by GSM.
1. Transparent EF
以binary命令进行操作,由一个byte序列所组成。当对该类型的EF进行读取和更新时应该根据该部分在序列中的偏移量和要读取和更新的长度来进行,第一个byte的偏移量是0.该类型的EF的header表示body的长度。
2. Linear fixed EF
以record命令进行操作,有一组具有相同长度的记录组成。第一条记录的编号是1.该类型的EF的每条记录的长度和数量包含在header中。对该类型EF中具体record的访问可以使用绝对的编号,使用NEXT 或 PREVIOUS,使用seek来定位。
3. Cyclic EF
类似Linear fixed EF以record命令进行操作,有一组具有相同长度的记录顺序组成。最后一条记录的next是第一条记录,此时进行操作会将旧的信息更改。

文件访问条件
每个文件都有自己的访问条件。对于SELECT和STATUS命令总是允许的,而对于READ和SEEK则是需要检查的。
文件访问条件等级如下
Level         Access Condition
0              ALWays
1              CHV1
2              CHV2
3              Reserved for GSM Future Use
4 to 14          ADM
15              NEVer
ALWays:没有限制
CHV1:满足以下3个条件中任意一个1.CHV1值已经被正确提交。2. CHV1启用与禁用标志被设为禁用。3.解除CHV1的值被正确提交。
CHV2:满足以下2个条件中任意一个1.CHV2值已经被正确提交。2.解除CHV2的值被正确提交。
ADM:管理权力,拥有分配以上权力的责任。
NEVer:SIM卡内部使用,不会出现在与外部交互中。