Re: Serial communication, detecting parity bits
- From: Tauno Voipio <tauno.voipio@xxxxxxxxxxxxx>
- Date: Wed, 25 Jan 2006 19:00:23 GMT
Mattias Brändström wrote:
Tauno Voipio wrote:
kobus wrote:
IIRC, the Stick Parity bit in the 8250 -family of serial interfaces
by-passes the parity generation, creating a ninth bit which can be controlled with the even/odd parity bit. Similarly, a received ninth bit can be detected as a parity error state change.
I have now been able to look a bit more closely at the serial port api in Linux. It seems that I can detect parity errors by setting PARMRK bit with tcsetattr(). Since the protocol that I have to use does not use any parity but uses the wakeup bit I can set my serial port to use either even or odd parity and then bytes that has a parity error will be prefixed with the bytes 0xff and 0x00. This will enable me to calculate what value the wakeup bit had for each byte.
The only thing I worried about now is what will happen if my the data stream contains the combination 0xff 0x00. How do I know that that combination is legitimate data and not a parity error?
Maybe someone has a nice solution to this?
:.:: mattias
The classic method for coding out-of-band data is similar to that used in PPP: christen one byte code (not either of the codes already out-of-band), e.g. 0x7d to mark out of band data and add the code there suitably modified.
The PPP method uses 0x7d to escape the control characters: if there is a reserved code in the data payload, replace it by the bytes 0x7d, data xor 0x20. This transforms the unhandleable code to something that can be sent. The receiving end has to detect the marker byte (0x7d) and decode the next byte as the real payload byte. Of course, the marker byte has to be encoded if it occurs in the payload.
Using this method, the bytes will be coded:
payload byte encoded sequence ------------ ----------------
0x00 0x7d 0x20
0x7d 0x7d 0x5d
0xff 0x7d 0xdfHTH
--
Tauno Voipio tauno voipio (at) iki fi .
- References:
- Serial communication, detecting parity bits
- From: Mattias Brändström
- Re: Serial communication, detecting parity bits
- From: kobus
- Re: Serial communication, detecting parity bits
- From: Tauno Voipio
- Re: Serial communication, detecting parity bits
- From: Mattias Brändström
- Serial communication, detecting parity bits
- Prev by Date: Re: running at boot time & signals
- Next by Date: Re: running at boot time & signals
- Previous by thread: Re: Serial communication, detecting parity bits
- Next by thread: Re: Serial communication, detecting parity bits
- Index(es):
Relevant Pages
|