LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET C# CRC checksum code to LabVIEW

Solved!
Go to solution

Hi guys,

 

I'm trying to build a CRC checksum calculator for communication with a measurement device. The manufacturer has given me a .NET/C# example program, which I'm now adapting for use in LabVIEW.

The program I've built doesn't give me the correct checksum. This might have something to do with the way I bitshift data or something else, I'm no C# expert. Could anybody please take a look at my program? The C# code is displayed in the block diagram. Thanks in advance.

 

Paul

 

P.S. here are a number of values and the corresponding CRC value (according to the datasheet)

 

data: 01

CRC: F1D1

 

data: 03

CRC: D193

 

 

Download All
0 Kudos
Message 1 of 6
(4,390 Views)

Where's the C# code?

 

Edit: Nevermind. Didn't see it in the leftbox.

0 Kudos
Message 2 of 6
(4,381 Views)
Solution
Accepted by topic author Perreijn

You're confusing terminology. A CRC and a checksum are two completely different things. The function name says "Checksum", but seems to be calculating a CRC. The C# code itself doesn't make much sense. What is the polynomial that the person who wrote it was trying to use? As for the LabVIEW code, get rid of the Type Cast functions. You don't actually need them, and in the very first step you're actually doing the bit shifting and type casting in reverse order.

Message 3 of 6
(4,364 Views)

Thanks for the reply. You're right; checksum and CRC are not the same (although they're both ways of catching errors). The CRC implementation I got from the hardware guy calls this .NET program a 'CRC checksum calculation', but technically it's wrong. Furthermore the hardware guy's document title was 32 bit CRC, but it should be 16 bit CRC (the return type is a 16 bit number).

As for the type casts; it's not pretty, but I'm trying to literally interpret what the .NET function is supposed to do. Trouble is that I have very limited experience with .NET and I can't tell if this program even works. I don't have the polynomial on which it is based, this .NET code is all I got.

0 Kudos
Message 4 of 6
(4,359 Views)

Take out all the typecasts as suggested and your VI will work.

Message 5 of 6
(4,356 Views)

Awesome, without the typecasts it's indeed OK!

Don't know why the .NET program needs that many, but the LabVIEW VI doesn't need them.

Thanks and kudos to you both.

 

0 Kudos
Message 6 of 6
(4,353 Views)