Offline
Newbie
Karma: 0
Posts: 5
|
 |
« on: November 24, 2012, 11:45:06 pm » |
Sorry if this isn't the correct subforum.
Arduino 1.0.2 gives me the option to use parity error detection on serial connections. Does anyone know if I need to manually handle parity errors, or does the Arduino automatically request retransmission?
Thanks!
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 270
Posts: 17059
Available for Design & Build services
|
 |
« Reply #1 on: November 24, 2012, 11:55:31 pm » |
Would really depend on your sketch, wouldn't it? I am betting manually, not all sending devices would be capable of resending. The protocol you are using would define what happens when parity error is detected. The data may have error correction built in for example, allowing the receiver to correct the error.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #2 on: November 25, 2012, 12:11:35 am » |
Thanks for the quick reply!
I don't suppose you know if there's a function I can call to determine if a parity error has been detected? I'm using SERIAL_8E1 (8 data bits, even parity, 1 stop bit) if that makes any difference.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 270
Posts: 17059
Available for Design & Build services
|
 |
« Reply #3 on: November 25, 2012, 12:16:47 am » |
I've not used anything except Serial.begin() library, no experience with parity detecting code. What's your environment that you expect parity errors to occur?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #4 on: November 25, 2012, 12:29:20 am » |
Sorry for the confusion. As of Arduino 1.0.2, Serial.begin() takes an extra (optional) parameter that defines the configuration of the serial connection. Since it's so new, the only information I could find on it was some discussion on Google Code, and the Serial/Begin page. I also tried snooping around the HardwareSerial code, but it's mostly over my head. I'm not expecting parity errors, but if they happen I'd like to be able to handle them gracefully.
|
|
|
|
« Last Edit: November 26, 2012, 07:27:42 am by MCDO »
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 270
Posts: 17059
Available for Design & Build services
|
 |
« Reply #5 on: November 25, 2012, 01:00:11 am » |
You're right, not much documented as to what happens when there is an incoming error. Have to get one of the real programmers involved.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #6 on: November 29, 2012, 08:12:41 am » |
What's the best way to get in contact with them?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 270
Posts: 17059
Available for Design & Build services
|
 |
« Reply #7 on: November 29, 2012, 02:39:32 pm » |
Try a PM to someone like Coding Badly
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 283
Posts: 15443
Measurement changes behavior
|
 |
« Reply #8 on: November 29, 2012, 06:52:32 pm » |
I think what you will find is that you will have to study the datasheet for the AVR chip and learn how the various options for parity checking are enabled and how actual received parity errors are detected and signaled. Once you do understand how the underlining hardware functions, then you have to see how you will go about either modifying the existing hardware serial library to integrate this new 'feature' or write your own custom serial library. The fact that the existing hardware serial library utilizes buffered interrupt driven on received characters makes this not so simple a feature to implement.
First you have to ask yourself what you want to happen if and when a character is received that has bad parity detected? Your choices are fairly limited, either just throw the character away or via a protocol you work out with the sender of the characters, send them a signal that you received a bad character and to resend the character or the complete message. So you see it can get quite complex quite quickly and it is very much just a part of the overall serial protocol you wish to utilize between the sender and receiver of serial data.
Good luck;
Lefty
|
|
|
|
« Last Edit: November 29, 2012, 06:54:48 pm by retrolefty »
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #9 on: November 29, 2012, 07:25:18 pm » |
The '328p datasheet (here: http://www.atmel.com/Images/doc8161.pdf), section 19, page 176, is the place to start in understanding parity support in the hardware. It looks like it both generates the parity bit on output and checks it on input. See 19.7.4 for Receiver Error flags. One issue with the Arduino buffered serial input (since you're not managing it yourself) will be knowing _which_ character was in error when the error flag lights up. Good luck with your project. -br
|
|
|
|
|
Logged
|
|
|
|
|
Finland
Offline
Jr. Member
Karma: 0
Posts: 55
|
 |
« Reply #10 on: November 30, 2012, 04:42:30 am » |
I do not know about parity errors. When I have tried to transfer data from Arduino to WindowsXP computer with as high speed as possible, it is quite seldom that the received character is wrong. Rather, there are more omissions of one or more characters the higher speed I try (up to about 1 megabaud).
Those omission errors should be detected also. A lot of work!
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #11 on: November 30, 2012, 07:09:50 am » |
Thanks for all your help guys!
I've decided to chicken out and implement a checksum-based error detection protocol instead of trying to do it with serial parity checking. I suspect that the new Serial.begin() function was implemented so that the Arduino could easily be connected to devices with fixed data & parity settings, (instead of people having to roll their own HardwareSerial library to support a particular device).
|
|
|
|
|
Logged
|
|
|
|
|
|