Hi Thomas; Thanks for your advise, I will try that and see.
Best regards Mohsen On Mar 28, 2009 3:23 PM, "Thomas Hruska" <thru...@cubiclesoft.com> wrote: Mohsen Deeb wrote: > Hi; > > I found this code on some websites, but I don't know how to check if i... There are some freeware applications out there that allow you to generate a bunch of different CRCs for a given data set. Just find one that does 16-bit CRCs. You've run into one of my pet peeves: http://cubicspot.blogspot.com/2007/09/standards-documentation-is-annoying.html To answer your question, it looks correct. There are no reflections and the poly is 0x1021, which is the correct poly. The only issue you probably have is "What do I do with this function?" The only thing you are likely missing is the initial value to pass in as 'crc'. 0xFFFF is what I've got as the correct initial value for all standardized CRC-16s. To answer your next question, "How do I test this?" Enter a string into both the freeware tool you find and your app. If the value matches up (typically in hex), then your implementation is probably correct. Maybe. Your tool AND their tool could both be wrong and yet produce the same answer (i.e. both using the same flawed source code). Here's a sample from my personal, automated test suite: Using no reflections, a 0x1021 poly, and an initial 0xFFFF, the string: "message digest" (without the quotes) should be 0x32CC. -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* MyTaskFocus 1.1 Get on task. Stay ... [Non-text portions of this message have been removed]