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

Method setStopBits

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

* @brief Changes the stop bits of the serial port. */

Source from the content-addressed store, hash-verified

645 * @brief Changes the stop bits of the serial port.
646 */
647void IO::Drivers::UART::setStopBits(const quint8 stopBitsIndex)
648{
649 if (stopBitsIndex >= stopBitsList().count()) {
650 qWarning() << "UART::setStopBits: index" << stopBitsIndex << "out of range";
651 return;
652 }
653
654 if (m_stopBitsIndex == stopBitsIndex)
655 return;
656
657 m_stopBitsIndex = stopBitsIndex;
658 m_settings.setValue("UartDriver/stopBits", stopBitsIndex);
659
660 switch (stopBitsIndex) {
661 case 0:
662 m_stopBits = QSerialPort::OneStop;
663 break;
664 case 1:
665 m_stopBits = QSerialPort::OneAndHalfStop;
666 break;
667 case 2:
668 m_stopBits = QSerialPort::TwoStop;
669 break;
670 }
671
672 if (port())
673 port()->setStopBits(stopBits());
674
675 Q_EMIT stopBitsChanged();
676}
677
678/**
679 * @brief Enables or disables the auto-reconnect feature.

Callers 1

openMethod · 0.45

Calls 1

countMethod · 0.45

Tested by

no test coverage detected