0

i have a problem converting the byte i get from the tag into serial number.

i get this byte from the tag: 2 52 66 48 48 65 57 55 70 57 48 48 68 13 10 3

i'm code it in C#, and here is the code :

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();

the tag serial number is : 0011108240.

i have tried to convert those number to ASCII, but i didn't get anything. so how to get the 0011108240 from the byte i received from the tag?

here is the code i got from the manual, it's written in pascal and i dont get it, anyone can tell me how?

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;

thanks.

helb
  • 7,609
  • 8
  • 36
  • 58
Brilian
  • 9
  • 4
  • What you receive decodes (ASCII) to [STX] 4B00A9F900D [CR] [LF] [ETX]. – Michael Roland Mar 06 '14 at 06:00
  • 1
    What reader are you using? What does the reader's manual say about how to decode the received value? – Michael Roland Mar 06 '14 at 06:01
  • hello Michael Roland, i use a reader from my country and its not arduinio. i didnt get any manual but i got the sample program to read the RFID tags. i have included the code above, do you how it works? thanks, – Brilian Mar 06 '14 at 08:39
  • A "reader from your country" is not really useful information. Also knowing that it is "not arduino" isn't useful either. Using the input and the conversion function you gave would lead to the decimal value 14296328831156 (4B00A9F900D -> reversed -> D009F9A00B4 -> 14296328831156) – Michael Roland Mar 06 '14 at 11:23
  • okay Michael, thanks for your help i finally know how to do it. thank you very much. – Brilian Mar 07 '14 at 04:15

0 Answers0