* @brief Sets the serial port parity by index from parityList(). */
| 568 | * @brief Sets the serial port parity by index from parityList(). |
| 569 | */ |
| 570 | void IO::Drivers::UART::setParity(const quint8 parityIndex) |
| 571 | { |
| 572 | if (parityIndex >= parityList().count()) { |
| 573 | qWarning() << "UART::setParity: index" << parityIndex << "out of range"; |
| 574 | return; |
| 575 | } |
| 576 | |
| 577 | if (m_parityIndex == parityIndex) |
| 578 | return; |
| 579 | |
| 580 | m_parityIndex = parityIndex; |
| 581 | m_settings.setValue("UartDriver/parity", parityIndex); |
| 582 | |
| 583 | switch (parityIndex) { |
| 584 | case 0: |
| 585 | m_parity = QSerialPort::NoParity; |
| 586 | break; |
| 587 | case 1: |
| 588 | m_parity = QSerialPort::EvenParity; |
| 589 | break; |
| 590 | case 2: |
| 591 | m_parity = QSerialPort::OddParity; |
| 592 | break; |
| 593 | case 3: |
| 594 | m_parity = QSerialPort::SpaceParity; |
| 595 | break; |
| 596 | case 4: |
| 597 | m_parity = QSerialPort::MarkParity; |
| 598 | break; |
| 599 | } |
| 600 | |
| 601 | if (port()) |
| 602 | port()->setParity(parity()); |
| 603 | |
| 604 | Q_EMIT parityChanged(); |
| 605 | } |
| 606 | |
| 607 | /** |
| 608 | * @brief Changes the data bits of the serial port. |