7-SIM数据交互之-B2(READ RECORD)

B2-READ RECORD

B2即获取线性固定EF或者循环EF里面的记录record,该指令一般在C0之后执行,在C0返回的fcp里面可以判断到该文件下是否存在record,record的个数及record的长度,如果存在即可用B2需要读的字节长度。B2与B0的最大不同之处就是B2的个数是不确定的,而B0的个数是固定为一个。

B2指令有如下三种:

  • 读下一条记录:00 B2 00 02 XX(XX代表要读取的长度)
  • 读上一条记录:00 B2 00 03 XX(XX代表要读取的长度)
  • 读当前记录:00 B2 XX 04 XX (XX1代表要读取的第几个记录,XX2代表要读取的长度)

不过我们最常用的还是00 B2 XX 04 XX读当前记录

1.正常读取

当读B2时,解析fcp里面的内容可知B2的个数和每个Record的长度为多少(83之前的三个字节002C07,共07个,每个002C字节),后面就用解析到的长度进行B2的读取即可,00 B2 00 00 XX(长度)

=>00 A4 00 04 02
<=A4
=>2F 06
<=61 1C                 //返回长度0x19
=>00 C0 00 00 19        //读取0x19的fcp数据
<=C0 621A82054221002C0783022F068A01058B032F060480020134880130 9000 //2C07
=>00 B2 01 04 2C
<=B2 8001019000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 9000
=>00 B2 02 04 2C
<=B2 8001019000800102A406830101950108800118A40683010A950108FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 9000
=>00 B2 03 04 2C
<=B2 800101A40683010195010880011AA40683010A950108FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 9000
=>00 B2 04 04 2C
<=B2 800101900080011AA40683010A950108FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 9000
=>00 B2 05 04 2C
<=B2 80010190008001029700800118A40683010A950108FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 9000
=>00 B2 06 04 2C
<=B2 80011BA40683010A950108FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF  9000
=>00 B2 07 04 2C
<=B2 80010190008001029700800118A40683010A950108FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 9000

2.读取少于/多于/00原有记录长度

当读B2时,解析fcp里面的内容可知B2个数为07,长度为2C,但是却只想读取少于0A/多余2F/00/的内容,则就会返回实际长度回来6C开始

=>00 A4 00 04 02
<=A4
=>2F 06
<=61 1C                 //返回长度0x19
=>00 C0 00 00 19        //读取0x19的fcp数据
<=C0 621A82054221002C0783022F068A01058B032F060480020134880130 9000 //2C07
=>00 B2 01 04 0A
<=6C 2C    //返回实际B2长度
=>00 A4 00 04 02
<=A4
=>2F 06
<=61 1C                 //返回长度0x19
=>00 C0 00 00 19        //读取0x19的fcp数据
<=C0 621A82054221002C0783022F068A01058B032F060480020134880130 9000 //2C07
=>00 B2 01 04 2F
<=6C 2C    //返回实际B2长度
=>00 A4 00 04 02
<=A4
=>2F 06
<=61 1C                 //返回长度0x19
=>00 C0 00 00 19        //读取0x19的fcp数据
<=C0 621A82054221002C0783022F068A01058B032F060480020134880130 9000 //2C07
=>00 B2 01 04 00
<=6C 2C    //返回实际B2长度

3.读超过/00原有记录个数

当读B2时,解析fcp里面的内容可知B2个数为07,长度为2C,但是却想读取超过08/00/的记录,则就会返回记录找不到6A 83

=>00 A4 00 04 02
<=A4
=>2F 06
<=61 1C                 //返回长度0x19
=>00 C0 00 00 19        //读取0x19的fcp数据
<=C0 621A82054221002C0783022F068A01058B032F060480020134880130 9000 //2C07
=>00 B2 08 04 2C
<=6A 83   //记录找不到
=>00 A4 00 04 02
<=A4
=>2F 06
<=61 1C                 //返回长度0x19
=>00 C0 00 00 19        //读取0x19的fcp数据
<=C0 621A82054221002C0783022F068A01058B032F060480020134880130 9000 //2C07
=>00 B2 00 04 2C
<=6A 83   //记录找不到

你可能感兴趣的:(7-SIM数据交互之-B2(READ RECORD))