LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CRC-16 Calculation

Solved!
Go to solution

The reader's address must be correct as i used FF (255) which sends the commands to all readers. Fixing the length didn't solve it. I used the codes you sent me. Maybe mistake is related to the CRC? If the command is incomplete, reader won't reply so probably its unable to identify the LSB And MSB


 

0 Kudos
Message 11 of 21
(3,861 Views)

This is an amazingly well-written document.  You will have to calculate the length of the message.  Command data block length 1 byte (not including itself). Value range is 4~96. The number of Len equals the length of Data [] plus 4.  I take this to mean Adr + Cmd + CRC = 4 bytes + Data[].  In other words, concatenate your message with everything but Len.  Take the size of that byte array, convert it to a u8 and tack it on to the front of the array.  That's your message.

 

I think you have the importance of the various parts of your message failing all wrong.  The length, which you assigned an arbitrary number to, is actually critical to the device understanding the message, while the CRC value just needs to be any u16.

 

Once you get a response back (that will probably tell you the command failed the CRC check), you can fool around with calculating the CRC value.

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.
Message 12 of 21
(3,843 Views)
Solution
Accepted by fadihajj

This is how I would do it, based on the docs:

snippet1.png

Oops, didn't optimize the read.  See the post below.

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.
Message 13 of 21
(3,833 Views)
Solution
Accepted by fadihajj

snippet2.pngOops, I didn't optimize the comm part.  To read the response, first read one byte (VISA byte count = 1).  The result is the length of the rest of the message (as u8).  That's also your VISA byte count for your next (and final) VISA read.  No more loop, no more "bytes at port".  No more guessing at when the message is ending.  You know when it ends.  This is a very efficient protocol.

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.
Message 14 of 21
(3,829 Views)

Thinking about your problem further, you're probably not getting a response because bytes at port is likely still 0 when you look at it.  That, plus the loop only executes once because of the true constant.  You won't have that issue with the method I outlined above.

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.
Message 15 of 21
(3,810 Views)
Solution
Accepted by fadihajj

More than likely, you will also have to disable the termination character on both the VISA READ and WRITE functions.

 

Capture.PNG

Message 16 of 21
(3,790 Views)

Thank you all for your help, i am going to try the above as we speak. I' ll let you guys know what happens.

Thank you again.

0 Kudos
Message 17 of 21
(3,773 Views)

Thanks alot. Its working fine. I would like to add that even though the length was correct the  bytes at port property node was returning a 0, this is why i marked the second snippet as solution. Thank you sir.

0 Kudos
Message 18 of 21
(3,764 Views)

You can mark more than one as a solution.  I think this was a combination of several posts by a couple of different people.  🙂

 

You were awesome to dole out the kudos, though.

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 19 of 21
(3,731 Views)

Yes, thanks to all of you. But the accept solution button isn't appearing anymore.

0 Kudos
Message 20 of 21
(3,709 Views)