* @brief Get current UART configuration */
| 475 | * @brief Get current UART configuration |
| 476 | */ |
| 477 | API::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 | } |
nothing calls this directly
no test coverage detected