Skip to content

Commit

Permalink
feat(burst_downmix): Make multiple frames per burst optional
Browse files Browse the repository at this point in the history
  • Loading branch information
schneider42 committed Jul 1, 2016
1 parent 28a5956 commit 55a116e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 16 deletions.
7 changes: 6 additions & 1 deletion apps/iridium-extractor
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ if __name__ == "__main__":
'burstsize=',
'uplink',
'downlink',
'decimation'
'decimation',
'multi-frame'
])

center = None
Expand All @@ -118,6 +119,7 @@ if __name__ == "__main__":
burst_size = 20
direction = None
decimation = 1
handle_multiple_frames_per_burst = False

if len(remainder) == 0 or remainder[0] == '-':
filename = "/dev/stdin"
Expand Down Expand Up @@ -168,6 +170,8 @@ if __name__ == "__main__":
# direction = iridium.DOWNLINK
elif opt in ('-D', '--decimation'):
decimation = int(arg)
elif opt == '--multi-frame':
handle_multiple_frames_per_burst = True

if sample_rate == None:
print >> sys.stderr, "Sample rate missing!"
Expand All @@ -190,6 +194,7 @@ if __name__ == "__main__":
filename=filename, sample_format=fmt,
threshold=threshold, signal_width=search_window,
offline=offline, max_queue_len = max_queue_len,
handle_multiple_frames_per_burst=handle_multiple_frames_per_burst,
verbose=verbose)

statistics_thread = threading.Thread(target=print_stats, args=(tb,))
Expand Down
8 changes: 7 additions & 1 deletion grc/iridium_burst_downmix.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<key>iridium_burst_downmix</key>
<category>iridium</category>
<import>import iridium</import>
<make>iridium.burst_downmix($sample_rate, $search_depth, $hard_max_queue_len, $input_taps, $start_finder_taps)</make>
<make>iridium.burst_downmix($sample_rate, $search_depth, $hard_max_queue_len, $input_taps, $start_finder_taps, $handle_multiple_frames_per_burst)</make>

<param>
<name>Sample Rate</name>
Expand Down Expand Up @@ -36,6 +36,12 @@
<type>real_vector</type>
</param>

<param>
<name>Handle Multiple Frames Per Burst</name>
<key>handle_multiple_frames_per_burst</key>
<type>bool</type>
</param>


<sink>
<name>cpdus</name>
Expand Down
3 changes: 2 additions & 1 deletion include/iridium/burst_downmix.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ namespace gr {
* creating new instances.
*/
static sptr make(int sample_rate, int search_depth, size_t hard_max_queue_len,
const std::vector<float> &input_taps, const std::vector<float> &start_finder_taps);
const std::vector<float> &input_taps, const std::vector<float> &start_finder_taps,
bool handle_multiple_frames_per_burst);

virtual uint64_t get_n_dropped_bursts() = 0;
virtual size_t get_input_queue_size() = 0;
Expand Down
28 changes: 19 additions & 9 deletions lib/burst_downmix_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,20 @@ namespace gr {

burst_downmix::sptr
burst_downmix::make(int sample_rate, int search_depth, size_t hard_max_queue_len,
const std::vector<float> &input_taps, const std::vector<float> &start_finder_taps)
const std::vector<float> &input_taps, const std::vector<float> &start_finder_taps,
bool handle_multiple_frames_per_burst)
{
return gnuradio::get_initial_sptr
(new burst_downmix_impl(sample_rate, search_depth, hard_max_queue_len, input_taps, start_finder_taps));
(new burst_downmix_impl(sample_rate, search_depth, hard_max_queue_len, input_taps, start_finder_taps,
handle_multiple_frames_per_burst));
}

/*
* The private constructor
*/
burst_downmix_impl::burst_downmix_impl(int sample_rate, int search_depth, size_t hard_max_queue_len,
const std::vector<float> &input_taps, const std::vector<float> &start_finder_taps)
const std::vector<float> &input_taps, const std::vector<float> &start_finder_taps,
bool handle_multiple_frames_per_burst)
: gr::sync_block("burst_downmix",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(0, 0, 0)),
Expand All @@ -86,6 +89,7 @@ namespace gr {
d_fft_over_size_facor(16),
d_sync_search_len((::iridium::PREAMBLE_LENGTH_LONG + ::iridium::UW_LENGTH + 2) * d_output_samples_per_symbol),
d_hard_max_queue_len(hard_max_queue_len),
d_handle_multiple_frames_per_burst(handle_multiple_frames_per_burst),
d_debug(false),

d_frame(NULL),
Expand Down Expand Up @@ -551,7 +555,7 @@ namespace gr {
}

void burst_downmix_impl::handler(pmt::pmt_t msg)
{
{
/*
* Extract the burst and meta data from the cpdu
*/
Expand Down Expand Up @@ -691,11 +695,17 @@ namespace gr {
write_data_c(d_frame + start, burst_size - start, (char *)"signal-filtered-deci-cut-start", id);
}

int handled_samples;
do {
handled_samples = process_next_frame(sample_rate, center_frequency, offset, id, burst_size, start);
start += handled_samples;
} while(handled_samples > 0);
if(d_handle_multiple_frames_per_burst) {
// Make some room in the id space
uint64_t new_id = id * 10;
int handled_samples;
do {
handled_samples = process_next_frame(sample_rate, center_frequency, offset, new_id++, burst_size, start);
start += handled_samples;
} while(d_handle_multiple_frames_per_burst && handled_samples > 0);
} else {
process_next_frame(sample_rate, center_frequency, offset, id, burst_size, start);
}

message_port_pub(pmt::mp("burst_handled"), pmt::mp(id));
}
Expand Down
4 changes: 3 additions & 1 deletion lib/burst_downmix_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace gr {
int d_sync_search_len;
int d_hard_max_queue_len;
uint64_t d_n_dropped_bursts;
bool d_handle_multiple_frames_per_burst;
bool d_debug;

gr_complex * d_frame;
Expand Down Expand Up @@ -80,7 +81,8 @@ namespace gr {

public:
burst_downmix_impl(int sample_rate, int search_depth, size_t hard_max_queue_len,
const std::vector<float> &input_taps, const std::vector<float> &start_finder_taps);
const std::vector<float> &input_taps, const std::vector<float> &start_finder_taps,
bool handle_multiple_frames_per_burst);
~burst_downmix_impl();

size_t get_input_queue_size();
Expand Down
7 changes: 4 additions & 3 deletions python/iridium_extractor_flowgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


class FlowGraph(gr.top_block):
def __init__(self, center_frequency, sample_rate, decimation, filename, sample_format=None, threshold=7.0, signal_width=40e3, offline=False, max_queue_len=500, verbose=False):
def __init__(self, center_frequency, sample_rate, decimation, filename, sample_format=None, threshold=7.0, signal_width=40e3, offline=False, max_queue_len=500, handle_multiple_frames_per_burst=False, verbose=False):
gr.top_block.__init__(self, "Top Block")
self._center_frequency = center_frequency
self._signal_width = 40e3
Expand All @@ -26,6 +26,7 @@ def __init__(self, center_frequency, sample_rate, decimation, filename, sample_f
self._filename = filename
self._offline = offline
self._max_queue_len = max_queue_len
self._handle_multiple_frames_per_burst = handle_multiple_frames_per_burst

self._fft_size = int(math.pow(2, 1 + int(math.log(self._input_sample_rate / 1000, 2)))) # fft is approx 1ms long
self._burst_pre_len = 2 * self._fft_size
Expand Down Expand Up @@ -211,7 +212,7 @@ def __init__(self, center_frequency, sample_rate, decimation, filename, sample_f
burst_to_pdu_converter = iridium.tagged_burst_to_pdu(self._max_burst_len, relative_center,
relative_span, relative_sample_rate, self._max_queue_len, not self._offline)
burst_downmixer = iridium.burst_downmix(self._burst_sample_rate,
int(0.007 * 250000), 0, (input_filter), (start_finder_filter))
int(0.007 * 250000), 0, (input_filter), (start_finder_filter), self._handle_multiple_frames_per_burst)

self._burst_downmixers.append(burst_downmixer)
self._burst_to_pdu_converters.append(burst_to_pdu_converter)
Expand All @@ -236,7 +237,7 @@ def __init__(self, center_frequency, sample_rate, decimation, filename, sample_f

tb.msg_connect((self._burst_downmixers[i], 'cpdus'), (self._iridium_qpsk_demod, 'cpdus'))
else:
burst_downmix = iridium.burst_downmix(self._burst_sample_rate, int(0.007 * 250000), 0, (input_filter), (start_finder_filter))
burst_downmix = iridium.burst_downmix(self._burst_sample_rate, int(0.007 * 250000), 0, (input_filter), (start_finder_filter), self._handle_multiple_frames_per_burst)
burst_to_pdu = iridium.tagged_burst_to_pdu(self._max_burst_len, 0.0, 1.0, 1.0, self._max_queue_len, not self._offline)

if converter:
Expand Down

0 comments on commit 55a116e

Please sign in to comment.