我正在使用Motorola Scanner SDK和Motorola DS9808-SR rfid阅读器测试CS8300 RFID tag。
基本上,所有简单任务都有效:让扫描器发出蜂鸣声,通过属性35001获取epcID等;的除了:
在通过属性 35002 指定标签ID后,我始终从属性35009获取状态2(表示未找到标签')。注意:Attribute Explained in this doc
正如您在我的代码中看到的那样(第80行'属性 35002 设置'),我尝试了许多不同格式的epcID,例如 0080B0403C0000000C015F85 或 0x00 0x0e 0x08 0x80 0x00 0x80 0xb0 0x40 0x3c 0x00 0x00 0x00 0x0c 0x01 0x5f 0x85 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 , 但都没有用。
我错过了什么?顺便说一下,我已经测试了几个BAP标签。标签本身很好,因为它们可以被其他读者/ SDK读取。
我的代码:
using System;
using System.Collections.Generic;
using System.Text;
using CoreScanner;
namespace SampleApplication
{
class Program //page 118 Motorola Scanner SDK for Windows Developer Guide.pdf
{
// Declare CoreScannerClass
static CCoreScannerClass cCoreScannerClass;
static void Main(string[] args)
{
//Instantiate CoreScanner Class
cCoreScannerClass = new CCoreScannerClass();
//Call Open API
short[] scannerTypes = new short[1]; // Scanner Types you are interested in
scannerTypes[0] = 1; // 1 for all scanner types
short numberOfScannerTypes = 1; // Size of the scannerTypes array
int status; // Extended API return code
cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status);
if (status == 0)
{
Console.WriteLine("CoreScanner API: Open Successful");
}
else
{
Console.WriteLine("CoreScanner API: Open Failed");
}
// Lets list down all the scanners connected to the host
short numberOfScanners; // Number of scanners expect to be used
int[] connectedScannerIDList = new int[255];
// List of scanner IDs to be returned
string outXML; //Scanner details output
cCoreScannerClass.GetScanners(out numberOfScanners, connectedScannerIDList, out outXML, out status);
Console.WriteLine(outXML);
//// Let's beep the beeper
//int opcode = 6000; // Method for Beep the beeper
//string outXMLBeep; // Output
//string inXML = "<inArgs>" +
// "<scannerID>1</scannerID>" + // The scanner you need to beep
// "<cmdArgs>" +
// "<arg-int>3</arg-int>" + // 4 high short beep pattern
// "</cmdArgs>" +
// "</inArgs>";
//cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXMLBeep, out status);
//Console.WriteLine(outXMLBeep);//null
//// Let's set the UPC-A enable/disable
//int opcode = 5004; // Method for Set the scanner attributes
//string outXMLUPC; // XML Output
//string inXML = "<inArgs>" +
// "<scannerID>1</scannerID>" + // The scanner you need to get the information (above)
// "<cmdArgs>" +
// "<arg-xml>" +
// "<attrib_list>" +
// "<attribute>" +
// "<id>1</id>" + // Attribute number for UPC-A from the Attribute Data Dictionary (above)
// "<datatype>F</datatype>" +
// "<value>False</value>" +
// "</attribute>" +
// "</attrib_list>" +
// "</arg-xml>" +
// "</cmdArgs>" +
// "</inArgs>";//This method does not show any output but it sets the UPC-A to enable (True) or disable (False).
//cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXMLUPC, out status);
//Console.WriteLine(outXMLUPC);
// Let's set the user data reading attributes
int opcode = 5004; // Method for Set the scanner attributes
string outXMLUserData0; // XML Output
string inXML = "<inArgs>" +
"<scannerID>1</scannerID>" + // The scanner you need to get the information (above)
"<cmdArgs>" +
"<arg-xml>" +
"<attrib_list>" +
"<attribute>" +
"<id>35002</id>" +
"<datatype>A</datatype>" +//<!-- get it using <attrib_list>35001</attrib_list> -->0080B0403C0000000C015F85
"<value>000e08800080B0403C0000000C015F85</value>" +//0x00 0x0e 0x08 0x80 0x00 0x80 0xb0 0x40 0x3c 0x00 0x00 0x00 0x0c 0x01 0x5f 0x85 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 000e08800080B0403C0000000C015F85000000000000000000000000000000000000
"</attribute>" +
"<attribute>" +//"<!-- bank -->" +
"<id>35003</id>" +
"<datatype>B</datatype>" +
"<value>3</value>" +
"</attribute>" +
"<attribute>" +//"<!-- offset -->" +
"<id>35005</id>" +
"<datatype>W</datatype>" +
"<value>1</value>" +
"</attribute>" +
"<attribute>" +// "<!-- length -->" +
"<id>35006</id>" +
"<datatype>W</datatype>" +
"<value>0</value>" +
"</attribute>" +
"<attribute>" +// "<!-- command -->" +
"<id>35008</id>" +
"<datatype>B</datatype>" +
"<value>1</value>" +
"</attribute>" +
"</attrib_list>" +
"</arg-xml>" +
"</cmdArgs>" +
"</inArgs>";
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXMLUserData0, out status);
Console.WriteLine(status);
// Let's retrieve assert tracking information
int opcode1 = 5001; // Method for Get the scanner attributes
string outXMLRetrieve; // XML Output
string inXML1 = "<inArgs>" +
"<scannerID>1</scannerID>" + // The scanner you need to get the information
"<cmdArgs>" +
"<arg-xml>" +
"<attrib_list>35009,35004</attrib_list>" + // attribute numbers you need
"</arg-xml>" +
"</cmdArgs>" +
"</inArgs>";
cCoreScannerClass.ExecCommand(opcode1, ref inXML1, out outXMLRetrieve, out status);
Console.WriteLine(status + "\r\n" + outXMLRetrieve);
if (System.Diagnostics.Debugger.IsAttached)
Console.ReadLine();
}
}
}
答案 0 :(得分:0)
数组类型属性应该是空格分隔的十六进制缓冲区的问题。
因此35002
格式应为0x00 0x0e 0x08 0x80 0x00 0x80 0xb0 0x40 0x3c 0x00 0x00 0x00 0x0c 0x01 0x5f 0x85 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
。
请告诉我设置属性号35008的原因是什么?