views:

43

answers:

1

Hi, i'm trying to implement a CRC-CCITT (XModem) check in javascript without success. I need it in order to send socket string into a controller via RS232. does anyone know how to do it? or perhaps is there a sample code somewhere??

I would appreciate any kind of help :)

A: 

A quick search showed http://zorc.breitbandkatze.de/crc.html which is an online CRC calculator in Javascript. It looks like it's quite general purpose because all CRC parameters can be changed, so it may be much more than what you're looking for. However, the same techniques will apply for your application.

Greg Hewgill
hi Greg,thanks for your answer, however the online calculator you proposed does not calculate the XModem correctly - "question#2: in c-code, be careful using polynoms having a LSB of 0 (e. g. XMODEM 0x8408)... code doesn't work for such cases!!! Any ideas how to convert direct to nondirect values with polynoms having LSB=0?"so i still do not have a sample code that does it.
Salmonela
@Salmonela: I've used that online CRC calculator before and it is correct. You must be careful with things like bit order and reciprocal polynomial values. The best option might be to find some simple C code that does what you want, and convert that to Javascript. The completed function should be about 10 lines of code.
Greg Hewgill