MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / section8

Function section8

tests/rigctld_test.cpp:1329–1429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1327// ═════════════════════════════════════════════════════════════════════════════
1328
1329void section8(RigctlClient& c, Runner& r)
1330{
1331 r.section(QStringLiteral("Section 8 — Functions"));
1332
1333 struct FuncCase { const char* name; const char* getId; const char* setOnId; const char* setOffId; };
1334 static constexpr FuncCase kFuncs[] = {
1335 {"NB", "8.1", "8.2", "8.3"},
1336 {"NR", "8.4", "8.5", nullptr},
1337 {"ANF", "8.6", "8.7", nullptr},
1338 {"VOX", "8.8", "8.9", nullptr},
1339 {"MUTE", "8.10", nullptr, nullptr},
1340 };
1341 for (const auto& fn : kFuncs) {
1342 const QString fnName = QLatin1String(fn.name);
1343 QStringList lines = c.send(QStringLiteral("\\get_func ") + fnName);
1344 const QString val = c.field(lines, fnName);
1345 r.check(QStringLiteral("%1 get_func %2 returns 0 or 1")
1346 .arg(QLatin1String(fn.getId), fnName),
1347 c.ok(lines) && (val == QLatin1String("0") || val == QLatin1String("1")), val);
1348
1349 const QString orig = val;
1350 if (fn.setOnId) {
1351 lines = c.send(QStringLiteral("\\set_func %1 1").arg(fnName));
1352 r.check(QStringLiteral("%1 set_func %2 1 returns RPRT 0")
1353 .arg(QLatin1String(fn.setOnId), fnName),
1354 c.ok(lines));
1355 }
1356 if (fn.setOffId) {
1357 lines = c.send(QStringLiteral("\\set_func %1 0").arg(fnName));
1358 r.check(QStringLiteral("%1 set_func %2 0 returns RPRT 0")
1359 .arg(QLatin1String(fn.setOffId), fnName),
1360 c.ok(lines));
1361 }
1362 if (fn.setOnId && !orig.isNull())
1363 c.send(QStringLiteral("\\set_func %1 %2").arg(fnName, orig));
1364 }
1365
1366 // 8.11 get_func TONE — must return 0 or 1 (CTCSS TX encode on/off)
1367 {
1368 QStringList lines = c.send(QStringLiteral("\\get_func TONE"));
1369 const QString val = c.field(lines, QStringLiteral("TONE"));
1370 r.check(QStringLiteral("8.11 get_func TONE returns 0 or 1"),
1371 c.ok(lines) && (val == QLatin1String("0") || val == QLatin1String("1")), val);
1372
1373 // 8.12 set_func TONE 1 / set_func TONE 0 — round-trip
1374 const QString orig = val;
1375 lines = c.send(QStringLiteral("\\set_func TONE 1"));
1376 r.check(QStringLiteral("8.12 set_func TONE 1 returns RPRT 0"), c.ok(lines));
1377 QThread::msleep(50);
1378 lines = c.send(QStringLiteral("\\get_func TONE"));
1379 r.check(QStringLiteral("8.12 get_func TONE after set 1 returns 1"),
1380 c.field(lines, QStringLiteral("TONE")) == QLatin1String("1"),
1381 c.field(lines, QStringLiteral("TONE")));
1382 lines = c.send(QStringLiteral("\\set_func TONE 0"));
1383 r.check(QStringLiteral("8.12 set_func TONE 0 returns RPRT 0"), c.ok(lines));
1384 // Restore original
1385 if (!orig.isEmpty())
1386 c.send(QStringLiteral("\\set_func TONE %1").arg(orig));

Callers 1

mainFunction · 0.70

Calls 9

isNullMethod · 0.80
containsMethod · 0.80
sectionMethod · 0.45
sendMethod · 0.45
fieldMethod · 0.45
checkMethod · 0.45
okMethod · 0.45
isEmptyMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected