MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setParity

Method setParity

app/src/IO/Drivers/UART.cpp:570–605  ·  view source on GitHub ↗

* @brief Sets the serial port parity by index from parityList(). */

Source from the content-addressed store, hash-verified

568 * @brief Sets the serial port parity by index from parityList().
569 */
570void 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.

Callers 1

openMethod · 0.45

Calls 1

countMethod · 0.45

Tested by

no test coverage detected