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

Method getPortList

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

* @brief Get list of available serial ports */

Source from the content-addressed store, hash-verified

430 * @brief Get list of available serial ports
431 */
432API::CommandResponse API::Handlers::UARTHandler::getPortList(const QString& id,
433 const QJsonObject& params)
434{
435 Q_UNUSED(params)
436
437 const auto& portList = IO::ConnectionManager::instance().uart()->portList();
438
439 QJsonArray ports;
440 for (int i = 0; i < portList.count(); ++i) {
441 QJsonObject port;
442 port[QStringLiteral("index")] = i;
443 port[QStringLiteral("name")] = portList.at(i);
444 ports.append(port);
445 }
446
447 QJsonObject result;
448 result[QStringLiteral("portList")] = ports;
449 result[QStringLiteral("currentPortIndex")] =
450 IO::ConnectionManager::instance().uart()->portIndex();
451 return CommandResponse::makeSuccess(id, result);
452}
453
454/**
455 * @brief Get list of common baud rates

Callers

nothing calls this directly

Calls 5

portListMethod · 0.80
uartMethod · 0.80
portIndexMethod · 0.80
countMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected