This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Serial port - Parity question
#1
Hi
I need to communicate via a serial line with a device which requires a special behavior of the parity bit.
I've to send this strange structure:
The communication is two bytes only.
The first byte (address) must ends with parity bit always set to 1
The second byte (data) must ends with parity bit always set to 0
Fortunately the communication is 2 wires only. So I don't need to maintain signalling.

Do you have any idea how to do it?

Can I set parity setting to "Always 1" or "Always 0"? In this example I see none, even or odd. http://openrb.com/serial-port-communication-in-lm2/

Can I switch the parity settings after the port has already been opened?

In case everything above fails. Can I:
1. Calculate parity for address
2. Open the serial port with the calculated parity setting
3. Send the address I want to set
4. close the port
5. Calculate parity for data
6. Open the serial port with the data calculated parity setting
7. Send the data
4. close the port

I'm afraid about buffering. In case the sending won't be fast enough (or the script too fast) did the second port opening clear the sending buffer?

Thank you for any ideas
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259
Reply
#2
Sticky parity is not implemented because it's not standard and will not work on all supported platforms. Your approach should work, closing the port waits until all output has been transmitted.
Reply


Forum Jump: