The chooser runs before ScopeModel exists, so declining costs no buffer and no socket. UDPSCOPE_PROBE_SOURCES=1 prints what the discovery found and exits, before gtk_init(), so the list is checkable with no display.
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
// SPDX-License-Identifier: MIT
|
|
// SPDX-FileCopyrightText: 2026 Martino Ferrari
|
|
|
|
#include "acquisition.hpp"
|
|
#include "config.hpp"
|
|
#include "model.hpp"
|
|
#include "plot_host.hpp"
|
|
#include "source_dialog.hpp"
|
|
#include "ui.hpp"
|
|
|
|
#include <cstdio>
|
|
#include <exception>
|
|
|
|
int main(int argc, char** argv) {
|
|
udpscope::Config cfg;
|
|
try {
|
|
cfg = udpscope::parse_args(argc, argv);
|
|
} catch (const std::exception& e) {
|
|
std::fprintf(stderr, "udpscope: %s\n", e.what());
|
|
return 2;
|
|
}
|
|
|
|
// No `--server` means the user has not said which source to open, so ask. Before the model:
|
|
// declining must cost no buffer and no socket, and nothing below has to cope with "no source".
|
|
if (!cfg.server_specified && !udpscope::choose_source(cfg)) return 0;
|
|
|
|
udpscope::ScopeModel model(cfg);
|
|
udpscope::RowSet rows;
|
|
rows.set_row_count(cfg.plots);
|
|
udpscope::Acquisition acquisition(model, cfg);
|
|
try {
|
|
acquisition.start();
|
|
} catch (const std::exception& e) {
|
|
std::fprintf(stderr, "udpscope: %s\n", e.what());
|
|
return 1;
|
|
}
|
|
|
|
const int result = udpscope::run_ui(argc, argv, cfg, model, acquisition, rows);
|
|
acquisition.stop();
|
|
return result;
|
|
}
|