Re: Serial communication, detecting parity bits



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
.



Relevant Pages

  • Re: Possible to receive 8O1 data on serial port?
    ... If you use the high bit for parity, ... The guide for POSIX is an excellent resource! ... The same comments as above go for all of the termios flag members. ... The above prevents a common problem where a serial port has be ...
    (comp.os.linux.networking)
  • Re: Possible to receive 8O1 data on serial port?
    ... If you use the high bit for parity, ... The guide for POSIX is an excellent resource! ... The same comments as above go for all of the termios flag members. ... The above prevents a common problem where a serial port has be ...
    (comp.os.linux.development.apps)
  • Re: display output from serial port device
    ... If your program fails to open the serial port, ... If you do want parity, restore INPCK, but also add PARENB to ... always get the right number of characters. ...
    (comp.os.linux.development.system)
  • Re: display output from serial port device
    ... >>i use the following code to connect to HA3035 proximity access controller ... What if the last program to use the serial port ... > If you do want parity, restore INPCK, but also add PARENB to ... > always get the right number of characters. ...
    (comp.os.linux.development.system)
  • Re: Hash refs of hashs

    (perl.beginners)