Specify type of parity checking
You can configure Parity to be none, odd, even, mark,
or space. If Parity is none,
parity checking is not performed and the parity bit is not transmitted.
If Parity is odd, the number
of mark bits (1s) in the data is counted, and the parity bit is asserted
or unasserted to obtain an odd number of mark bits. If Parity is even,
the number of mark bits in the data is counted, and the parity bit
is asserted or unasserted to obtain an even number of mark bits. If Parity is mark,
the parity bit is asserted. If Parity is space,
the parity bit is unasserted.
Parity checking can detect errors of one bit only. An error in two bits might cause the data to have a seemingly valid parity, when in fact it is incorrect. To learn more about parity checking, refer to Parity Bit.
In addition to the parity bit, the serial data format consists
of a start bit, between five and eight data bits, and one or two stop
bits. You specify the number of data bits with the DataBits property,
and the number of stop bits with the StopBits property.
Usage | Serial port, VISA-serial |
Read only | Never |
Data type | Character vector |
Default value is enclosed in braces ({}).
| No parity checking |
| Odd parity checking |
| Even parity checking |
| Mark parity checking |
| Space parity checking |
This example shows how to set the parity for a serial port object.
Create a serial port object associated with the COM1 port. The
default setting for Parity is none,
so if you want to use parity checking, change the value to the type
you want to use, for example, odd.
s = serial('COM1');
s.Parity = 'odd';