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

Method read_io_settings

app/src/DataModel/Frame.cpp:66–91  ·  view source on GitHub ↗

* @brief Reads frame delimiters and checksum algorithm from a source JSON object, resolving * hex/escape encodings and accepting the legacy "checksum" key as a fallback. */

Source from the content-addressed store, hash-verified

64 * hex/escape encodings and accepting the legacy "checksum" key as a fallback.
65 */
66void DataModel::read_io_settings(QByteArray& frameStart,
67 QByteArray& frameEnd,
68 QString& checksum,
69 const QJsonObject& obj)
70{
71 auto fEndStr = ss_jsr(obj, Keys::FrameEnd, "").toString();
72 auto fStartStr = ss_jsr(obj, Keys::FrameStart, "").toString();
73 auto isHex = ss_jsr(obj, Keys::HexadecimalDelimiters, false).toBool();
74
75 if (obj.contains(Keys::ChecksumAlgorithm))
76 checksum = obj.value(Keys::ChecksumAlgorithm).toString();
77 else
78 checksum = ss_jsr(obj, Keys::Checksum, "").toString();
79
80 if (isHex) {
81 QString resolvedEnd = SerialStudio::resolveEscapeSequences(fEndStr);
82 QString resolvedStart = SerialStudio::resolveEscapeSequences(fStartStr);
83 frameStart = QByteArray::fromHex(resolvedStart.remove(' ').toUtf8());
84 frameEnd = QByteArray::fromHex(resolvedEnd.remove(' ').toUtf8());
85 }
86
87 else {
88 frameEnd = SerialStudio::resolveEscapeSequences(fEndStr).toUtf8();
89 frameStart = SerialStudio::resolveEscapeSequences(fStartStr).toUtf8();
90 }
91}
92
93//--------------------------------------------------------------------------------------------------
94// JSON helpers that parse numbers (out-of-line so they can reach SerialStudio::toDouble)

Callers

nothing calls this directly

Calls 4

ss_jsrFunction · 0.85
containsMethod · 0.45
valueMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected