Implement the UPSAT FSK encoder block.
Fix also a small bug at the UPSAT FSK decoder block.
This commit is contained in:
parent
4b3b08f200
commit
228fd37014
|
@ -32,5 +32,6 @@ install(FILES
|
|||
satnogs_tcp_rigctl_msg_source.xml
|
||||
satnogs_frame_encoder.xml
|
||||
satnogs_doppler_correction_cc.xml
|
||||
satnogs_upsat_fsk_frame_acquisition.xml DESTINATION share/gnuradio/grc/blocks
|
||||
satnogs_upsat_fsk_frame_acquisition.xml
|
||||
satnogs_upsat_fsk_frame_encoder.xml DESTINATION share/gnuradio/grc/blocks
|
||||
)
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
<?xml version="1.0"?>
|
||||
<block>
|
||||
<name>UPSAT FSK Frame Acquisition</name>
|
||||
<key>satnogs_upsat_fsk_frame_acquisition</key>
|
||||
<category>satnogs</category>
|
||||
<import>import satnogs</import>
|
||||
<make>satnogs.upsat_fsk_frame_acquisition($preamble, $sync_word, $whitening, $manchester)</make>
|
||||
<name>UPSAT FSK Frame Acquisition</name>
|
||||
<key>satnogs_upsat_fsk_frame_acquisition</key>
|
||||
<category>satnogs</category>
|
||||
<import>import satnogs</import>
|
||||
<make>satnogs.upsat_fsk_frame_acquisition($preamble, $sync_word, $whitening, $manchester)</make>
|
||||
|
||||
<param>
|
||||
<name>Frame Preamble</name>
|
||||
<key>preamble</key>
|
||||
<type>raw</type>
|
||||
</param>
|
||||
<param>
|
||||
<name>Frame Preamble</name>
|
||||
<key>preamble</key>
|
||||
<type>raw</type>
|
||||
</param>
|
||||
|
||||
<param>
|
||||
<name>Synchronization Word</name>
|
||||
<key>sync_word</key>
|
||||
<type>raw</type>
|
||||
</param>
|
||||
|
||||
<param>
|
||||
<name>Synchronization Word</name>
|
||||
<key>sync_word</key>
|
||||
<type>raw</type>
|
||||
</param>
|
||||
|
||||
<param>
|
||||
<name>Whitening</name>
|
||||
<key>whitening</key>
|
||||
|
@ -46,13 +46,13 @@
|
|||
</option>
|
||||
</param>
|
||||
|
||||
<sink>
|
||||
<name>in</name>
|
||||
<type>float</type>
|
||||
</sink>
|
||||
<sink>
|
||||
<name>in</name>
|
||||
<type>float</type>
|
||||
</sink>
|
||||
|
||||
<source>
|
||||
<name>pdu</name>
|
||||
<type>message</type>
|
||||
</source>
|
||||
<source>
|
||||
<name>pdu</name>
|
||||
<type>message</type>
|
||||
</source>
|
||||
</block>
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0"?>
|
||||
<block>
|
||||
<name>UPSAT FSK Frame Encoder</name>
|
||||
<key>satnogs_upsat_fsk_frame_encoder</key>
|
||||
<category>satnogs</category>
|
||||
<import>import satnogs</import>
|
||||
<make>satnogs.upsat_fsk_frame_encoder($preamble, $sync_word, $append_crc, $whitening, $manchester)</make>
|
||||
|
||||
<param>
|
||||
<name>Frame Preamble</name>
|
||||
<key>preamble</key>
|
||||
<type>raw</type>
|
||||
</param>
|
||||
|
||||
<param>
|
||||
<name>Synchronization Word</name>
|
||||
<key>sync_word</key>
|
||||
<type>raw</type>
|
||||
</param>
|
||||
|
||||
<param>
|
||||
<name>Append CRC</name>
|
||||
<key>append_crc</key>
|
||||
<type>enum</type>
|
||||
<option>
|
||||
<name>Yes</name>
|
||||
<key>True</key>
|
||||
</option>
|
||||
<option>
|
||||
<name>No</name>
|
||||
<key>False</key>
|
||||
</option>
|
||||
</param>
|
||||
|
||||
<param>
|
||||
<name>Whitening</name>
|
||||
<key>whitening</key>
|
||||
<type>enum</type>
|
||||
<option>
|
||||
<name>No</name>
|
||||
<key>False</key>
|
||||
</option>
|
||||
<option>
|
||||
<name>Yes</name>
|
||||
<key>True</key>
|
||||
</option>
|
||||
</param>
|
||||
|
||||
<param>
|
||||
<name>Use Manchester Coding</name>
|
||||
<key>manchester</key>
|
||||
<type>enum</type>
|
||||
<option>
|
||||
<name>No</name>
|
||||
<key>False</key>
|
||||
</option>
|
||||
<option>
|
||||
<name>Yes</name>
|
||||
<key>True</key>
|
||||
</option>
|
||||
</param>
|
||||
|
||||
<sink>
|
||||
<name>pdu</name>
|
||||
<type>message</type>
|
||||
</sink>
|
||||
|
||||
<source>
|
||||
<name>out</name>
|
||||
<type>float</type>
|
||||
</source>
|
||||
</block>
|
|
@ -45,5 +45,6 @@ install(FILES
|
|||
doppler_correction_cc.h
|
||||
doppler_fit.h
|
||||
freq_drift.h
|
||||
upsat_fsk_frame_acquisition.h DESTINATION include/satnogs
|
||||
upsat_fsk_frame_acquisition.h
|
||||
upsat_fsk_frame_encoder.h DESTINATION include/satnogs
|
||||
)
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
|
||||
*
|
||||
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_SATNOGS_UPSAT_FSK_FRAME_ENCODER_H
|
||||
#define INCLUDED_SATNOGS_UPSAT_FSK_FRAME_ENCODER_H
|
||||
|
||||
#include <satnogs/api.h>
|
||||
#include <gnuradio/sync_block.h>
|
||||
|
||||
namespace gr
|
||||
{
|
||||
namespace satnogs
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief This block implements a FSK frame encoder for the UPSAT satellite.
|
||||
* It takes as input a message containing the PDU and performs the NRZ
|
||||
* encoding. The resulting float samples can be passed from a FM modulation
|
||||
* block and then to the SDR device.
|
||||
*
|
||||
* \ingroup satnogs
|
||||
*
|
||||
*/
|
||||
class SATNOGS_API upsat_fsk_frame_encoder : virtual public gr::sync_block
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<upsat_fsk_frame_encoder> sptr;
|
||||
|
||||
/*!
|
||||
* Creates an FSK encoding block. Note that this block does NOT perform
|
||||
* the frequency modulation. You can use the existing frequency modulation
|
||||
* block shipped with the GNU Radio.
|
||||
*
|
||||
* @param preamble the bytes that consist the preamble of the frame
|
||||
*
|
||||
* @param sync_word the byte synchronization word
|
||||
*
|
||||
* @param append_crc if set to true the encoder will append a two byte
|
||||
* CRC field at the end of the frame. The CRC algorithm is compatible
|
||||
* with the CC1120 chip.
|
||||
*
|
||||
* @param whitening true if the transmitted data have been processed by
|
||||
* the whitening algorithm of the CC1120 chip. False otherwise.
|
||||
*
|
||||
* @param manchester true if the transmitted data have been processed by
|
||||
* the Manchester algorithm of the CC1120 chip. False otherwise.
|
||||
*/
|
||||
static sptr
|
||||
make (const std::vector<uint8_t>& preamble,
|
||||
const std::vector<uint8_t>& sync_word, bool append_crc = true,
|
||||
bool whitening = false, bool manchester = false);
|
||||
};
|
||||
|
||||
} // namespace satnogs
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_SATNOGS_UPSAT_FSK_FRAME_ENCODER_H */
|
||||
|
|
@ -43,7 +43,8 @@ list(APPEND satnogs_sources
|
|||
frame_encoder_impl.cc
|
||||
doppler_fit.cc
|
||||
freq_drift.cc
|
||||
upsat_fsk_frame_acquisition_impl.cc )
|
||||
upsat_fsk_frame_acquisition_impl.cc
|
||||
upsat_fsk_frame_encoder_impl.cc )
|
||||
|
||||
set(satnogs_sources "${satnogs_sources}" PARENT_SCOPE)
|
||||
if(NOT satnogs_sources)
|
||||
|
|
|
@ -57,6 +57,7 @@ namespace gr
|
|||
d_state (SEARCHING),
|
||||
d_shifting_byte (0x0),
|
||||
d_decoded_bytes (0),
|
||||
d_decoded_bits (0),
|
||||
d_frame_len (0)
|
||||
{
|
||||
message_port_register_out (pmt::mp ("pdu"));
|
||||
|
@ -195,6 +196,7 @@ namespace gr
|
|||
if (d_decoded_bytes == d_frame_len) {
|
||||
message_port_pub (pmt::mp ("pdu"),
|
||||
pmt::make_blob (d_pdu, d_frame_len));
|
||||
LOG_WARN("Packet of %u", d_frame_len);
|
||||
reset_state ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
|
||||
*
|
||||
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include "upsat_fsk_frame_encoder_impl.h"
|
||||
#include <satnogs/log.h>
|
||||
|
||||
namespace gr
|
||||
{
|
||||
namespace satnogs
|
||||
{
|
||||
|
||||
upsat_fsk_frame_encoder::sptr
|
||||
upsat_fsk_frame_encoder::make (const std::vector<uint8_t>& preamble,
|
||||
const std::vector<uint8_t>& sync_word,
|
||||
bool append_crc, bool whitening,
|
||||
bool manchester)
|
||||
{
|
||||
return gnuradio::get_initial_sptr (
|
||||
new upsat_fsk_frame_encoder_impl (preamble, sync_word, append_crc,
|
||||
whitening, manchester));
|
||||
}
|
||||
|
||||
/*
|
||||
* The private constructor
|
||||
*/
|
||||
upsat_fsk_frame_encoder_impl::upsat_fsk_frame_encoder_impl (
|
||||
const std::vector<uint8_t>& preamble,
|
||||
const std::vector<uint8_t>& sync_word, bool append_crc, bool whitening,
|
||||
bool manchester) :
|
||||
gr::sync_block ("upsat_fsk_frame_encoder",
|
||||
gr::io_signature::make (0, 0, 0),
|
||||
gr::io_signature::make (1, 1, sizeof(float))),
|
||||
d_preamble (preamble),
|
||||
d_preamble_len (preamble.size ()),
|
||||
d_sync_word (sync_word),
|
||||
d_sync_word_len (sync_word.size ()),
|
||||
d_append_crc(append_crc),
|
||||
d_whitening(whitening),
|
||||
d_manchester(manchester),
|
||||
d_encoded(0),
|
||||
d_pdu_len(0)
|
||||
{
|
||||
message_port_register_in (pmt::mp ("pdu"));
|
||||
/*
|
||||
* Allocate memory for the maximum possible frame WITH all headers and
|
||||
* tail fields
|
||||
* +-------------+----------+--------+--------------------------+------+
|
||||
* | Preamble | SFD | LENGTH | PDU | CRC |
|
||||
* +-------------+----------+--------+--------------------------+------+
|
||||
* User def. User def. 1B 1-255 B 2 B
|
||||
*/
|
||||
d_pdu = new uint8_t[d_preamble_len + d_sync_word_len + sizeof(uint8_t)
|
||||
+ UPSAT_MAX_FRAME_LEN + sizeof(uint16_t)];
|
||||
|
||||
/* Copy the preamble at the start of the pdu */
|
||||
memcpy(d_pdu, d_preamble.data(), d_preamble_len);
|
||||
memcpy(d_pdu + d_preamble_len, d_sync_word.data(), d_sync_word_len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Our virtual destructor.
|
||||
*/
|
||||
upsat_fsk_frame_encoder_impl::~upsat_fsk_frame_encoder_impl ()
|
||||
{
|
||||
delete [] d_pdu;
|
||||
}
|
||||
|
||||
int
|
||||
upsat_fsk_frame_encoder_impl::work (int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
pmt::pmt_t pdu;
|
||||
float *out = (float *) output_items[0];
|
||||
|
||||
/*
|
||||
* If the whole previous frame has been successfully sent, block waiting
|
||||
* for a new one
|
||||
*/
|
||||
if(d_encoded == 0){
|
||||
pdu = delete_head_blocking(pmt::mp("pdu"));
|
||||
d_pdu_len = pmt::blob_length (pdu);
|
||||
|
||||
if(d_pdu_len > UPSAT_MAX_FRAME_LEN){
|
||||
LOG_ERROR("PDU is greater than the supported. Dropping the PDU");
|
||||
return 0;
|
||||
}
|
||||
/* Set the frame length at the corresponding field */
|
||||
d_pdu[d_preamble_len + d_sync_word_len] = (uint8_t) d_pdu_len;
|
||||
/* Append the variable length PDU */
|
||||
memcpy (d_pdu + d_preamble_len + d_sync_word_len + sizeof(uint8_t),
|
||||
pmt::blob_data (pdu),
|
||||
d_pdu_len * sizeof(uint8_t));
|
||||
d_pdu_len += d_preamble_len + d_sync_word_len + sizeof(uint8_t);
|
||||
/* If it is necessary calculate and append the CRC */
|
||||
if(d_append_crc) {
|
||||
/* TODO: Calc CRC */
|
||||
d_pdu_len += sizeof(uint16_t);
|
||||
}
|
||||
}
|
||||
|
||||
return noutput_items;
|
||||
}
|
||||
|
||||
} /* namespace satnogs */
|
||||
} /* namespace gr */
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
|
||||
*
|
||||
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_SATNOGS_UPSAT_FSK_FRAME_ENCODER_IMPL_H
|
||||
#define INCLUDED_SATNOGS_UPSAT_FSK_FRAME_ENCODER_IMPL_H
|
||||
|
||||
#include <satnogs/upsat_fsk_frame_encoder.h>
|
||||
|
||||
namespace gr
|
||||
{
|
||||
namespace satnogs
|
||||
{
|
||||
|
||||
class upsat_fsk_frame_encoder_impl : public upsat_fsk_frame_encoder
|
||||
{
|
||||
private:
|
||||
const std::vector<uint8_t> d_preamble;
|
||||
const size_t d_preamble_len;
|
||||
const std::vector<uint8_t> d_sync_word;
|
||||
const size_t d_sync_word_len;
|
||||
const bool d_append_crc;
|
||||
const bool d_whitening;
|
||||
const bool d_manchester;
|
||||
size_t d_encoded;
|
||||
size_t d_pdu_len;
|
||||
uint8_t *d_pdu;
|
||||
|
||||
public:
|
||||
upsat_fsk_frame_encoder_impl (const std::vector<uint8_t>& preamble,
|
||||
const std::vector<uint8_t>& sync_word,
|
||||
bool append_crc, bool whitening,
|
||||
bool manchester);
|
||||
~upsat_fsk_frame_encoder_impl ();
|
||||
|
||||
// Where all the action really happens
|
||||
int
|
||||
work (int noutput_items, gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
};
|
||||
|
||||
} // namespace satnogs
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_SATNOGS_UPSAT_FSK_FRAME_ENCODER_IMPL_H */
|
||||
|
|
@ -26,6 +26,7 @@
|
|||
#include "satnogs/doppler_correction_cc.h"
|
||||
#include "satnogs/frame_encoder.h"
|
||||
#include "satnogs/upsat_fsk_frame_acquisition.h"
|
||||
#include "satnogs/upsat_fsk_frame_encoder.h"
|
||||
%}
|
||||
|
||||
|
||||
|
@ -62,3 +63,5 @@ GR_SWIG_BLOCK_MAGIC2(satnogs, frame_encoder);
|
|||
GR_SWIG_BLOCK_MAGIC2(satnogs, doppler_correction_cc);
|
||||
%include "satnogs/upsat_fsk_frame_acquisition.h"
|
||||
GR_SWIG_BLOCK_MAGIC2(satnogs, upsat_fsk_frame_acquisition);
|
||||
%include "satnogs/upsat_fsk_frame_encoder.h"
|
||||
GR_SWIG_BLOCK_MAGIC2(satnogs, upsat_fsk_frame_encoder);
|
||||
|
|
Loading…
Reference in New Issue