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

Method process

plugins/cubesat_support/common/module_ax25_decoder.cpp:35–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 }
34
35 void AX25DecoderModule::process()
36 {
37 if (input_data_type == DATA_FILE)
38 filesize = getFilesize(d_input_file);
39 else
40 filesize = 0;
41 if (input_data_type == DATA_FILE)
42 data_in = std::ifstream(d_input_file, std::ios::binary);
43
44 data_out = std::ofstream(d_output_file_hint + ".frm", std::ios::binary);
45 d_output_files.push_back(d_output_file_hint + ".frm");
46
47 std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/";
48
49 logger->info("Using input frames " + d_input_file);
50 logger->info("Decoding to " + d_output_file_hint + ".frm");
51
52 diff::NRZIDiff nrzi_decoder;
53 common::lfsr g3rhu_descramble(0x21, 0x0, 16);
54 HDLCDeframer hdlc_deframer(d_parameters["min_sz"].get<int>(), d_parameters["max_sz"].get<int>());
55
56 uint8_t bits_buf[256];
57
58 time_t lastTime = 0;
59 while (input_data_type == DATA_FILE ? !data_in.eof() : input_active.load())
60 {
61 // Read buffer
62 if (input_data_type == DATA_FILE)
63 data_in.read((char *)input_buffer, 256);
64 else
65 input_fifo->read((uint8_t *)input_buffer, 256);
66
67 // Slice
68 for (int i = 0; i < 256; i++)
69 bits_buf[i] = input_buffer[i] > 0;
70
71 // Optional NRZ-I
72 if (d_nrzi)
73 nrzi_decoder.decode_bits(bits_buf, 256);
74
75 // Optional G3RUH
76 for (int i = 0; i < 256; i++)
77 bits_buf[i] = g3rhu_descramble.next_bit_descramble(bits_buf[i]);
78
79 // Deframe
80 auto frames = hdlc_deframer.work(bits_buf, 256);
81
82 for (auto frm : frames)
83 {
84 std::string source_callsign;
85 for (int i = 0; i < 6; i++)
86 source_callsign += frm[i] >> 1;
87
88 std::string destination_callsign;
89 for (int i = 7; i < 7 + 6; i++)
90 destination_callsign += frm[i] >> 1;
91
92 int source_ssid = frm[6] >> 1;

Callers

nothing calls this directly

Calls 15

getFilesizeFunction · 0.85
to_stringFunction · 0.85
infoMethod · 0.80
eofMethod · 0.80
next_bit_descrambleMethod · 0.80
traceMethod · 0.80
loadMethod · 0.45
readMethod · 0.45
decode_bitsMethod · 0.45
workMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected