I'm having a devil of a time calculating the 802.15.4 CRC value. I have, for instance, the string
[9 1 128 1 0 0 0 4 23 215]
where the first value is the length of data values, not counting the length value itself, and the final two values are the FCS (Frame Check Sequence, which is the CRC).
My CRC algorithm (CRC-CCITT 16-bit checksum) works with the example input strings I have found on the internet. Great. That's the hard part down. Now I just need to feed it the right string. Only...
No matter the combination I cannot reproduce the correct FCS values. According to the 802.15.4 specifications, the FCS field is "calculated over the MHR and MAC payload parts of the frame". Which is already a confusing statement. (Over? Does that mean the two together, as if they were one long sequence, or does that perhaps mean something else?)
Again, according to the docs (Fig. 126.96.36.199 in IEEE Std 802.15.4-2005), the frame length (first value) is not part of the MHR and MAC payload, nor are the FCS (last two values). So that should, in theory, mean that the correct string is
[1 128 1 0 0 0 4]
only that doesn't give the right CRC. Nor does it if I reverse the order of the bits in the in each individual byte (that is to say, switch the endianness). Nor does it for any LINEAR combination of the above set.
So I've been bashing my head for over an hour, and I cannot find any source that gives me a worked example of an entire packet. Can someone out there help?