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

Method getConfiguration

app/src/API/Handlers/UARTHandler.cpp:477–519  ·  view source on GitHub ↗

* @brief Get current UART configuration */

Source from the content-addressed store, hash-verified

475 * @brief Get current UART configuration
476 */
477API::CommandResponse API::Handlers::UARTHandler::getConfiguration(const QString& id,
478 const QJsonObject& params)
479{
480 Q_UNUSED(params)
481
482 auto* uart = IO::ConnectionManager::instance().uart();
483
484 QJsonObject result;
485
486 result[QStringLiteral("portIndex")] = uart->portIndex();
487 const auto& portList = uart->portList();
488 if (uart->portIndex() < portList.count())
489 result[QStringLiteral("portName")] = portList.at(uart->portIndex());
490
491 result[QStringLiteral("baudRate")] = uart->baudRate();
492
493 result[QStringLiteral("parityIndex")] = uart->parityIndex();
494 const auto& parityList = uart->parityList();
495 if (uart->parityIndex() < parityList.count())
496 result[QStringLiteral("parityName")] = parityList.at(uart->parityIndex());
497
498 result[QStringLiteral("dataBitsIndex")] = uart->dataBitsIndex();
499 const auto& dataBitsList = uart->dataBitsList();
500 if (uart->dataBitsIndex() < dataBitsList.count())
501 result[QStringLiteral("dataBitsValue")] = dataBitsList.at(uart->dataBitsIndex());
502
503 result[QStringLiteral("stopBitsIndex")] = uart->stopBitsIndex();
504 const auto& stopBitsList = uart->stopBitsList();
505 if (uart->stopBitsIndex() < stopBitsList.count())
506 result[QStringLiteral("stopBitsValue")] = stopBitsList.at(uart->stopBitsIndex());
507
508 result[QStringLiteral("flowControlIndex")] = uart->flowControlIndex();
509 const auto& flowControlList = uart->flowControlList();
510 if (uart->flowControlIndex() < flowControlList.count())
511 result[QStringLiteral("flowControlName")] = flowControlList.at(uart->flowControlIndex());
512
513 result[QStringLiteral("dtrEnabled")] = uart->dtrEnabled();
514 result[QStringLiteral("autoReconnect")] = uart->autoReconnect();
515 result[QStringLiteral("isOpen")] = uart->isOpen();
516 result[QStringLiteral("configurationOk")] = uart->configurationOk();
517
518 return CommandResponse::makeSuccess(id, result);
519}

Callers

nothing calls this directly

Calls 15

uartMethod · 0.80
portIndexMethod · 0.80
portListMethod · 0.80
flowControlIndexMethod · 0.80
flowControlListMethod · 0.80
dtrEnabledMethod · 0.80
autoReconnectMethod · 0.80
countMethod · 0.45
baudRateMethod · 0.45
parityIndexMethod · 0.45
parityListMethod · 0.45
dataBitsIndexMethod · 0.45

Tested by

no test coverage detected