LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Checksum

Solved!
Go to solution

What is a 'checksum'?
I have heard people on the forums refferring to it before, but I'm not sure what it is, or when to use it.

I tried looking it up on Wikipedia but its a bit confusing.

 

Could anyone explain in laymans terms?

Cory K
0 Kudos
Message 1 of 11
(4,468 Views)
Solution
Accepted by topic author Cory_K

Basically a mathematical calculation of a series of bytes to that yields a 1 or 2 byte code.  That way if one of the early bytes is missing or changed, the resulting "checksum" value is different and is an indication that the data is not correct.

 

Source of data calculates a checksum and appends it to the data.  The receiver gets the data and calculates its own checksum and compares it to the checksum that was sent.  If it matches, then it is highly likely the data came through unscathed.  If they don't match, then one or more bytes of data was definitely changed or is missing.

 

Numerous algorithms can be used.  It's not foolproof.  A 1 byte checksum only has 256 possible values that is a check of any infinite number of bytes and combinations thereof.  So two different byte streams can give you the same checksum byte.  But the algorithms are developed so that it is mathematically improbable for normal byte stream errors.

Message Edited by Ravens Fan on 03-19-2009 12:02 PM
Message 2 of 11
(4,462 Views)

Cory K wrote:

What is a 'checksum'?
I have heard people on the forums refferring to it before, but I'm not sure what it is, or when to use it.

I tried looking it up on Wikipedia but its a bit confusing.

 

Could anyone explain in laymans terms?


 

From what I understand ancient Hebrew Sribes used a method to ensure that they copied the original text correctly. They assigned numeric value to every letter and then added up the value of all of the letters for each book. If the totoal for their copy was the same as the original, the copy was concidered correct.

 

So it was a method to ensure that a block of information was propery transfered from the original to the copy.

 

A similar technique is used in computers to enusre files are intact or messages are transfered correclty.

 

Whenever you down load a web-page a  sequence ofTCP/IP packets are used to transfer the info. When sent the hardware appends additional characters to the end of the packet that represent the total of the values contained in the packet an dthis is used to enusre the data was transfered correctly. In the event the total was not correct, the hardware decalres the data corrupted and tosses it. Mean while the transmitter is watching its own transmision and if it does not add up, it declares a "collistion" and attempts the transfer again.

 

I suspect the above is more than you wanted to hear and that someone else has already answered this Q while I was typing but I wanted to add sum context*.

 

Ben 

 

* Pun intended.

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 11
(4,461 Views)

Thanks for the lesson guys.
I'm not using checksum's in any of my VI's,

I just wanted to learn something new.Smiley Happy

I figured, who better to ask then the LabVIEW gurus?

Cory K
0 Kudos
Message 4 of 11
(4,439 Views)

Hi all,

I'm currently trying to communicate with an IBS 200 power supply.  The communication guide shows the following example to, for instance, read the restricted mode: 

PC to IBS: 1 02<TER><CHECKSUM>

IBS to PC: 0 0 0 0 0 0 0<TER><CHECKSUM>

Since the device communicates via RS-232, I will try/modify the "basic serial read and write. vi".  However, I don't understand how to obtain the Checksum since the communication guide doesn't provide the formula.  Do you guys have any lead?

0 Kudos
Message 5 of 11
(4,197 Views)

The manual has to provide some kind of information.  If it doesn't provide the formula, does it at least give the type such as CRC-8, CRC-16, LRC-16, or one of dozens of other algorithms?

 

Can you post a link to the manual?

0 Kudos
Message 6 of 11
(4,185 Views)

Thanks for your quick reply Ravens Fan.  I want to make a correction.  The guide provides the formula in a sample basic program under GWBASIC, which I'm not familiar with (not sure what is the ASC function).  Unfortunately, the device's company, CVC, no longer exist and so I couldn't find a soft copy. I attached the GWBASIC code as a doc.  Please take a look for me.

Thanks again,

0 Kudos
Message 7 of 11
(4,157 Views)

Hi DevinChen,

 

here you go:

checksum.png

 

The ASC() function converts an ASCII char to it's according number.

 

More notes:

- giving the Basic code as a simple textfile would be easier to read than any proprietary file format (which results in bigger files too..)!

- RTFM first would have reduced your question to a simple "What does the ASC() function of GWBasic?" Smiley Wink

- The addition of 13 in the formula results from the filtered carriage return in the (Basic) code before (line 1030). When your string already contains that CR you should not add 13 again!

Message Edited by GerdW on 09-12-2009 07:44 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 11
(4,153 Views)

Hi DevinChen,

 

the edit time has expired for my first reply...

 

Even more notes:

In line 2036 and 2064 a new variable CHKSM is used, but isn't initialized before. Maybe a typo again?

But nevertheless CHKSM is also just the sum of the ASCII values of the received chars, including the CR!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 11
(4,146 Views)

Hi GerdW,

Thanks for the help.  Lines 2035 and 2064 match those written on the guide.  I think it's because there're two commands so different variables are needed for the checksums. 

Thanks again,

 

0 Kudos
Message 10 of 11
(4,135 Views)