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

Method getConfiguration

app/src/API/Handlers/CANBusHandler.cpp:221–251  ·  view source on GitHub ↗

* @brief Get current CAN bus configuration */

Source from the content-addressed store, hash-verified

219 * @brief Get current CAN bus configuration
220 */
221API::CommandResponse API::Handlers::CANBusHandler::getConfiguration(const QString& id,
222 const QJsonObject& params)
223{
224 Q_UNUSED(params)
225
226 auto* canbus = IO::ConnectionManager::instance().canBus();
227
228 QJsonObject result;
229
230 result[QStringLiteral("pluginIndex")] = canbus->pluginIndex();
231 const auto& pluginList = canbus->pluginList();
232 if (canbus->pluginIndex() < pluginList.count())
233 result[QStringLiteral("pluginName")] = pluginList.at(canbus->pluginIndex());
234
235 result[QStringLiteral("interfaceIndex")] = canbus->interfaceIndex();
236 const auto& interfaceList = canbus->interfaceList();
237 if (canbus->interfaceIndex() < interfaceList.count())
238 result[QStringLiteral("interfaceName")] = interfaceList.at(canbus->interfaceIndex());
239
240 result[QStringLiteral("bitrate")] = static_cast<qint64>(canbus->bitrate());
241 result[QStringLiteral("canFD")] = canbus->canFD();
242
243 result[QStringLiteral("isOpen")] = canbus->isOpen();
244 result[QStringLiteral("configurationOk")] = canbus->configurationOk();
245
246 const QString interfaceError = canbus->interfaceError();
247 if (!interfaceError.isEmpty())
248 result[QStringLiteral("interfaceError")] = interfaceError;
249
250 return CommandResponse::makeSuccess(id, result);
251}
252
253/**
254 * @brief Get list of available CAN plugins

Callers

nothing calls this directly

Calls 12

canBusMethod · 0.80
pluginIndexMethod · 0.80
pluginListMethod · 0.80
interfaceIndexMethod · 0.80
interfaceListMethod · 0.80
bitrateMethod · 0.80
canFDMethod · 0.80
interfaceErrorMethod · 0.80
isEmptyMethod · 0.80
countMethod · 0.45
isOpenMethod · 0.45
configurationOkMethod · 0.45

Tested by

no test coverage detected