I notice that GHIElectronics.NETMF.System has a CRC generator, which would be useful but I get different values to the software CRC I use, can anyone confirm that the polynominal is…
x16 + x12 + x5 + 1
The software calculation I use is,
static readonly UInt16[] crc_table =
{
0x0000, 0x1081, 0x2102, 0x3183,
0x4204, 0x5285, 0x6306, 0x7387,
0x8408, 0x9489, 0xa50a, 0xb58b,
0xc60c, 0xd68d, 0xe70e, 0xf78f
};
public void Calculate( byte b )
{
/* Do this four bits at a time - more code, less space */
crc = (UInt16)((crc >> 4) ^ crc_table[(crc ^ b) & 0x000f]);
crc = (UInt16)((crc >> 4) ^ crc_table[(crc ^ (b >> 4)) & 0x000f]);
}
Where did you get this code? It doesn’t look right…
It works just fine for the crc required for the device Im talking to.
but as I said I think its a x16 + x12 + x5 + 1 which may be different to the GHI CRC-16.
of course that was just the meat of the calculation, I feed a byte at a time as they come in over the Uart (overlapping io with calculation), would be nice to have a native implementation tho.
even so despite micro.Net being interpreted it does a pretty good job