Re: Serial communication, detecting parity bits
- From: floyd@xxxxxxxxxx (Floyd L. Davidson)
- Date: Fri, 20 Jan 2006 03:04:23 -0900
Mattias Brändström <"thebrasse at brasse dot org"> wrote:
>Hello!
>
>I'm in the process of writing some code that will use RS-232 and
>a somewhat old protocol to speak to some external hardware. The
>protocol specifies that the first byte of each protocol packet
>will have its wakeup bit or parity bit set. I need to find these
>marked bytes in order to determine where each packet starts.
>
>This confuses me a bit. All serial communication programming I
>have done so far have beem blissfully unaware of parity bits,
>stop bits and so forth. As I understand it these are abstracted
>away by read(), open(), tcsetattr(), etc.
>
>My question is this: Is there some way that I can figure out if
>the wakeup or parity bit was set on a specific byte in the
>stream that I have read from the serial port?
The "parity bit" is the 8th bit (also called the "high" bit).
For the program to detect it, the serial port needs to be set for
"8 bits no parity", which will allow the program to see all 8 bits
of each byte. Essentially that means the serial port knows nothing
about parity.
Of course the program merely needs to AND each bit with 0x80 and
test for non-zero to detect whether the high bit is set on any
given byte.
--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@xxxxxxxxxx
.
- Follow-Ups:
- Re: Serial communication, detecting parity bits
- From: Grant Edwards
- Re: Serial communication, detecting parity bits
- References:
- Serial communication, detecting parity bits
- From: Mattias Brändström
- Serial communication, detecting parity bits
- Prev by Date: open() hanging...
- Next by Date: Re: open() hanging...
- Previous by thread: Serial communication, detecting parity bits
- Next by thread: Re: Serial communication, detecting parity bits
- Index(es):
Relevant Pages
|