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

Function section2

tests/rigctld_test.cpp:385–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383// ═════════════════════════════════════════════════════════════════════════════
384
385void section2(RigctlClient& c, Runner& r, qint64 origFreq)
386{
387 r.section(QStringLiteral("Section 2 — Frequency"));
388
389 // 2.1 get_freq long form
390 QStringList lines = c.send(QStringLiteral("\\get_freq"));
391 const QString freqStr = c.field(lines, QStringLiteral("Frequency"));
392 const qint64 gotFreq = freqStr.toLongLong();
393 r.check(QStringLiteral("2.1 get_freq returns numeric Hz value"),
394 c.ok(lines) && gotFreq > 0, freqStr);
395
396 // 2.2 + 2.3 set then verify
397 const qint64 testFreq = origFreq + 1000;
398 lines = c.send(QStringLiteral("\\set_freq %1").arg(testFreq));
399 r.check(QStringLiteral("2.2 set_freq returns RPRT 0"), c.ok(lines));
400 QThread::msleep(150);
401
402 lines = c.send(QStringLiteral("\\get_freq"));
403 const qint64 confirmed = c.field(lines, QStringLiteral("Frequency")).toLongLong();
404 r.check(QStringLiteral("2.3 get_freq confirms new frequency (%1 Hz)").arg(testFreq),
405 qAbs(confirmed - testFreq) < 10,
406 QStringLiteral("got %1").arg(confirmed));
407
408 c.send(QStringLiteral("\\set_freq %1").arg(origFreq));
409 QThread::msleep(100);
410
411 // 2.4 short form get
412 lines = c.send(QStringLiteral("f"));
413 r.check(QStringLiteral("2.4 short form \"f\" (get_freq) returns RPRT 0 with Frequency field"),
414 c.ok(lines) && isInt(c.field(lines, QStringLiteral("Frequency"))));
415
416 // 2.5 short form set
417 lines = c.send(QStringLiteral("F %1").arg(testFreq));
418 r.check(QStringLiteral("2.5 short form \"F\" (set_freq) returns RPRT 0"), c.ok(lines));
419 c.send(QStringLiteral("F %1").arg(origFreq));
420 QThread::msleep(100);
421
422 // 2.6 VFO-prefixed get_freq VFOA — same result as bare get_freq
423 lines = c.send(QStringLiteral("\\get_freq VFOA"));
424 r.check(QStringLiteral("2.6 get_freq VFOA returns same Hz as get_freq"),
425 c.ok(lines) && c.field(lines, QStringLiteral("Frequency")).toLongLong() == gotFreq,
426 c.field(lines, QStringLiteral("Frequency")));
427
428 // 2.7 VFO-prefixed set_freq VFOA <hz>
429 lines = c.send(QStringLiteral("\\set_freq VFOA %1").arg(testFreq));
430 r.check(QStringLiteral("2.7 set_freq VFOA returns RPRT 0"), c.ok(lines));
431 QThread::msleep(50);
432 lines = c.send(QStringLiteral("\\get_freq VFOA"));
433 r.check(QStringLiteral("2.8 get_freq VFOA confirms VFO-prefixed set_freq"),
434 c.ok(lines) && std::abs(c.field(lines, QStringLiteral("Frequency")).toLongLong() - testFreq) < 100,
435 c.field(lines, QStringLiteral("Frequency")));
436 c.send(QStringLiteral("\\set_freq %1").arg(origFreq));
437 QThread::msleep(50);
438
439 // 2.8b get_freq VFOB with no split — must return RIG_ENAVAIL (-8)
440 lines = c.send(QStringLiteral("\\get_freq VFOB"));
441 r.check(QStringLiteral("2.8b get_freq VFOB (no split) returns RPRT -8"),
442 lines.join(QLatin1String("")).contains(QLatin1String("RPRT -8")),

Callers 1

mainFunction · 0.70

Calls 8

isIntFunction · 0.85
containsMethod · 0.80
sendRawMethod · 0.80
sectionMethod · 0.45
sendMethod · 0.45
fieldMethod · 0.45
checkMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected