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

Method setMode

app/src/API/Handlers/ProcessHandler.cpp:100–121  ·  view source on GitHub ↗

* @brief Set the driver mode. */

Source from the content-addressed store, hash-verified

98 * @brief Set the driver mode.
99 */
100API::CommandResponse API::Handlers::ProcessHandler::setMode(const QString& id,
101 const QJsonObject& params)
102{
103 if (!params.contains(QStringLiteral("mode"))) {
104 return CommandResponse::makeError(
105 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: mode"));
106 }
107
108 const int mode = params.value(QStringLiteral("mode")).toInt();
109 if (mode < 0 || mode > 1) {
110 return CommandResponse::makeError(
111 id,
112 ErrorCode::InvalidParam,
113 QStringLiteral("Invalid mode: %1. Valid values: 0=Launch, 1=NamedPipe").arg(mode));
114 }
115
116 IO::ConnectionManager::instance().process()->setMode(mode);
117
118 QJsonObject result;
119 result[QStringLiteral("mode")] = mode;
120 return CommandResponse::makeSuccess(id, result);
121}
122
123/**
124 * @brief Set the executable path for Launch mode.

Callers 1

applyPublisherTopicsFunction · 0.45

Calls 3

containsMethod · 0.45
valueMethod · 0.45
processMethod · 0.45

Tested by

no test coverage detected