LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fletcher Checksum

Hi everybody!

I new in this and I need a VI that makes me a Fletcher Checksum. The string to be checksummed is (for example): 0x 50903001, and the result is 0xD11F8090.

 This is what i have to do in other lenguage:

 
 
/* U16 is 16-bit unsigned int, U32 is 32-bit unsigned int.*/
U32 inst_fletcher_checksum(
U32 prior, /* checksum from earlier data */
const U16 * p, /* where we’ll start checksumming this time */
U32 n) /* number of U16s to be checksummed */
{
/* Extract the two halves of the previous checksum */
U16 a = 0xFFFF & prior;
U16 b = 0xFFFF & (prior >> 16);
 
/* Add, ignoring any overflows */
while (n--) {
a += *(p++); /* same as a += *p; p++; */
b += a;
}
 
/* Concatenate a,b into a U32 */
return ((U32) b << 16) | (U32) a;
}
0 Kudos
Message 1 of 16
(4,167 Views)

This should do it for you.

 

Correction: your prior should actually be 0x0000FFFF


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
Message 2 of 16
(4,152 Views)

@crossrulz wrote:

This should do it for you.

 

Correction: your prior should actually be 0x0000FFFF


You've just done his work for him.

 

What is gained without him doing anything?

0 Kudos
Message 3 of 16
(4,132 Views)

nyc wrote:

You've just done his work for him.

 

What is gained without him doing anything?


I was feeling generous this morning.  It happens every once in awhile.  Checksums do tend to end up being weird.  I guess this one was simple enough.  Maybe I should have done an Altenbach.


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 16
(4,120 Views)

@crossrulz wrote:

nyc wrote:

You've just done his work for him.

 

What is gained without him doing anything?


I was feeling generous this morning.  It happens every once in awhile.  Checksums do tend to end up being weird.  I guess this one was simple enough.  Maybe I should have done an Altenbach.


I agree that checksums can be weird. All the more for doing work to learn.

 

 

 

 

0 Kudos
Message 5 of 16
(4,104 Views)

nyc wrote:

 

What is gained without him doing anything?


Meh I'm with crossrulz some times.  If I were looking for a Fletcher Checksum VI I know I could do it, and it probably wouldn't take much time, but I'd probably search the forums first, and be thrilled to see someone has already done it.  And then there is the fact that the OP can look at the text source, and see how it relates to this implementation in LabVIEW which can also be helpful for a learning experience.

 

But yeah, some days I feel generous too.

 

Also I figured the link to altenbach would have been to some obfuscated code thread.

0 Kudos
Message 6 of 16
(4,102 Views)

Thanks for the answer but I've tryed and it don't give the checksum that I need.

0 Kudos
Message 7 of 16
(4,067 Views)

I tested first the once i found in the forum and none worked, I also tried to make one myself, but have not been successful

0 Kudos
Message 8 of 16
(4,061 Views)

Be a little bit more specific. What data did you use and what is your expected checksum?

0 Kudos
Message 9 of 16
(4,048 Views)

@Anac wrote:

Thanks for the answer but I've tryed and it don't give the checksum that I need.


Make sure your Prior is correct.  That is the only information that was an unknown and I had to experiment to find one that worked with the data set you provided.


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 10 of 16
(4,039 Views)