CRC computation in JavaScript (Node)

Hi!

I’m controlling two 18v7 motor controllers with a Raspberry Pi using node and serialport but I’m experiencing some “stuttering” here and there and would like to implement CRC checks for my communication.

Could anyone help me translate any of these examples to JavaScript?

Here is my example project:

I’m not even sure what the correct output would be, all I know is that my motors doesn’t spin when using the code in crc.js. So I’m looking for someone who could point out any faults in my translation.

I have enabled CRC checks for “commands only” on the 18v7.

Thanks!

Hello.

Is there a reason why you are not using your getCRC function? (I just tested that part of your code and it works.) You can just pass your buffer object directly to the function without having to mess with the encodings. For the two byte sequence ([0x83,0x01]) you used in your script, the CRC byte should be 0x17 (or 23). You can find this information in the “Cyclic Redundancy Check (CRC) Error Detection” section of the Simple Motor Controller User’s Guide along with a step-by-step calculation example.

- Amanda