Skip to content

Commit

Permalink
tag next frames as NC1
Browse files Browse the repository at this point in the history
  • Loading branch information
schneider42 committed Dec 12, 2024
1 parent 321593d commit ed15f1e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
8 changes: 7 additions & 1 deletion lib/iridium_frame_printer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,19 @@ void iridium_frame_printer_impl::handler(const pmt::pmt_t& msg)
pmt::to_long(pmt::dict_ref(meta, pmt::mp("confidence"), pmt::PMT_NIL));
float level = pmt::to_float(pmt::dict_ref(meta, pmt::mp("level"), pmt::PMT_NIL));
int n_symbols = pmt::to_long(pmt::dict_ref(meta, pmt::mp("n_symbols"), pmt::PMT_NIL));
uint64_t next = pmt::to_uint64(pmt::dict_ref(meta, pmt::mp("next"), pmt::PMT_NIL));

if (d_file_info == "") {
d_t0 = (timestamp / 1000000000ULL) * 1000000000ULL;
d_file_info = "i-" + std::to_string(d_t0 / 1000000000ULL) + "-t1";
}

std::cout << "RAW: " << d_file_info << " ";
if(next)
std::cout << "NC1: ";
else
std::cout << "RAW: ";

std::cout << d_file_info << " ";
std::cout << format("%012.4f ") % ((timestamp - d_t0) / 1000000.);
std::cout << format("%010d ") % int(center_frequency + 0.5);
std::cout << format("N:%05.2f%+06.2f ") % magnitude % noise;
Expand Down
39 changes: 24 additions & 15 deletions lib/iridium_qpsk_demod_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,9 @@ void iridium_qpsk_demod_impl::handler(int channel, pmt::pmt_t msg)
float total_phase =
qpskFirstOrderPLL(d_decimated_burst, n_symbols, d_alpha, d_burst_after_pll);
if(next)
center_frequency += total_phase / (n_symbols / 30000.) / M_PI / 2.;
center_frequency += total_phase / (n_symbols / 30000.) / M_PI / 2.;
else
center_frequency += total_phase / (n_symbols / 25000.) / M_PI / 2.;
center_frequency += total_phase / (n_symbols / 25000.) / M_PI / 2.;
#else
memcpy(d_burst_after_pll, d_decimated_burst, n_symbols * sizeof(gr_complex));
#endif
Expand All @@ -389,22 +389,30 @@ void iridium_qpsk_demod_impl::handler(int channel, pmt::pmt_t msg)
n_symbols = demod_qpsk(
d_burst_after_pll, n_symbols, d_demodulated_burst, &level, &confidence);

bool dl_uw_ok =
check_sync_word(d_demodulated_burst, n_symbols, ::iridium::direction::DOWNLINK);
bool ul_uw_ok =
check_sync_word(d_demodulated_burst, n_symbols, ::iridium::direction::UPLINK);
bool dl_next_uw_ok =
check_sync_word(d_demodulated_burst, n_symbols, ::iridium::direction::DOWNLINK_NEXT);
bool ul_next_uw_ok =
check_sync_word(d_demodulated_burst, n_symbols, ::iridium::direction::UPLINK_NEXT);
d_n_handled_bursts++;

if (!dl_uw_ok && !ul_uw_ok && !dl_next_uw_ok && !ul_next_uw_ok) {
// Drop frames which have no valid sync word
return;
if(next) {
bool dl_next_uw_ok =
check_sync_word(d_demodulated_burst, n_symbols, ::iridium::direction::DOWNLINK_NEXT);
bool ul_next_uw_ok =
check_sync_word(d_demodulated_burst, n_symbols, ::iridium::direction::UPLINK_NEXT);

if (!dl_next_uw_ok && !ul_next_uw_ok) {
return;
}
} else {
bool dl_uw_ok =
check_sync_word(d_demodulated_burst, n_symbols, ::iridium::direction::DOWNLINK);
bool ul_uw_ok =
check_sync_word(d_demodulated_burst, n_symbols, ::iridium::direction::UPLINK);
if (!dl_uw_ok && !ul_uw_ok) {
// Drop frames which have no valid sync word
return;
}
}



// Let's count the number of bursts before
// the burst downmix split them up
uint64_t id = sub_id / 10;
Expand All @@ -430,8 +438,9 @@ void iridium_qpsk_demod_impl::handler(int channel, pmt::pmt_t msg)
pdu_meta = pmt::dict_add(pdu_meta, pmt::mp("noise"), pmt::mp(noise));
pdu_meta = pmt::dict_add(pdu_meta, pmt::mp("magnitude"), pmt::mp(magnitude));
pdu_meta = pmt::dict_add(pdu_meta, pmt::mp("n_symbols"), pmt::mp((int)n_symbols));
pdu_meta =
pmt::dict_add(pdu_meta, pmt::mp("direction"), pmt::mp((int)(ul_uw_ok ? 1 : 0)));
pdu_meta = pmt::dict_add(pdu_meta, pmt::mp("next"), pmt::mp(next));
//pdu_meta =
// pmt::dict_add(pdu_meta, pmt::mp("direction"), pmt::mp((int)(ul_uw_ok ? 1 : 0)));

pmt::pmt_t out_msg = pmt::cons(pdu_meta, pdu_vector);
message_port_pub(pmt::mp("pdus"), out_msg);
Expand Down

0 comments on commit ed15f1e

Please sign in to comment.