Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

CRC16 poly 8005

 [1/3] from: gschwarz::netconnect::com::au at: 24-Oct-2006 13:41


After a bit of playing around I come up with this function to do a CRC. Any feedback welcome. Regards, Greg data: "123456789" crc-8005: func ["returns a 4 byte string crc of string of data" data][ crc: 0 foreach char data [ char: to-integer to-binary char loop 8 [ either ( to-integer crc and 32768 ) <> 0 [ temp: 32773 crc: ( crc and 32767)] [ temp: 0 ] crc: (( crc * 2 ) + ( char and 1 )) xor to-integer temp char: to-integer char / 2 ] crc: crc and 65535 ; keep crc in the 16 bit range ] ; equiv to adding two zero bytes to end of string loop 16 [ either ( to-integer crc and 32768 ) <> 0 [ temp: 32773 ][ temp: 0 ] crc: ( crc * 2 ) xor to-integer temp crc: crc and 65535 ; keep crc in the 16 bit range ] ; Reflect crc ref: 0 loop 16 [ ref: to-integer ( ref * 2 ) ref: ref + ( crc and 1 ) crc: to-integer crc / 2 ] crc: remove/part to-string to-hex ref 4 return crc ] print crc-8005 data print "should be BB3D"

 [2/3] from: greggirwin::mindspring::com at: 26-Oct-2006 11:06


Hi Greg, GS> After a bit of playing around I come up with this function to do a CRC. Thanks for sharing that. Is there a specific, or general, application for this particular CRC calc? -- Gregg

 [3/3] from: gschwarz::netconnect::com::au at: 27-Oct-2006 9:35


Gregg, This can be changed for a few 16 with different poly's 32773 dec = 8005hex below are the main 16bit CRC's Regards, Greg CRC16 The following polynomial are used: Normal Inverted/reversed/reflected $8005 $A001 Std. $1021 $8408 CCITT, X24 $4003 $C002 $0811 $8810