04-09-2015 09:51 AM
Hi All,
I need some help to convert this C code in to LabVIEW.Has anyone has below flectcher 32 checksum method in Labview?Please help to guide.The C code is shown below:
unsigned int ComputeChecksum(unsigned char *buffer, int byteCount)
{
unsigned int sum1 = 0xFFFF;
unsigned int sum2 = 0xFFFF;
unsigned int tlen = 0;
unsigned int shortCount = byteCount / sizeof(short);
unsigned int oddLength = byteCount % 2;
while(shortCount)
{
tlen = shortCount > 360 ? 360 : shortCount;
shortCount -= tlen;
do
{
sum1 += *buffer++;
sum1 += (*buffer++ << 8);
sum2 += sum1;
}
while(--tlen);
if((oddLength == 1) && (shortCount < 1))
{
sum1 += *buffer++;
sum2 += sum1;
}
sum1 = (sum1 & 0xFFFF) + (sum1 >> 16);
sum2 = (sum2 & 0xFFFF) + (sum2 >> 16);
}
sum1 = (sum1 & 0xFFFF) + (sum1 >> 16);
sum2 = (sum2 & 0xFFFF) + (sum2 >> 16);
return (sum2 << 16 | sum1);
}
Thanks alot.
04-09-2015 10:16 AM
Seems very straightforward to me.
What exactly is your problem?
If you don't understand C, then find a colleague who does.