Add LRPT decoder
Currently it performs only convolutional decoding
This commit is contained in:
parent
dcadfe9ab1
commit
854becb15d
|
@ -36,6 +36,7 @@ list(APPEND enabled_blocks
|
||||||
satnogs_fox_telem_mm.xml
|
satnogs_fox_telem_mm.xml
|
||||||
satnogs_frame_file_sink.xml
|
satnogs_frame_file_sink.xml
|
||||||
satnogs_iq_sink.xml
|
satnogs_iq_sink.xml
|
||||||
|
satnogs_lrpt_decoder.xml
|
||||||
satnogs_lrpt_sync.xml
|
satnogs_lrpt_sync.xml
|
||||||
satnogs_morse_decoder.xml
|
satnogs_morse_decoder.xml
|
||||||
satnogs_multi_format_msg_sink.xml
|
satnogs_multi_format_msg_sink.xml
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?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>
|
|
@ -21,10 +21,4 @@
|
||||||
<name>cadu</name>
|
<name>cadu</name>
|
||||||
<type>message</type>
|
<type>message</type>
|
||||||
</source>
|
</source>
|
||||||
|
|
||||||
<source>
|
|
||||||
<name>reset</name>
|
|
||||||
<type>message</type>
|
|
||||||
</source>
|
|
||||||
|
|
||||||
</block>
|
</block>
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
|
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/>
|
* Copyright (C) 2016,2018 Libre Space Foundation <http://librespacefoundation.org/>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -21,12 +21,14 @@
|
||||||
#ifndef INCLUDE_SATNOGS_UTILS_H_
|
#ifndef INCLUDE_SATNOGS_UTILS_H_
|
||||||
#define INCLUDE_SATNOGS_UTILS_H_
|
#define INCLUDE_SATNOGS_UTILS_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
namespace gr
|
namespace gr
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace satnogs
|
namespace satnogs
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the Mean Absolute Percentage Error
|
* Computes the Mean Absolute Percentage Error
|
||||||
* @param ref the reference value
|
* @param ref the reference value
|
||||||
|
@ -201,6 +203,15 @@ namespace gr
|
||||||
| (_bytes_reversed[(i >> 24) & 0xff]);
|
| (_bytes_reversed[(i >> 24) & 0xff]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint64_t
|
||||||
|
reverse_uint64_bytes (uint64_t x)
|
||||||
|
{
|
||||||
|
x = (x & 0x00000000FFFFFFFF) << 32 | (x & 0xFFFFFFFF00000000) >> 32;
|
||||||
|
x = (x & 0x0000FFFF0000FFFF) << 16 | (x & 0xFFFF0000FFFF0000) >> 16;
|
||||||
|
x = (x & 0x00FF00FF00FF00FF) << 8 | (x & 0xFF00FF00FF00FF00) >> 8;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace satnogs
|
} // namespace satnogs
|
||||||
|
|
||||||
} // namespace gr
|
} // namespace gr
|
||||||
|
|
|
@ -25,7 +25,9 @@
|
||||||
#include <gnuradio/io_signature.h>
|
#include <gnuradio/io_signature.h>
|
||||||
#include "lrpt_decoder_impl.h"
|
#include "lrpt_decoder_impl.h"
|
||||||
#include <satnogs/log.h>
|
#include <satnogs/log.h>
|
||||||
|
extern "C" {
|
||||||
#include <fec.h>
|
#include <fec.h>
|
||||||
|
}
|
||||||
|
|
||||||
namespace gr
|
namespace gr
|
||||||
{
|
{
|
||||||
|
@ -45,22 +47,18 @@ lrpt_decoder_impl::lrpt_decoder_impl()
|
||||||
: gr::block("lrpt_decoder",
|
: gr::block("lrpt_decoder",
|
||||||
gr::io_signature::make(0, 0, 0),
|
gr::io_signature::make(0, 0, 0),
|
||||||
gr::io_signature::make(0, 0, 0)),
|
gr::io_signature::make(0, 0, 0)),
|
||||||
d_cadu_len(1020),
|
d_cadu_len(1020 + 4),
|
||||||
d_coded_cadu_len(1020 * 2),
|
d_coded_cadu_len(1020 * 2 + 4*2),
|
||||||
d_conv_deinterl(36, 2048)
|
d_conv_deinterl(36, 2048)
|
||||||
{
|
{
|
||||||
|
|
||||||
message_port_register_in(pmt::mp("cadu"));
|
message_port_register_in(pmt::mp("cadu"));
|
||||||
message_port_register_in(pmt::mp("reset"));
|
message_port_register_out(pmt::mp("frame"));
|
||||||
|
|
||||||
set_msg_handler (
|
set_msg_handler (
|
||||||
pmt::mp ("cadu"),
|
pmt::mp ("cadu"),
|
||||||
boost::bind (&lrpt_decoder_impl::decode, this, _1));
|
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);
|
d_vt = create_viterbi27(d_cadu_len * 8);
|
||||||
if(!d_vt) {
|
if(!d_vt) {
|
||||||
throw std::runtime_error("lrpt_decoder: Failed to init Viterbi decoder");
|
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);
|
set_viterbi27_polynomial(polys);
|
||||||
|
|
||||||
d_cadu = new uint8_t[d_cadu_len];
|
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_cadu;
|
||||||
delete [] d_coded_cadu_deinterl;
|
delete [] d_coded_cadu_syms;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -92,20 +90,23 @@ lrpt_decoder_impl::decode (pmt::pmt_t m)
|
||||||
return;
|
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);
|
init_viterbi27(d_vt, 0);
|
||||||
|
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
lrpt_decoder_impl::reset (pmt::pmt_t m)
|
|
||||||
{
|
|
||||||
if(pmt::to_bool(m)) {
|
|
||||||
d_conv_deinterl.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} /* namespace satnogs */
|
} /* namespace satnogs */
|
||||||
|
|
|
@ -40,15 +40,12 @@ private:
|
||||||
const size_t d_cadu_len;
|
const size_t d_cadu_len;
|
||||||
const size_t d_coded_cadu_len;
|
const size_t d_coded_cadu_len;
|
||||||
convolutional_deinterleaver d_conv_deinterl;
|
convolutional_deinterleaver d_conv_deinterl;
|
||||||
uint8_t *d_coded_cadu_deinterl;
|
uint8_t *d_coded_cadu_syms;
|
||||||
uint8_t *d_cadu;
|
uint8_t *d_cadu;
|
||||||
void *d_vt;
|
void *d_vt;
|
||||||
|
|
||||||
void
|
void
|
||||||
decode(pmt::pmt_t m);
|
decode(pmt::pmt_t m);
|
||||||
|
|
||||||
void
|
|
||||||
reset(pmt::pmt_t m);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace satnogs
|
} // namespace satnogs
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <gnuradio/io_signature.h>
|
#include <gnuradio/io_signature.h>
|
||||||
#include "lrpt_sync_impl.h"
|
#include "lrpt_sync_impl.h"
|
||||||
#include <satnogs/log.h>
|
#include <satnogs/log.h>
|
||||||
|
#include <satnogs/utils.h>
|
||||||
|
|
||||||
#include <volk/volk.h>
|
#include <volk/volk.h>
|
||||||
#include <gnuradio/blocks/count_bits.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),
|
d_window((72 + 8)/2),
|
||||||
/* Each CADU has the 4 byte ASM and a VCDU of 1020 bytes*/
|
/* 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_frame_sync(false),
|
||||||
d_received(0),
|
d_received(0),
|
||||||
d_rotate(1, 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");
|
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];
|
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("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)) {
|
if(found_sync(d_shift_reg0)) {
|
||||||
d_rotate = gr_complex(1.0, 0);
|
d_rotate = gr_complex(1.0, 0);
|
||||||
d_frame_sync = true;
|
d_frame_sync = true;
|
||||||
LOG_ERROR("SYNC");
|
|
||||||
return i * d_window + j;
|
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)) {
|
if(found_sync(d_shift_reg1)) {
|
||||||
d_rotate = gr_complex(0.0, 1.0);
|
d_rotate = gr_complex(0.0, 1.0);
|
||||||
d_frame_sync = true;
|
d_frame_sync = true;
|
||||||
LOG_ERROR("SYNC");
|
|
||||||
return i * d_window + j;
|
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)) {
|
if(found_sync(d_shift_reg2)) {
|
||||||
d_rotate = gr_complex(-1.0, 0);
|
d_rotate = gr_complex(-1.0, 0);
|
||||||
d_frame_sync = true;
|
d_frame_sync = true;
|
||||||
LOG_ERROR("SYNC");
|
|
||||||
return i * d_window + j;
|
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)) {
|
if(found_sync(d_shift_reg3)) {
|
||||||
d_rotate = gr_complex(0.0, -1.0);
|
d_rotate = gr_complex(0.0, -1.0);
|
||||||
d_frame_sync = true;
|
d_frame_sync = true;
|
||||||
LOG_ERROR("SYNC");
|
|
||||||
return i * d_window + j;
|
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++) {
|
for(int i = 0; i < multiple; i++) {
|
||||||
volk_32fc_s32fc_multiply_32fc(d_corrected, in + i * d_window,
|
volk_32fc_s32fc_multiply_32fc(d_corrected, in + i * d_window,
|
||||||
d_rotate, d_window);
|
d_rotate, d_window);
|
||||||
/*
|
for(int j = 0; j < d_window; j += 4) {
|
||||||
* Skip UW, for now
|
|
||||||
* NOTE: UW is unencoded
|
|
||||||
*/
|
|
||||||
for(int j = 0; j < d_window - 4; j += 4) {
|
|
||||||
b = 0;
|
b = 0;
|
||||||
b = d_qpsk->decision_maker(d_corrected + j) << 6;
|
b = d_qpsk->decision_maker(d_corrected + j) << 6;
|
||||||
b |= d_qpsk->decision_maker(d_corrected + j + 1) << 4;
|
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;
|
d_coded_cadu[d_received++] = b;
|
||||||
if(d_received == d_coded_cadu_len) {
|
if(d_received == d_coded_cadu_len) {
|
||||||
LOG_ERROR("frame");
|
LOG_ERROR("frame");
|
||||||
d_received = 0;
|
d_received = sizeof(uint64_t);
|
||||||
d_frame_sync = false;
|
d_frame_sync = false;
|
||||||
message_port_pub (pmt::mp ("cadu"),
|
message_port_pub (pmt::mp ("cadu"),
|
||||||
pmt::make_blob (d_coded_cadu, d_coded_cadu_len));
|
pmt::make_blob (d_coded_cadu, d_coded_cadu_len));
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "satnogs/decoder_8b10b.h"
|
#include "satnogs/decoder_8b10b.h"
|
||||||
#include "satnogs/ccsds_rs_decoder_mm.h"
|
#include "satnogs/ccsds_rs_decoder_mm.h"
|
||||||
#include "satnogs/fox_telem_mm.h"
|
#include "satnogs/fox_telem_mm.h"
|
||||||
|
#include "satnogs/lrpt_decoder.h"
|
||||||
#include "satnogs/lrpt_sync.h"
|
#include "satnogs/lrpt_sync.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
@ -117,3 +118,6 @@ GR_SWIG_BLOCK_MAGIC2(satnogs, fox_telem_mm);
|
||||||
|
|
||||||
%include "satnogs/lrpt_sync.h"
|
%include "satnogs/lrpt_sync.h"
|
||||||
GR_SWIG_BLOCK_MAGIC2(satnogs, lrpt_sync);
|
GR_SWIG_BLOCK_MAGIC2(satnogs, lrpt_sync);
|
||||||
|
|
||||||
|
%include "satnogs/lrpt_decoder.h"
|
||||||
|
GR_SWIG_BLOCK_MAGIC2(satnogs, lrpt_decoder);
|
||||||
|
|
Loading…
Reference in New Issue