1

I am coding with serial communication in windows. In this communication, in order for program to recognize a start of message, i have to use parity bit.

It means that if the byte received with setting parity bit is a start point of a message.

For example, If receiving bytes like below from a serial port ([byte] means a byte received, and [byte]p means a byte with setting a parity bit)

Serial port <-[byte]<- [byte]<- [byte]<- [byte]<- [byte]p<- [byte] : sequence bytes received

I have to parse above the message after discarding 4 bytes before a byte with setting parity bit.

In the case of Linux, a Setting parity bit is represented as 0XFF 0x00 so if i receive 1 byte 0xEE with parity. It is denoted as 0xFF 0x00 0xEE, so that I can picked the start point.

But in windows, parity bit seems to be represented as event EV_ERR by WaitCommEvent() And read data separately by ReadFile().

I think it is difficult to find out where parity error happen to distinguish a start point of message.

Is there any way to solve this problem, actually since i am new at windows programming, i think there must exist other way, right ?

SangminKim
  • 8,358
  • 14
  • 69
  • 125
  • 1
    Protocols like this are invented by companies that also have the hardware to sell you. Knowing full well that you don't stand a chance to implement it yourself. Buy the product. – Hans Passant Nov 13 '14 at 15:27
  • *"[byte]p means a byte with setting a parity bit"* -- You seem to be trying to describe a 9-bit character. The parity bit would be the high-order bit. So the correct representation should be p. For possible solutions see http://superuser.com/questions/411386/seeking-9-bit-serial-port-card-for-windows-pc/411438#411438 – sawdust Nov 13 '14 at 20:22
  • If you can take over the parity bit in software, then every 8-bit UART with parity is secretly a 9-bit UART without parity, just need to twiddle the bits to put everything in the correctly bit order again. Its a pity M$ hasn't updated their Serial Port Driver in years...You might fare better with Linux... and 9-bits is the holy grail for easy framing of control and data... – Bimo Aug 06 '17 at 08:42

1 Answers1

0

The documentation seems clear on how parity errors are handled (or not): "Because the operating system determines whether to raise this event or not, not all parity errors may be reported"

Luis Alvarado Day
  • 217
  • 1
  • 3
  • 14