Newb. RS232 with CRC.16 communication.

Hi there

This is my second time putting this up as for some reason my post was deleted!!!

if this is the wrong place tell me/move it, no need to delete it!

I want to communicate with a serial device that send a command using CRC.16

i have done this in a Visual studio program. but i now want to do it with a arduino and want to get help doing this.

Basically is it encodes the data before sending using the crc.
EG: SendDataIPS(GetCommand(unitcommand));

i’ve attached the crc code i use.

any way of doing this?

regards
Jeremy

crccode.txt (2.14 KB)

That code could be rather easily edited to run on Arduino (the integer variable types will have to be treated carefully).

how would i got about doing this?

Before you go to the trouble of trying to port that (rather ugly) code, why don't you spent ten minutes researching the results of a Google search for "Arduino CRC16" ?

P.S.: You'll find it's already been done, many times.

Thanks for the help and the reply avr_fred :)

Before doing your CRC check you will need to receive the message. The examples in Serial Input Basics may help.

...R

Hi Robin

whats the limitation on that?

the reason why i asked. cos i have to send command before receiving the data and the data can vary from 4 - 250 characters all depending on the command sent.

regards Jeremy

jeremy450: cos i have to send command before receiving the data and the data can vary from 4 - 250 characters all depending on the command sent.

In the examples the array is set to 32 chars but you could change the value of numChars to make it big enough for your largest message.

The code will work with any size of message up to the max that you have chosen.

...R