- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在为摩托罗拉 MC9190 RFID 手持阅读器开发应用程序。
我需要在 UHF RFID 标签中读取和写入人类可读的信息。所以我决定用ASCII字符写信息。
在做一些研究时,我发现可以在 RFID 标签内存中写入 ASCII 字符,但它支持的字符较少。我不会介意,除非它少于 10 个字符。
引用资料:
http://blog.atlasrfidstore.com/types-of-memory-in-gen-2-uhf-rfid-tags
现在,我有点困惑如何在阅读器中直接写入和读取 ASCII 字符。
这是十六进制字符写入的代码。
private void writeButton_Click(object sender, EventArgs e)
{
string dataToWrite="ABCDEF9876";
Symbol.RFID3.TagAccess.WriteAccessParams m_WriteParams;
m_WriteParams.AccessPassword = 0;
m_WriteParams.MemoryBank = MEMORY_BANK.MEMORY_BANK_USER;
m_WriteParams.ByteOffset = 0;
m_WriteParams.WriteDataLength = 6;
byte[] writeData = new byte[m_WriteParams.WriteDataLength];
for (int index = 0; index < m_WriteParams.WriteDataLength; index += 2)
{
writeData[index] = byte.Parse(dataToWrite.Substring(index * 2, 2),
System.Globalization.NumberStyles.HexNumber);
writeData[index + 1] = byte.Parse(dataToWrite.Substring((index + 1) * 2, 2),
System.Globalization.NumberStyles.HexNumber);
}
m_WriteParams.WriteData = writeData;
string m_SelectedTagID = "0123456789ABCDEF"; //for example
RunWriteOperation(m_SelectedTagID,m_WriteParams);
}
void RunWriteOperation(string m_SelectedTagID,Symbol.RFID3.TagAccess.WriteAccessParams m_WriteParams)
{
if (m_SelectedTagID != String.Empty)
{
m_ReaderAPI.Actions.TagAccess.WriteWait(m_SelectedTagID,m_WriteParams, null);
}
}
如果我想用 ASCII 写入,我想应该将其编码为 ASCII 字节。那么如果我替换下面的代码而不是 for 循环,它会写入成功吗?
string dataToWrite="HELLOWORLD";
byte[] writeData = ASCIIEncoding.ASCII.GetBytes(dataToWrite);
因为我没有带阅读器,所以我现在无法测试。
如果成功,在读取标签时,如何配置读取器解码为 ASCII 字符并显示它,还是需要以编程方式转换?
由于我是 RFID 技术的新手,我不确定自己是否正确地进行了研究。如果我错了,请纠正我。
最佳答案
void hex2dec(unsigned adchex,unsigned value)
{
unsigned value[4];
for(i=0;i<4;i++)
{
value[i]=adchex%10;
// value[i]=adchex%10+0x30; //for ASCII presentation
adchex=adchex/10;
}
}
您还可以在这里查看此 SDK: http://www.tsl.uk.com/2013/07/tsls-ios-uhf-ascii-2-0-sdk-v0-8-1-now-available/
TSLAsciiCommands.framework - 一组易于使用的 Objective C 类,封装了 TSL UHF ASCII 2.0 协议(protocol),作为通用静态框架提供,可用于 iOS 设备和 iOS 模拟器- TSL ASCII 2.0 SDK 文档 – 可作为用于在 Xcode 中集成的文档集和 HTML 格式提供- 快速启动示例 Xcode 项目
如果您使用 TSLAsciiCommands 框架,您可以执行类似的操作。
-(void)initAndShowConnectedReader
{
if( _commander.isConnected )
{
// Display the serial number of the successfully connected unit
[self.selectReaderButton setTitle:_currentAccessory.serialNumber forState:UIControlStateNormal];
// Ensure the reader is in a known (default) state
// No information is returned by the reset command
TSLFactoryDefaultsCommand * resetCommand = [TSLFactoryDefaultsCommand synchronousCommand];
[_commander executeCommand:resetCommand];
// Notify user device has been reset
if( resetCommand.isSuccessful )
{
self.resultsTextView.text = [self.resultsTextView.text stringByAppendingString:@"Reader reset to Factory Defaults\n"];
}
else
{
self.resultsTextView.text = [self.resultsTextView.text stringByAppendingString:@"!!! Unable to reset reader to Factory Defaults !!!\n"];
}
// Update the version information for the connected reader
[_commander executeCommand:self.versionInformationCommand];
if( [self.class comparableVersionValue:self.versionInformationCommand.asciiProtocol] < [self.class comparableVersionValue:MINIMUM_ASCII_PROTOCOL_VERSION_FOR_LICENCE_KEY_COMMAND] )
{
[self updateResults:[NSString stringWithFormat:@"Reader does not support licence keys\nRequires ASCII protocol: %@\nReader ASCII protocol: %@\n",
MINIMUM_ASCII_PROTOCOL_VERSION_FOR_LICENCE_KEY_COMMAND,
self.versionInformationCommand.asciiProtocol
]];
}
[self validateReader];
}
else
{
[self.selectReaderButton setTitle:@"Tap to select reader..." forState:UIControlStateNormal];
[self updateUIState];
}
}
或
// Write data to general tag memory
string tagDataStr = "HELLO WORLD!";
byte[] tagData = ASCIIEncoding.ASCII.GetBytes(tagDataStr);
byte memBank = 0; // Different memory banks serve different purposes. See MC9190 specifications.
int addr = 0;
byte words = (byte)(tagData.Length / 2); // Words = length of msg / 2
if (UHFWriteTagData(theHandle, readerType, memBank,addr, tagData, (byte)tagData.Length, out errValue) == 0)
{
// Handle Error
}
// Read data from tag memory
byte[] readTagData = new byte[512];
int bytesRead;
if (UHFReadTagData(theHandle, readerType, memBank, addr, words, readTagData,
readTagData.Length, out bytesRead, out errValue) == 0)
{
// Handle Error
}
// Display Results
string results =
"Input tag ID: " +
tagIDStr +
Environment.NewLine +
"Read tag ID: " +
ASCIIEncoding.ASCII.GetString(readTagID).Replace('\0','-') +
Environment.NewLine +
"Input tag data: " +
tagDataStr +
Environment.NewLine +
"Read tag data: " +
ASCIIEncoding.ASCII.GetString(readTagData).Replace('\0', '-').Substring(0,bytesRead) +
Environment.NewLine;
MessageBox.Show(results);
关于c# - 是否可以在 UHF RFID 标签中写入和读取 ASCII 字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31630552/
我有这个代码 var myChart = new FusionCharts("../themes/clean/charts/hbullet.swf", "myChartId", "400", "75
既然写入是立即进行的(复制到内核缓冲区并返回),那么使用 io_submit 进行写入有什么好处? 事实上,它 (aio/io_submit) 看起来更糟,因为您必须在堆上分配写入缓冲区并且不能使用基
我正在使用 mootool 的 Request.JSON 从 Twitter 检索推文。收到它后,我将写入目标 div 的 .innerHTML 属性。当我在本地将其作为文件进行测试时,即 file:
最终,我想将 Vertica DB 中的数据抓取到 Spark 中,训练机器学习模型,进行预测,并将这些预测存储到另一个 Vertica DB 中。 当前的问题是确定流程最后部分的瓶颈:将 Spark
我使用 WEKA 库编写了一个 Java 程序, 训练分类算法 使用经过训练的算法对未标记的数据集运行预测 将结果写入 .csv 文件 问题在于它当前写出离散分类结果(即算法猜测一行属于哪个类别)。我
背景 - 我正在考虑使用 clickonce 通过 clickonce(通过网站)部署 WinForms 应用程序。相对简单的应用程序的要素是: - 它是一个可执行文件和一个数据库文件(sqlite)
是否有更好的解决方案来快速初始化 C 数组(在堆上创建)?就像我们使用大括号一样 double** matrix_multiply(const double **l_matrix, const dou
我正在读取 JSON 文件,取出值并进行一些更改。 基本上我向数组添加了一些值。之后我想将其写回到文件中。当我将 JSONArray 写回文件时,会被写入字符串而不是 JSONArray 对象。怎样才
我为两个应用程序使用嵌入式数据库,其中一个是服务器,另一个是客户端。客户端应用程序。可以向服务器端发送获取数据请求以检索数据并显示在表格(或其他)中。问题是这样的:如何将获取的数据保存(写入)到页面文
是否有更好的解决方案来快速初始化 C 数组(在堆上创建)?就像我们使用大括号一样 double** matrix_multiply(const double **l_matrix, const dou
从问题得出问题:找到所有 result = new ArrayList(); for (int i = 2; i >(i%8) & 0x1) == 0) { result.add(i
由于某种原因,它没有写入 CSV。谁能明白为什么它不写吗? def main(): list_of_emails = read_email_csv() #read input file, cr
关闭。 这个问题是 not reproducible or was caused by typos 。它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能在这里出现,
我目前正在开发一个保存和加载程序,但我无法获得正确的结果。 编写程序: #include #include #define FILENAME "Save" #define COUNT 6 type
import java.io.*; public class Main2 { public static void main(String[] args) throws Exception {
我需要使用预定义位置字符串“Office”从所有日历中检索所有 iOS 事件,然后将结果写入 NSLog 和 UITextView。 到目前为止,这是我的代码: #import "ViewCo
我正在尝试将 BOOL 值写入 PFInstallation 中的列,但会不停地崩溃: - (IBAction)pushSwitch:(id)sender { NSUserDefaults *push
我以前在学校学过一些简单的数据库编程,但现在我正在尝试学习最佳实践,因为我正在编写更复杂的应用程序。写入 MySQL 数据库并不难,但我想知道让分布式应用程序写入 Amazon EC2 上的远程数据库
是否可以写回到ResourceBundle?目前我正在使用 ResourceBundle 来存储信息,在运行时使用以下内容读取信息 while(ResourceBundle.getBundle("bu
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
我是一名优秀的程序员,十分优秀!