Commit 854becb1 authored by Manolis Surligas's avatar Manolis Surligas

Add LRPT decoder

Currently it performs only convolutional decoding
parent dcadfe9a
......@@ -36,6 +36,7 @@ list(APPEND enabled_blocks
satnogs_fox_telem_mm.xml
satnogs_frame_file_sink.xml
satnogs_iq_sink.xml
satnogs_lrpt_decoder.xml
satnogs_lrpt_sync.xml
satnogs_morse_decoder.xml
satnogs_multi_format_msg_sink.xml
......
<?xml version="1.0"?>
<block>
<name>LRPT Frame Decoder</name>
<key>satnogs_lrpt_decoder</key>
<import>import satnogs</import>
<make>satnogs.lrpt_decoder()</make>
<sink>
<name>cadu</name>
<type>message</type>
</sink>
<source>
<name>frame</name>
<type>message</type>
</source>
</block>
\ No newline at end of file
......@@ -21,10 +21,4 @@
<name>cadu</name>
<type>message</type>
</source>
<source>
<name>reset</name>
<type>message</type>
</source>
</block>
\ No newline at end of file
This diff is collapsed.
......@@ -25,7 +25,9 @@
#include <gnuradio/io_signature.h>
#include "lrpt_decoder_impl.h"
#include <satnogs/log.h>
#include <fec.h>
extern "C" {
#include <fec.h>
}
namespace gr
{
......@@ -45,22 +47,18 @@ lrpt_decoder_impl::lrpt_decoder_impl()
: gr::block("lrpt_decoder",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(0, 0, 0)),
d_cadu_len(1020),
d_coded_cadu_len(1020 * 2),
d_cadu_len(1020 + 4),
d_coded_cadu_len(1020 * 2 + 4*2),
d_conv_deinterl(36, 2048)
{
message_port_register_in(pmt::mp("cadu"));
message_port_register_in(pmt::mp("reset"));
message_port_register_out(pmt::mp("frame"));
set_msg_handler (
pmt::mp ("cadu"),
boost::bind (&lrpt_decoder_impl::decode, this, _1));
set_msg_handler (
pmt::mp ("reset"),
boost::bind (&lrpt_decoder_impl::reset, this, _1));
d_vt = create_viterbi27(d_cadu_len * 8);
if(!d_vt) {
throw std::runtime_error("lrpt_decoder: Failed to init Viterbi decoder");
......@@ -69,7 +67,7 @@ lrpt_decoder_impl::lrpt_decoder_impl()
set_viterbi27_polynomial(polys);
d_cadu = new uint8_t[d_cadu_len];
d_coded_cadu_deinterl = new uint8_t[d_coded_cadu_len];
d_coded_cadu_syms = new uint8_t[d_coded_cadu_len * 8];
}
......@@ -80,7 +78,7 @@ lrpt_decoder_impl::~lrpt_decoder_impl ()
{
delete [] d_cadu;
delete [] d_coded_cadu_deinterl;
delete [] d_coded_cadu_syms;
}
void
......@@ -92,22 +90,25 @@ lrpt_decoder_impl::decode (pmt::pmt_t m)
return;
}
for(size_t i = 0; i < d_coded_cadu_len; i++) {
d_coded_cadu_deinterl[i] = d_conv_deinterl.decode_byte(coded_cadu[i]);
}
init_viterbi27(d_vt, 0);
}
void
lrpt_decoder_impl::reset (pmt::pmt_t m)
{
if(pmt::to_bool(m)) {
d_conv_deinterl.reset();
for(size_t i = 0; i < d_coded_cadu_len; i++) {
d_coded_cadu_syms[i * 8] = ~(255 + (coded_cadu[i] >> 7));
d_coded_cadu_syms[i * 8 + 1] = ~(255 + (coded_cadu[i] >> 6) & 0x1);
d_coded_cadu_syms[i * 8 + 2] = ~(255 + (coded_cadu[i] >> 5) & 0x1);
d_coded_cadu_syms[i * 8 + 3] = ~(255 + (coded_cadu[i] >> 4) & 0x1);
d_coded_cadu_syms[i * 8 + 4] = ~(255 + (coded_cadu[i] >> 3) & 0x1);
d_coded_cadu_syms[i * 8 + 5] = ~(255 + (coded_cadu[i] >> 2) & 0x1);
d_coded_cadu_syms[i * 8 + 6] = ~(255 + (coded_cadu[i] >> 1) & 0x1);
d_coded_cadu_syms[i * 8 + 7] = ~(255 + (coded_cadu[i] & 0x1));
}
update_viterbi27_blk(d_vt, d_coded_cadu_syms, d_cadu_len * 8);
chainback_viterbi27(d_vt, d_cadu, d_cadu_len * 8, 0);
message_port_pub(pmt::mp("frame"), pmt::make_blob(d_cadu, d_cadu_len));
}
} /* namespace satnogs */
} /* namespace gr */
......@@ -40,15 +40,12 @@ private:
const size_t d_cadu_len;
const size_t d_coded_cadu_len;
convolutional_deinterleaver d_conv_deinterl;
uint8_t *d_coded_cadu_deinterl;
uint8_t *d_coded_cadu_syms;
uint8_t *d_cadu;
void *d_vt;
void
decode(pmt::pmt_t m);
void
reset(pmt::pmt_t m);
};
} // namespace satnogs
......
......@@ -25,6 +25,7 @@
#include <gnuradio/io_signature.h>
#include "lrpt_sync_impl.h"
#include <satnogs/log.h>
#include <satnogs/utils.h>
#include <volk/volk.h>
#include <gnuradio/blocks/count_bits.h>
......@@ -57,7 +58,7 @@ lrpt_sync_impl::lrpt_sync_impl (size_t threshold) :
*/
d_window((72 + 8)/2),
/* Each CADU has the 4 byte ASM and a VCDU of 1020 bytes*/
d_coded_cadu_len(1020 * 2),
d_coded_cadu_len(1020 * 2 + 4*2),
d_frame_sync(false),
d_received(0),
d_rotate(1, 0),
......@@ -97,10 +98,12 @@ lrpt_sync_impl::lrpt_sync_impl (size_t threshold) :
throw std::runtime_error("lrpt_sync: Could not allocate memory");
}
uint64_t asm_coded = reverse_uint64_bytes(d_asm_coded);
d_coded_cadu = new uint8_t[d_coded_cadu_len];
memcpy(d_coded_cadu, &asm_coded, sizeof(uint64_t));
d_received = sizeof(uint64_t);
message_port_register_out(pmt::mp("cadu"));
message_port_register_out(pmt::mp("reset"));
}
/*
......@@ -146,7 +149,6 @@ lrpt_sync_impl::work_no_sync(const gr_complex *in, int noutput_items)
if(found_sync(d_shift_reg0)) {
d_rotate = gr_complex(1.0, 0);
d_frame_sync = true;
LOG_ERROR("SYNC");
return i * d_window + j;
}
......@@ -156,7 +158,6 @@ lrpt_sync_impl::work_no_sync(const gr_complex *in, int noutput_items)
if(found_sync(d_shift_reg1)) {
d_rotate = gr_complex(0.0, 1.0);
d_frame_sync = true;
LOG_ERROR("SYNC");
return i * d_window + j;
}
......@@ -166,7 +167,6 @@ lrpt_sync_impl::work_no_sync(const gr_complex *in, int noutput_items)
if(found_sync(d_shift_reg2)) {
d_rotate = gr_complex(-1.0, 0);
d_frame_sync = true;
LOG_ERROR("SYNC");
return i * d_window + j;
}
......@@ -176,7 +176,6 @@ lrpt_sync_impl::work_no_sync(const gr_complex *in, int noutput_items)
if(found_sync(d_shift_reg3)) {
d_rotate = gr_complex(0.0, -1.0);
d_frame_sync = true;
LOG_ERROR("SYNC");
return i * d_window + j;
}
}
......@@ -192,11 +191,7 @@ lrpt_sync_impl::work_sync(const gr_complex *in, int noutput_items)
for(int i = 0; i < multiple; i++) {
volk_32fc_s32fc_multiply_32fc(d_corrected, in + i * d_window,
d_rotate, d_window);
/*
* Skip UW, for now
* NOTE: UW is unencoded
*/
for(int j = 0; j < d_window - 4; j += 4) {
for(int j = 0; j < d_window; j += 4) {
b = 0;
b = d_qpsk->decision_maker(d_corrected + j) << 6;
b |= d_qpsk->decision_maker(d_corrected + j + 1) << 4;
......@@ -206,7 +201,7 @@ lrpt_sync_impl::work_sync(const gr_complex *in, int noutput_items)
d_coded_cadu[d_received++] = b;
if(d_received == d_coded_cadu_len) {
LOG_ERROR("frame");
d_received = 0;
d_received = sizeof(uint64_t);
d_frame_sync = false;
message_port_pub (pmt::mp ("cadu"),
pmt::make_blob (d_coded_cadu, d_coded_cadu_len));
......
......@@ -35,6 +35,7 @@
#include "satnogs/decoder_8b10b.h"
#include "satnogs/ccsds_rs_decoder_mm.h"
#include "satnogs/fox_telem_mm.h"
#include "satnogs/lrpt_decoder.h"
#include "satnogs/lrpt_sync.h"
%}
......@@ -117,3 +118,6 @@ GR_SWIG_BLOCK_MAGIC2(satnogs, fox_telem_mm);
%include "satnogs/lrpt_sync.h"
GR_SWIG_BLOCK_MAGIC2(satnogs, lrpt_sync);
%include "satnogs/lrpt_decoder.h"
GR_SWIG_BLOCK_MAGIC2(satnogs, lrpt_decoder);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment