LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CRC-16 Calculation

Solved!
Go to solution

Hello guys,

 

I am working on an RFID, and i need to send a CRC-16 to the reader in the form of a command. I have an example of the crc-16 used by the manufacturer however i have no knowledge of C++ language and some parameters are not clear. Maybe if someone has experience in dealing with CRC-16 can help me out?

I attached a snippet of the VI i am using that contains the CRC-16 calculation and the example given in the reader's manual. Is it possible to check them out and tell me if my VI is correct? Because i am not receiving a reading from the RFID and i am sure the rest of my parameters are correct.

 

Thank you,

Fadi 

Download All
0 Kudos
Message 1 of 21
(9,620 Views)

The labview code seems to match the C code and I see you even swapped the endianness of the I16 it generates.

 

Any documentation about the request/reply structure? Most smartcards I have seen give some sort of status word response at the end of a reply to denote if your command was good or not (which would also reply as bad if your checksum on your request was wrong).

 

Deceased

Message 2 of 21
(9,568 Views)

Hello Sir,

 

Thank you for replying,

I attached the reader's manual. In the Vi i previously attached i am trying to send the command " inventory " which returns the EPC of the tag. I think the parameters are correct except for the CRC because in the sample code, i found in the manual ( on page 6), there isn't any indication of what the inputs are. Maybe i shouldn't use all five parameters to return a CRC. If you have good understanding of this problem could you help me figure out what i am missing on?

And to reply to your question, i am not receiving a response from the reader, i just get an empty string indicator.

Should i define all the parameters first? such as power, frequency and all that. For now, i am only looking for a good communication between the PC and reader before building a complex code.

 

Thank you,

Fadi

0 Kudos
Message 3 of 21
(9,558 Views)

You are using a length of 8 even though you only have 4 bytes in your message (excluding the length byte).  If your length is 8, you should have 4 bytes of data for the command.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 21
(9,547 Views)

Hi sir,

 

you are right, i assigned 8 randomly. The manual specifies 0xXX for length, there isn't a speficied one. I thought that it won't create any problems. 

0 Kudos
Message 5 of 21
(9,545 Views)

You probably have to calculate how long the message is!

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 21
(9,521 Views)

 

Command:

Len

Adr

Cmd

Data[]

CRC-16

AdrTID

LenTID

0xXX

0xXX

0x01

0xXX

0xXX

LSB

MSB

Parameter Connect:

AdrTID: One byte. It specifies the starting word address for the TID memory read. For example, AdrTID = 00h specifies the first 16-bit memory word, AdrTID = 01h specifies the second 16-bit memory word, etc.

 

LenTID: One byte. It specifies the number of 16-bit words to be read. The value is less then 16, otherwise, it returns the parameters error message.

Notes: It will get tags’ EPC values when the AdrTID and LenTID vacant. Otherwise, get tags’ TID values. TID-inventory function is only available for reader with firmware version V2.36 and above.

-----------------------------------------------------------------------------------

From the manual it looks like you want a command like this

 

0x06 0xFF 0x01 0x00 0x0E + CRC

 

0 Kudos
Message 7 of 21
(9,515 Views)

yes, this is it. except i am sending a value of 0 for LenTID as well in order to get the tag's EPC. My length initialization is wrong, but to get things clear, is this type of coding considered strict? if i define a larger length shouldn't it be okey? 

So besides the length, if there is anything it's the CRC. And again my concern here is that the manual doesn't define what the inputs are when i am using all the my parameters as inputs.

 

Thank you for your help

0 Kudos
Message 8 of 21
(9,508 Views)

I just tried it out and still no response from the reader. I would like to add that if the demo software is running and try to run labview code then i get an error and when i stop the demo software the VI works fine. So i guess Labview is communicating with the serial port connected to the reader.

0 Kudos
Message 9 of 21
(9,504 Views)

Commonly smartcards will be incredibly strict over packet structure since specifying incorrect lengths can cause buffer overflows.

 

From the manual:

 

Two kinds of command reader cannot respond:

  1. The reader’s address error.
  2. The command is incomplete, namely the command Len is longer than the actual command length.

 

------------------------------

 

I agree its not clear which bytes the crc shoukd include, but best to assume all that are sent (unless it says otherwise) since the purpose of the crc is to detect packet corruption.

0 Kudos
Message 10 of 21
(9,503 Views)