概述
在使用现有的RFID Demo的时候,读取操作时所设置的长度不能超过255words,也就是510 bytes,这个也是Gen2的标准,单次读取的数据量的上限。
一次读取太多的数据还会造成读取的性能不稳定,实际上一次读取128 words就不太稳定了,这个跟具体的标签的性能也很有关系,实际做项目的时候,应该充分测试后,选择一个合适的值作为单次读取和写入的数量。
现在有很多UHF 的RFID标签的用户区的容量都很大,比如1K字节,那么该如何读取大容量的数据区呢?有两种方法,以读取1K字节的数据为例:
调用4次readWait这个SYNC API,每次读取128 words;
readWait offset=0, size=128 words;
readWait offset=128, size=128 words;
readWait offset=256, size=128 words;
readWait offset=384, size=128 words;
如果128 words不稳定,可以每次读64 words,32 words或者更少,调用次数相应增加;
多次调用Actions.TagAccess.OperationSequence.performSequence这个ASYNC API(推荐这种方式 - 性能好)
每次Actions.TagAccess.OperationSequence.add(),每次128 words, add 4个Sequence;
调用4次Actions.TagAccess.OperationSequence.performSequence;
不同的标签读写性能不一样,根据实际测试,调整单次Sequence的读写数据量;调用次数相应增加;
附件是读写320字节的Best Practice,大家可以参考。
RFD8500 样例演示
这个演示应用程序概述了在大约1秒内快速读写10个用户存储区数据块(总共320字节)的最佳实践。
1. 前提条件:下载Android SDK 1.2.0.15版本和RFID演示
app链接如下:
https://www.zebra.cn/us/en/support-downloads/software/developer-tools/rfid-sdk-for-android.html
2. 配置应用预滤器配置
对于访问序列操作:sequence API没有作为访问过滤器的EPC ID的输入参数,因此
操作必须应用预过滤器,以避免多个标签参与库存和读/写访问序列操作
将Singulation控件从默认库存状态A配置到B。
使用EPC配置预过滤器,offset=2 和 动作设置 INV B状态,以匹配Singulation控制:
3. 配置停止触发器
避免多存取读和写操作。设置停止触发器为
• Tag Observation = 1
• Tag timeout = 2000 ms
4.1 代码片段实现快速读取320字节
public static class RfidAccessReadSequenceStart extends AsyncTask<Void, Void, Void>{@Overrideprotected Void doInBackground(Void... params) {//Word by Word Writetry {addOperationReadSequence(yourAppInputOffset[0], yourAppInputWordToRead[0]);addOperationReadSequence(yourAppInputOffset[1], yourAppInputWordToRead[1]);addOperationReadSequence(yourAppInputOffset[2], yourAppInputWordToRead[2]);addOperationReadSequence(yourAppInputOffset[3], yourAppInputWordToRead[3]);addOperationReadSequence(yourAppInputOffset[4], yourAppInputWordToRead[4]);addOperationReadSequence(yourAppInputOffset[5], yourAppInputWordToRead[5]);addOperationReadSequence(yourAppInputOffset[6], yourAppInputWordToRead[6]);addOperationReadSequence(yourAppInputOffset[7], yourAppInputWordToRead[7]);addOperationReadSequence(yourAppInputOffset[8], yourAppInputWordToRead[8]);addOperationReadSequence(yourAppInputOffset[9], yourAppInputWordToRead[9]);}catch (Exception ex){Log.d("ECRT", "UI Input Paramaters Exception=" +ex.getMessage());}try {Log.d("ECRT", "Start Word by Word Write Operation....");mConnectedReader.Actions.TagAccess.OperationSequence.performSequence();} catch (InvalidUsageException e) {e.printStackTrace();} catch (OperationFailureException e) {e.printStackTrace();}return null;}}static boolean addOperationReadSequence(int iWordOffset, int iWordCount){boolean bResult = false;TagAccess tagAccess = new TagAccess();TagAccess.Sequence sequence = tagAccess.new Sequence(tagAccess);TagAccess.Sequence.Operation operation = sequence.new Operation();operation.setAccessOperationCode(ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ);operation.ReadAccessParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_USER);operation.ReadAccessParams.setAccessPassword(0);operation.ReadAccessParams.setByteCount(iWordCount);operation.ReadAccessParams.setByteOffset(iWordOffset);try {mConnectedReader.Actions.TagAccess.OperationSequence.add(operation);bResult = true;} catch (InvalidUsageException e) {e.printStackTrace();} catch (OperationFailureException e) {e.printStackTrace();}return bResult;}
4.2 代码片段实现了320字节的快速写入
public static class RfidAccessWriteWordSequenceStart extends AsyncTask<Void, Void, Void>{@Overrideprotected Void doInBackground(Void... params) {//Word by Word Writetry {addOperationSequenceWrite(yourAppInputOffset[0], yourAppInputWordToRead[0], 0);addOperationSequenceWrite(yourAppInputOffset[1], yourAppInputWordToRead[1], 1);addOperationSequenceWrite(yourAppInputOffset[2], yourAppInputWordToRead[2], 2);addOperationSequenceWrite(yourAppInputOffset[3], yourAppInputWordToRead[3], 3);addOperationSequenceWrite(yourAppInputOffset[4], yourAppInputWordToRead[4], 4);addOperationSequenceWrite(yourAppInputOffset[5], yourAppInputWordToRead[5], 5);addOperationSequenceWrite(yourAppInputOffset[6], yourAppInputWordToRead[6], 6);addOperationSequenceWrite(yourAppInputOffset[7], yourAppInputWordToRead[7], 7);addOperationSequenceWrite(yourAppInputOffset[8], yourAppInputWordToRead[8], 8);addOperationSequenceWrite(yourAppInputOffset[9], yourAppInputWordToRead[9], 9);}catch (Exception ex){Log.d("ECRT", "UI Input Paramaters Exception=" +ex.getMessage());}try {Log.d("ECRT", "Start Word by Word Write Operation....");mConnectedReader.Actions.TagAccess.OperationSequence.performSequence();} catch (InvalidUsageException e) {e.printStackTrace();} catch (OperationFailureException e) {e.printStackTrace();}return null;}}static boolean addOperationSequenceWrite(int iWordOffset, int count, int iSeq){boolean bResult = false;TagAccess tagAccess = new TagAccess();TagAccess.Sequence sequence = tagAccess.new Sequence(tagAccess);TagAccess.Sequence.Operation operation = sequence.new Operation();operation.setAccessOperationCode(ACCESS_OPERATION_CODE.ACCESS_OPERATION_WRITE);operation.WriteAccessParams.setMemoryBank(MEMORY_BANK.MEMORY_BANK_USER);operation.WriteAccessParams.setAccessPassword(0);operation.WriteAccessParams.setByteOffset(iWordOffset);try {byte toWriteData[] = new byte[count * 2];Log.d("ECRT", "write data size = " + toWriteData.length + "byte length, Word Offset=" + iWordOffset);for (int i = 0; i < toWriteData.length; i++) {toWriteData[i] = (byte) (iWordOffset*2 + count*2);}operation.WriteAccessParams.setWriteData(toWriteData);mConnectedReader.Actions.TagAccess.OperationSequence.add(operation);bResult = true;} catch (InvalidUsageException e) {e.printStackTrace();} catch (OperationFailureException e) {e.printStackTrace();}catch (Exception e){Log.d("ECRT", "Excetion=" + e.getMessage());}return bResult;}
5. 代码片测试快速读取320字节
//UIstatic int[] yourAppInputOffset = new int[10];static int[] yourAppInputWordToRead = new int[10];static MEMORY_BANK mUI_MEMORY_BANK = MEMORY_BANK.MEMORY_BANK_USER;yourAppInputOffset[0] = 0;yourAppInputWordToRead[0] = 16; //16 words = 32 bytesyourAppInputOffset[1] = 16;yourAppInputWordToRead[1] = 16; //32yourAppInputOffset[2] = 32;yourAppInputWordToRead[2] = 16; //32yourAppInputOffset[3] = 48;yourAppInputWordToRead[3] = 16; //32yourAppInputOffset[4] = 64;yourAppInputWordToRead[4] = 16; //32yourAppInputOffset[5] = 80;yourAppInputWordToRead[5] = 16; //32yourAppInputOffset[6] = 96;yourAppInputWordToRead[6] = 16; //32yourAppInputOffset[7] = 112;yourAppInputWordToRead[7] = 16; //32yourAppInputOffset[8] = 128;yourAppInputWordToRead[8] = 16; //32 bytesyourAppInputOffset[9] = 144;yourAppInputWordToRead[9] = 16; //Total 160 words = 320 byteif ( id == R.id.action_read){new RfidAccessReadSequenceStart().execute();}
6. 日志输出:320字节的总读取时间= 56.587-55.677 = 910 ms
12-03 16:20:55.677 5330-5379/com.zebra.rfid.rfd8500readmulti D/ECRT: Start Word by Word Read Operation....
12-03 16:20:56.359 5330-5372/com.zebra.rfid.rfd8500readmulti D/ECRT: INVENTORY_START_EVENT
12-03 16:20:56.467 5330-5372/com.zebra.rfid.rfd8500readmulti D/ECRT: OPERATION_END_SUMMARY_EVENT: Total Round=1 Total
Tag=1 Time=104419 us
INVENTORY_STOP_EVENT, Total=0 ,Unique=0
12-03 16:20:56.517 5330-5381/com.zebra.rfid.rfd8500readmulti D/ECRT: Access Read OK for Sequence i=0
,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=1E0008010A4210000E0001010C0202010B460001000000000000000000000000 ,API offset=0
12-03 16:20:56.518 5330-5381/com.zebra.rfid.rfd8500readmulti D/ECRT: i=0
,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=1E0008010A4210000E0001010C0202010B460001000000000000000000000000 ,offset=0 ,API offset=0
Access Read OK for Sequence i=1 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,API offset=16
i=1 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,offset=16 ,API offset=16
Access Read OK for Sequence i=2 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,API offset=32
i=2 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,offset=32 ,API offset=32
Access Read OK for Sequence i=3 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,API offset=48
i=3 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,offset=48 ,API offset=48
12-03 16:20:56.519 5330-5381/com.zebra.rfid.rfd8500readmulti D/ECRT: Access Read OK for Sequence i=4
,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,API offset=64
i=4 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,offset=64 ,API offset=64
Access Read OK for Sequence i=5 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,API offset=80
i=5 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,offset=80 ,API offset=80
12-03 16:20:56.520 5330-5381/com.zebra.rfid.rfd8500readmulti D/ECRT: Access Read OK for Sequence i=6
,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,API offset=96
i=6 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,offset=96 ,API offset=96
Access Read OK for Sequence i=7 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,API offset=112
i=7 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,offset=112 ,API offset=112
Access Read OK for Sequence i=8 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,API offset=128
i=8 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,offset=128 ,API offset=128
Access Read OK for Sequence i=9 ,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,API offset=144
12-03 16:20:56.521 5330-5381/com.zebra.rfid.rfd8500readmulti D/ECRT:
**********************************************
############# Read 10 Blocks 320 bytes OK ##############
**********************************************
12-03 16:20:56.587 5330-5381/com.zebra.rfid.rfd8500readmulti D/ECRT: i=9
,EPC=AAAA0000AAAA1111222233334C60010534FB70CB2000
,Data=0000000000000000000000000000000000000000000000000000000000000000 ,offset=144 ,API offset=144
感谢Max 的经验分享,欢迎你也来帮大家。
谢谢你的关注和转发
最后
以上就是机智白开水为你收集整理的易语言逐条读access数据_读取UHF RFID大容量用户区数据的全部内容,希望文章能够帮你解决易语言逐条读access数据_读取UHF RFID大容量用户区数据所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复