Hmmm, looks like I was on the right track all along, as I can follow your Perl pretty well...

Unfortunately that calls into question if the C code was ever doing what it purported to do in the first place, as the routine should fail if, for example the inbound string is <SOH>9998FF1B<ETX> - and although as far as I can tell you have provided an exact duplicate of what the C code does, I ran the above string, through the provided subroutine, and received "0"...
So...
According to the description, the C code purports to do the following:
"The Checksum is a series of four ASCII-hexidecimal characters which provide a check on the integrity of all characters preceeding it. The four characters represent a 16-bit binary count which is the 2's complimented sum of the 8-bit binary representations of the message characters. The data integrity check is done by converting the four checksum characters into a 16-bit binary, and adding the 8-bit binary representation of the message characters to it. The binary result should be zero."
Implied, is that any value other than zero indicates a checksum failure.

Can anyone tell me if the C code is actually doing that, or for that matter how CombatSquirrel's kindly provided code sample could be made to perform this (to me rather arcane) act?

Still out of my depth here, but at least someone threw me a floatation device.

Thanks CombatSquirrel.
Mike Gucciard

In reply to Re: Re: Conversion of C code to Perl-ese. by gooch
in thread Conversion of C code to Perl-ese. by gooch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.