Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5da4723
commit 04b243c
Showing
9 changed files
with
616 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0"?> | ||
<block> | ||
<name>CCSDS Reed-Solomon Encoder</name> | ||
<key>satellites_encode_rs</key> | ||
<category>[Satellites]/FEC</category> | ||
<import>import satellites</import> | ||
<make>satellites.encode_rs($basis)</make> | ||
|
||
<param> | ||
<name>Basis</name> | ||
<key>basis</key> | ||
<type>int</type> | ||
<option> | ||
<name>Conventional</name> | ||
<key>0</key> | ||
</option> | ||
<option> | ||
<name>Dual</name> | ||
<key>1</key> | ||
</option> | ||
</param> | ||
|
||
<sink> | ||
<name>in</name> | ||
<type>message</type> | ||
</sink> | ||
|
||
<source> | ||
<name>out</name> | ||
<type>message</type> | ||
</source> | ||
</block> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
install(FILES | ||
api.h | ||
decode_rs.h | ||
encode_rs.h | ||
ao40_syncframe.h | ||
ao40_deinterleaver.h | ||
ao40_rs_decoder.h | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* -*- c++ -*- */ | ||
/* | ||
* Copyright 2018 Daniel Estevez <daniel@destevez.net>. | ||
* | ||
* This is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3, or (at your option) | ||
* any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this software; see the file COPYING. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifndef INCLUDED_SATELLITES_ENCODE_RS_H | ||
#define INCLUDED_SATELLITES_ENCODE_RS_H | ||
|
||
#include <satellites/api.h> | ||
#include <gnuradio/block.h> | ||
|
||
namespace gr { | ||
namespace satellites { | ||
|
||
/*! | ||
* \brief <+description of block+> | ||
* \ingroup satellites | ||
* | ||
*/ | ||
class SATELLITES_API encode_rs : virtual public gr::block | ||
{ | ||
public: | ||
typedef boost::shared_ptr<encode_rs> sptr; | ||
|
||
/*! | ||
* \brief Return a shared_ptr to a new instance of satellites::encode_rs. | ||
* | ||
* To avoid accidental use of raw pointers, satellites::encode_rs's | ||
* constructor is in a private implementation | ||
* class. satellites::encode_rs::make is the public interface for | ||
* creating new instances. | ||
*/ | ||
static sptr make(int basis); | ||
}; | ||
|
||
} // namespace satellites | ||
} // namespace gr | ||
|
||
#endif /* INCLUDED_SATELLITES_ENCODE_RS_H */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* -*- c++ -*- */ | ||
/* | ||
* Copyright 2018 Daniel Estevez <daniel@destevez.net>. | ||
* | ||
* This is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3, or (at your option) | ||
* any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this software; see the file COPYING. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif | ||
|
||
#include <gnuradio/io_signature.h> | ||
#include "encode_rs_impl.h" | ||
|
||
#include <cstdio> | ||
|
||
extern "C" { | ||
#include <fec.h> | ||
} | ||
|
||
#define MAX_FRAME_LEN 255 | ||
#define PARITY_BYTES 32 | ||
|
||
#define BASIS_CONVENTIONAL 0 | ||
#define BASIS_DUAL 1 | ||
|
||
namespace gr { | ||
namespace satellites { | ||
|
||
encode_rs::sptr | ||
encode_rs::make(int basis) | ||
{ | ||
return gnuradio::get_initial_sptr | ||
(new encode_rs_impl(basis)); | ||
} | ||
|
||
/* | ||
* The private constructor | ||
*/ | ||
encode_rs_impl::encode_rs_impl(int basis) | ||
: gr::block("encode_rs", | ||
gr::io_signature::make(0, 0, 0), | ||
gr::io_signature::make(0, 0, 0)) | ||
{ | ||
d_basis = basis; | ||
|
||
message_port_register_out(pmt::mp("out")); | ||
message_port_register_in(pmt::mp("in")); | ||
set_msg_handler(pmt::mp("in"), | ||
boost::bind(&encode_rs_impl::msg_handler, this, _1)); | ||
} | ||
|
||
/* | ||
* Our virtual destructor. | ||
*/ | ||
encode_rs_impl::~encode_rs_impl() | ||
{ | ||
} | ||
|
||
void | ||
encode_rs_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required) | ||
{ | ||
} | ||
|
||
int | ||
encode_rs_impl::general_work (int noutput_items, | ||
gr_vector_int &ninput_items, | ||
gr_vector_const_void_star &input_items, | ||
gr_vector_void_star &output_items) | ||
{ | ||
return 0; | ||
} | ||
|
||
void | ||
encode_rs_impl::msg_handler (pmt::pmt_t pmt_msg) { | ||
pmt::pmt_t msg = pmt::cdr(pmt_msg); | ||
uint8_t data[MAX_FRAME_LEN]; | ||
int frame_len = pmt::length(msg); | ||
size_t offset(0); | ||
|
||
assert(frame_len <= MAX_FRAME_LEN - PARITY_BYTES); | ||
|
||
memcpy(data, pmt::uniform_vector_elements(msg, offset), frame_len); | ||
|
||
if (d_basis == BASIS_CONVENTIONAL) { | ||
encode_rs_8(data, data + frame_len, MAX_FRAME_LEN - frame_len - PARITY_BYTES); | ||
} | ||
else { | ||
encode_rs_ccsds(data, data + frame_len, MAX_FRAME_LEN - frame_len - PARITY_BYTES); | ||
} | ||
|
||
// Send by GNUradio message | ||
message_port_pub(pmt::mp("out"), | ||
pmt::cons(pmt::PMT_NIL, | ||
pmt::init_u8vector(frame_len + PARITY_BYTES, data))); | ||
} | ||
} /* namespace satellites */ | ||
} /* namespace gr */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* -*- c++ -*- */ | ||
/* | ||
* Copyright 2018 Daniel Estevez <daniel@destevez.net>. | ||
* | ||
* This is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3, or (at your option) | ||
* any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this software; see the file COPYING. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifndef INCLUDED_SATELLITES_ENCODE_RS_IMPL_H | ||
#define INCLUDED_SATELLITES_ENCODE_RS_IMPL_H | ||
|
||
#include <satellites/encode_rs.h> | ||
|
||
namespace gr { | ||
namespace satellites { | ||
|
||
class encode_rs_impl : public encode_rs | ||
{ | ||
private: | ||
int d_basis; | ||
|
||
public: | ||
encode_rs_impl(int basis); | ||
~encode_rs_impl(); | ||
|
||
// Where all the action really happens | ||
void forecast (int noutput_items, gr_vector_int &ninput_items_required); | ||
|
||
int general_work(int noutput_items, | ||
gr_vector_int &ninput_items, | ||
gr_vector_const_void_star &input_items, | ||
gr_vector_void_star &output_items); | ||
|
||
void msg_handler(pmt::pmt_t pmt_msg); | ||
}; | ||
|
||
} // namespace satellites | ||
} // namespace gr | ||
|
||
#endif /* INCLUDED_SATELLITES_ENCODE_RS_IMPL_H */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.