Hi,
Is there a way to check for errors using CRC in data like "a1500b1600c1700d" received over the serial port ?
Hi,
Is there a way to check for errors using CRC in data like "a1500b1600c1700d" received over the serial port ?
Only if the serial data 'message' has CRC data bytes appended to the end of the 'message'. Then you would have to know which CRC encoding method was used in generating the message and finally you would have to have to do the same CRC calculations in your program to compare with the CRC bytes sent.
Lefty
Does arduino have a CRC implementation?
http://www.arduino.cc/playground/Learning/OneWire
The above link has a mention of CRC.Can I use it?
And the one below has one CRC implementation
http://www.nongnu.org/avr-libc/user-manual/group__util__crc.html
How do I exactly implement the info in the above thread in arduino.Will it take a lot of time and CPU computation to do it?
I infer that the question arises in a Dallas 1-Wire context.
In that context, the answer to RetroLefty's queston is "yes".
When 1-Wire chips send a message to their controller (an Arduino, in the context of this discussion), part of the message is a CRC value that can be cross checked against the rest of the message. The algorithms are at the Dallas site, if not already encoded in the Arduino 1-Wire library.
The concept is simple; the details are a little tedious.
Does anyone KNOW whether the Arduino 1-Wire library has CRC routines?
If the interface to the 1-Wire device is via a Peter Anderson 1-Wire interface, as extolled in....
... then I'm not sure whether he checks the CRC data in what is done by the controller, nor do I think there is an easy way to do it yourself... I would just read the data several times and assume all is well if I get consistent readings.
So is CRC there for arduino in the 1-wire lib?
The 1-wire chips (almost?) always SEND a CRC word... but the Arduino 1-Wire library may or may not be bothering to read it. And it if reads it, it may or may not be using it.
For anyone reading this who isn't familiar with CRC type data checking...
(I'm making gross simplificatons in what follows, to make the illustration clear, I hope.)
Suppose the 1-Wire chip wanted to send 789 as the data. It sends it. AND it does something with what it sends. We'll pretend that it just adds up the digits. (7+8+9=24). It then, in my imaginary world, throws away all but the least significant digit.... 24 is chopped down to "4". The 1-Wire chip then sends this to the same place it sent the 789. At that place, probably an Arduino, given where I'm posting this, but the principle is general, the receiving entity ALSO adds the digits it received, e.g. the 7, 8, 9... and does the chop down... and looks to see if the value it (the receiving entity) gets matches the check digit sent to it by the 1-Wire chip. If they match, there's a pretty good chance that the data and check digit got through correctly.
Consider what happens if the 1-Wire TRIES to send 789+4, but it comes through as 779+4. The receiving entity will add 7+7+9, get 23, throw away the "2", and be left with "3" which won't match the "4" sent by the 1-Wire chip, and thus the receiving entity knows there was a glicth in the transmission.
The most recent version of the OneWire library does include CRC checking. It can calculate both 8-bit and 16-bit CRC's.
You can download the library zip file from http://homepage.mac.com/wtpollard/Software/FileSharing7.html.
Regards,
-Mike