mirror of
https://github.com/vicliu624/trail-mate.git
synced 2026-11-11 14:47:39 +00:00
Keep IQ capture isolated from decoder startup and rendering, bound transport backpressure, validate DMA batches before publication, and expose playback telemetry. Preserve radio restoration and add capture, transport, media and SDL regression coverage. Document user-accepted CM0 and Sony reception and the limits of the one-shot kernel experiment. Repair stale preview TileContext initialization, missing simulator link sources and Cardputer SDL dependencies. Align menu and radio-log contracts with current implementations, keep AutoInterface port admission covered, refresh source inventories, and apply the CI clang-format 14 rules. Validation: 45 Agenda tests, 30 1seg tests, 8 LR2021 IQ tests, 17 native config interop tests, ESP stack hygiene, platform/root guards, source inventories, clang-format 14, git diff --check, and staged GitNexus detect_changes.
109 lines
3.8 KiB
C++
109 lines
3.8 KiB
C++
#include "platform/desktop/device_options.h"
|
|
#include <cstdio>
|
|
#include <stdexcept>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
if (argc < 2 || argc > 4) return 1;
|
|
const auto options = platform::desktop::loadDeviceOptions(argv[1]);
|
|
if (options.radio.oneseg_gain_step != (argc >= 3 ? std::stoul(argv[2]) : 0)) return 14;
|
|
if (options.radio.oneseg_sample_rate_hz != (argc == 4 ? std::stoul(argv[3]) : 576000)) return 15;
|
|
if (options.width != 1232 || options.height != 568 || options.rotation != 0 || !options.auto_keyboard ||
|
|
!options.fullscreen || options.ux_pack != "t_display_p4_touch") return 2;
|
|
if (options.radio.driver != "lr2021" || options.radio.bus.spi_device != "/dev/spidev0.0" ||
|
|
options.radio.bus.reset_gpio != 7 || options.radio.bus.busy_gpio != 24 ||
|
|
options.radio.bus.irq_gpio != -1 || options.radio.tcxo_voltage != 3.0f) return 4;
|
|
using RfProfile = platform::linux_runtime::Lr2021RfSwitchProfile;
|
|
if (options.radio.rf_switch_profile != RfProfile::Cm0_16E8 ||
|
|
platform::desktop::DeviceOptions{}.radio.rf_switch_profile != RfProfile::None) return 12;
|
|
for (const bool wrong_driver : {false, true})
|
|
{
|
|
auto invalid_rf = options;
|
|
if (wrong_driver) invalid_rf.radio.driver = "sx126x";
|
|
else invalid_rf.radio.rf_switch_profile = static_cast<RfProfile>(255);
|
|
try
|
|
{
|
|
platform::desktop::validateDeviceOptions(invalid_rf);
|
|
return 13;
|
|
}
|
|
catch (const std::runtime_error&)
|
|
{
|
|
}
|
|
}
|
|
if (options.sensors.expected || options.sensors.landscape_rotation) return 5;
|
|
if (options.runtime_mode != platform::linux_runtime::LinuxRuntimeMode::DeviceRealMesh) return 7;
|
|
if (options.gnss.protocol != "nmea" || !options.gnss.device.empty() ||
|
|
options.gnss.baud != 0 || options.gnss.modem_lines || options.gnss.gnss_only_setup) return 6;
|
|
if (options.gnss.power.line != -1) return 8;
|
|
if (options.screen_power != "none" || !options.screen_power_output.empty()) return 10;
|
|
auto display = options;
|
|
display.screen_power = "wayland";
|
|
display.screen_power_output = "external-display";
|
|
platform::desktop::validateDeviceOptions(display);
|
|
display.screen_power = "invalid";
|
|
try
|
|
{
|
|
platform::desktop::validateDeviceOptions(display);
|
|
return 11;
|
|
}
|
|
catch (const std::runtime_error&)
|
|
{
|
|
}
|
|
auto conflict = options;
|
|
conflict.gnss.power.chip = "/dev/gpiochip0";
|
|
conflict.gnss.power.line = options.radio.bus.reset_gpio;
|
|
bool rejected = false;
|
|
try
|
|
{
|
|
platform::desktop::validateDeviceOptions(conflict);
|
|
}
|
|
catch (const std::runtime_error&)
|
|
{
|
|
rejected = true;
|
|
}
|
|
if (!rejected) return 9;
|
|
auto invalid_gain = options;
|
|
invalid_gain.radio.oneseg_gain_step = 14;
|
|
rejected = false;
|
|
try
|
|
{
|
|
platform::desktop::validateDeviceOptions(invalid_gain);
|
|
}
|
|
catch (const std::runtime_error&)
|
|
{
|
|
rejected = true;
|
|
}
|
|
if (!rejected) return 10;
|
|
auto invalid_rate = options;
|
|
invalid_rate.radio.oneseg_sample_rate_hz = 499999;
|
|
rejected = false;
|
|
try
|
|
{
|
|
platform::desktop::validateDeviceOptions(invalid_rate);
|
|
}
|
|
catch (const std::runtime_error&)
|
|
{
|
|
rejected = true;
|
|
}
|
|
if (!rejected) return 16;
|
|
// A second device can use this same backend without acquiring CM0 defaults.
|
|
auto other = options;
|
|
other.width = 800;
|
|
other.height = 480;
|
|
other.rotation = 0;
|
|
other.fullscreen = false;
|
|
other.gnss.power = {};
|
|
platform::desktop::validateDeviceOptions(other);
|
|
other.rotation = 45;
|
|
try
|
|
{
|
|
platform::desktop::validateDeviceOptions(other);
|
|
}
|
|
catch (const std::runtime_error&)
|
|
{
|
|
return 0;
|
|
}
|
|
std::fputs("Invalid rotation was accepted\n", stderr);
|
|
return 3;
|
|
}
|