C# 转换RFID字节以获取RFID序列卡号
我无法将从标签中获取的字节转换为序列号 我从标签中得到这个字节: 2. 52 66 48 48 65 57 55 70 57 48 48 68 13 10 三, 我用C#编写代码,代码如下:C# 转换RFID字节以获取RFID序列卡号,c#,rfid,C#,Rfid,我无法将从标签中获取的字节转换为序列号 我从标签中得到这个字节: 2. 52 66 48 48 65 57 55 70 57 48 48 68 13 10 三, 我用C#编写代码,代码如下: SerialPort port = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One); port.Open(); while (true) { if (port.BytesToRead > 0) { b
SerialPort port = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One);
port.Open();
while (true)
{
if (port.BytesToRead > 0)
{
byte b = (byte)port.ReadByte();
Console.WriteLine(b);
}
}
port.Close();
标签序列号为:0011108240
我曾尝试将这些数字转换为ASCII码,但没有得到任何结果。
那么如何从我从标记接收到的字节中获取0011108240呢
这是我从手册中得到的代码,它是用pascal编写的,我不懂,谁能告诉我怎么做
function tform1.hextoint(input : string):longint;
var
c,i : longint;
input1 : string;
begin
c:=0;
input1:='';
for i:=length(input) downto 1 do input1:=input1+input[i]+'';
input1:=uppercase(input1);
for i:=1 to length(input1) do
begin
if (input1[i] in ['A'..'F'])and(i>1)then
c:=((ord(input1[i])-ord('A')+10) shl (4*(i-1)))or c
else
if (input1[i] in ['0'..'9'])and(i>1)then
c:=((ord(input1[i])-ord('0')) shl (4*(i-1))) or c
else
if (input1[i] in ['A'..'F'])and(i=1)then
c:=(ord(input1[i])-ord('A')+10) or c
else
if (input1[i] in ['0'..'9'])and(i=1)then
c:=(ord(input1[i])-ord('0')) or c;
end;
result:=c;
end;
谢谢。您收到的内容将(ASCII)解码为[STX]4B00A9F900D[CR][LF][ETX]。您使用的是什么阅读器?读者手册对如何解码接收到的值有何规定?您好,迈克尔·罗兰,我使用的是来自我国的阅读器,而不是Arduino。我没有得到任何手册,但我得到了读取RFID标签的示例程序。我已经包含了上面的代码,你知道它是如何工作的吗?谢谢,“你们国家的读者”并不是真正有用的信息。同时知道它“不是arduino”也没用。使用您提供的输入和转换函数将得到十进制值14296328831156(4B00A9F900D->reversed->D009F9A000B4->14296328831156)。好的,Michael,谢谢您的帮助,我终于知道该怎么做了。非常感谢你。