http://qs321.pair.com?node_id=11131313


in reply to Re^5: How to read serial port with WIN32:SerialPort?
in thread How to read serial port with WIN32:SerialPort?

The parity bit that this is referring to is a bit in an on-chip transmit control register. This register has to be modified to cause the chip generated parity bit to be set to indicate an address byte. And then be modified again to turn off address-mode.

My guess is the Device::SerialPort module doesn't use it's parity argument for this purpose.

Of course it does not. It becomes obvious when you read the POD of Device::SerialPort:

parity

One of the following: "none", "odd", "even".

To use the parity bit for non-parity purposes, you would need other values, e.g. "mark" and "space" or simply "0" and "1".

Also, parity() is one of the configuration parameter methods, not an operating method. It is not clear if changing the parity at operation time is supported:

Some individual parameters (eg. baudrate) can be changed after the initialization is completed. These will be validated and will update the serial driver as required.

Just to see an alternative implementation of a non-PC USART, here is a part of the documentation for the SERCOM peripheral of the Atmel/Microchip SAM D21 in USART Mode. It is also available in other SAMs, like the L21 and the D5x/E5x:

USART Features

  • Full-duplex Operation
  • Asynchronous (with Clock Reconstruction) or Synchronous Operation
  • Internal or External Clock source for Asynchronous and Synchronous Operation
  • ...
  • Supports Serial Frames with 5, 6, 7, 8 or 9 Data bits and 1 or 2 Stop bits
  • Odd or Even Parity Generation and Parity Check
  • Selectable LSB- or MSB-first Data Transfer
  • ...

Note that neither mark or space are supported for parity, but you can transfer 9 data bits. The data register is 16 bits wide to support using 9 data bits.

If you want to drive people really mad, you use 9 bit mode with parity enabled and two stop bits. This ends with a line format of 13 bits (1 start + 9 data + 1 parity + 2 stop bits), and only a few other U(S)ARTs will be able to send or receive that format.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^7: How to read serial port with WIN32:SerialPort?
by jmlynesjr (Deacon) on Apr 16, 2021 at 01:46 UTC

    Alexander:

    Thanks for comfirming my guess. I have not gotten around to reading the POD or code.

    I have nothing else to add to this topic. It was a good discussion.

    James

    There's never enough time to do it right, but always enough time to do it over...