MCPcopy Create free account
hub / github.com/SatDump/SatDump / main_record

Function main_record

src-cli/record.cpp:21–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21int main_record(int argc, char *argv[])
22{
23 if (argc < 5) // Check overall command
24 {
25 logger->error("Usage : " + std::string(argv[0]) + " record [output_baseband (without extension!)] [additional options as required]");
26 logger->error("Extra options (examples. Any parameter used in sources can be used here) :");
27 logger->error(" --samplerate [baseband_samplerate] --baseband_format [cf32/cs32/cs16/cs8/cu8/wav16/ziq] --dc_block --iq_swap");
28 logger->error(" --source [airspy/rtlsdr/etc] --gain 20 --bias");
29 logger->error("As well as --timeout in seconds");
30 logger->error("Sample command :");
31 logger->error("./satdump record baseband_name --source airspy --samplerate 6e6 --frequency 1701.3e6 --general_gain 18 --bias --timeout 780");
32 return 1;
33 }
34
35 // Init SatDump
36 satdump::initSatdump();
37 completeLoggerInit();
38
39 std::string output_file = argv[2];
40
41 // Parse flags
42 nlohmann::json parameters = parse_common_flags(argc - 3, &argv[3], {{"source_id", typeid(std::string)}});
43
44 uint64_t samplerate;
45 uint64_t frequency;
46 uint64_t timeout;
47 std::string handler_id;
48 std::string hdl_dev_id;
49 double decimation = 1;
50
51 try
52 {
53 samplerate = parameters["samplerate"].get<uint64_t>();
54 frequency = parameters["frequency"].get<uint64_t>();
55 timeout = parameters.contains("timeout") ? parameters["timeout"].get<uint64_t>() : 0;
56 handler_id = parameters["source"].get<std::string>();
57 if (parameters.contains("decimation"))
58 decimation = parameters["decimation"].get<int>();
59 if (parameters.contains("source_id"))
60 hdl_dev_id = parameters["source_id"].get<std::string>();
61 }
62 catch (std::exception &e)
63 {
64 logger->error("Error parsing arguments! %s", e.what());
65 return 1;
66 }
67
68 // Create output dir
69 if (std::filesystem::path(output_file).has_parent_path())
70 if (!std::filesystem::exists(std::filesystem::path(output_file).parent_path().string()))
71 std::filesystem::create_directories(std::filesystem::path(output_file).parent_path().string());
72
73 // Get all sources
74 dsp::registerAllSources();
75 std::vector<dsp::SourceDescriptor> source_tr = dsp::getAllAvailableSources();
76 dsp::SourceDescriptor selected_src;
77
78 // Try to find it and check it's usable

Callers 1

mainFunction · 0.85

Calls 15

initSatdumpFunction · 0.85
completeLoggerInitFunction · 0.85
parse_common_flagsFunction · 0.85
pathClass · 0.85
registerAllSourcesFunction · 0.85
getAllAvailableSourcesFunction · 0.85
getSourceFromDescriptorFunction · 0.85
startFunction · 0.85
stopFunction · 0.85
debugMethod · 0.80
c_strMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected