0

I've used the arduino uno with the python serial library months ago and some packets got lost in the way. I've been searching about serial communication for arduino and I've been thinking that I could use some parity systems and other things to guarantee that my packets will arrive. First of all, if I use the parity system of the arduino's serial library, how good it will be? I need to send packets like "this button was touched", but ALL packets must arrive, so if some packet fails, I need to send it again.

How to make it possible? I'm thinking about using the parity system of the arduino's library, but I don't think if it's gonna work well.

Can somebody point me some good text about it?

3
  • You seem to be freely intermixing three extremely distinct concepts - Arduino "serial" which tends to mean UART-style asynchronous, "packets" a concept for which the previous serial has no inherent support, and then a rather random i2c tag, which is something else entirely (a shared synchronous signalling scheme). Step one is going to be to sort out what specifically and exactly you are asking about. Commented Jan 2, 2015 at 19:32
  • Also note that on direct connections such as you likely have, failure is extremely infrequent - if you are seeing it, then likely you either have software which does not service the channel frequently enough to avoid missing data, or else extreme electrical noise. While protocol-level integrity can be useful (especially where misoperation has real consequences), in a scheme that shouldn't be failing you should spend some time trying to understand why it is. Commented Jan 2, 2015 at 19:34
  • What baud rate are you using? Commented Jan 2, 2015 at 23:32

1 Answer 1

1

There is no way to guarantee that all packets will arrive. The best you can do is to have the receiving system acknowledge receipt of all packets, with enough data within to verify the correctness of the packets.

UART parity is not a good method to verify correctness since it can only detect single-bit errors within a byte; two bit errors will verify correctly, and of course the entire byte may get dropped before it can even get to the receiver.

RFC 916, "RELIABLE ASYNCHRONOUS TRANSFER PROTOCOL (RATP)", describes a TCP/IP-like method of sending data reliably over an asynchronous medium. It's more wordy than just sending a byte containing status changes, but if you need reliability then you need more than that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.