From 5aae0a1b49bfedb304bb571734a166ffc658c24d Mon Sep 17 00:00:00 2001 From: Manolis Surligas Date: Fri, 2 Feb 2018 11:28:37 +0200 Subject: [PATCH] Add block for parsing the FOX slow speed telemetry frames --- .../satellites/amsat_fox_duv_decoder.grc | 51 ++++++++- .../satnogs_amsat_fox_duv_decoder.py | 6 +- grc/CMakeLists.txt | 3 +- grc/satnogs_block_tree.xml | 4 + grc/satnogs_fox_telem_mm.xml | 17 +++ include/satnogs/CMakeLists.txt | 3 +- include/satnogs/fox_telem_mm.h | 57 ++++++++++ lib/CMakeLists.txt | 3 +- lib/fox_telem_mm_impl.cc | 103 ++++++++++++++++++ lib/fox_telem_mm_impl.h | 50 +++++++++ swig/satnogs_swig0.i | 4 + 11 files changed, 293 insertions(+), 8 deletions(-) create mode 100644 grc/satnogs_fox_telem_mm.xml create mode 100644 include/satnogs/fox_telem_mm.h create mode 100644 lib/fox_telem_mm_impl.cc create mode 100644 lib/fox_telem_mm_impl.h diff --git a/apps/flowgraphs/satellites/amsat_fox_duv_decoder.grc b/apps/flowgraphs/satellites/amsat_fox_duv_decoder.grc index c0774fb..7f847eb 100644 --- a/apps/flowgraphs/satellites/amsat_fox_duv_decoder.grc +++ b/apps/flowgraphs/satellites/amsat_fox_duv_decoder.grc @@ -3015,6 +3015,45 @@ max_modulation_freq = 3000 0 + + satnogs_fox_telem_mm + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (535, 759) + + + _rotation + 180 + + + id + satnogs_fox_telem_mm_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + satnogs_frame_file_sink @@ -3035,7 +3074,7 @@ max_modulation_freq = 3000 _coordinate - (622, 761) + (279, 779) _rotation @@ -3428,9 +3467,9 @@ max_modulation_freq = 3000 satnogs_ccsds_rs_decoder_mm_0 - satnogs_frame_file_sink_0_1_0 + satnogs_fox_telem_mm_0 pdu - frame + in satnogs_coarse_doppler_correction_cc_0 @@ -3444,6 +3483,12 @@ max_modulation_freq = 3000 pdu in + + satnogs_fox_telem_mm_0 + satnogs_frame_file_sink_0_1_0 + raw + frame + satnogs_quad_demod_filter_ff_0 digital_binary_slicer_fb_0_0 diff --git a/apps/flowgraphs/satellites/satnogs_amsat_fox_duv_decoder.py b/apps/flowgraphs/satellites/satnogs_amsat_fox_duv_decoder.py index c9a78a4..bff4f5f 100755 --- a/apps/flowgraphs/satellites/satnogs_amsat_fox_duv_decoder.py +++ b/apps/flowgraphs/satellites/satnogs_amsat_fox_duv_decoder.py @@ -5,7 +5,7 @@ # Title: AMSAT FOX DUV Decoder # Author: Thanos Giolias (agiolias@csd.uoc.gr), Nikos Karamolegos (karamolegkos.n@gmail.com), Manolis Surligas (surligas@gmail.com) # Description: A DUV Decoder for the AMSAT FOX satellites -# Generated: Wed Jan 31 22:50:39 2018 +# Generated: Fri Feb 2 11:24:35 2018 ################################################## from gnuradio import analog @@ -69,6 +69,7 @@ class satnogs_amsat_fox_duv_decoder(gr.top_block): self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(file_path, audio_samp_rate, 1.0) self.satnogs_iq_sink_0 = satnogs.iq_sink(32767, iq_file_path, False, enable_iq_dump) self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink(decoded_data_file_path, 1) + self.satnogs_fox_telem_mm_0 = satnogs.fox_telem_mm() self.satnogs_decoder_8b10b_0 = satnogs.decoder_8b10b('0011111010', 960) self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, samp_rate_rx) @@ -107,8 +108,9 @@ class satnogs_amsat_fox_duv_decoder(gr.top_block): ################################################## # Connections ################################################## - self.msg_connect((self.satnogs_ccsds_rs_decoder_mm_0, 'pdu'), (self.satnogs_frame_file_sink_0_1_0, 'frame')) + self.msg_connect((self.satnogs_ccsds_rs_decoder_mm_0, 'pdu'), (self.satnogs_fox_telem_mm_0, 'in')) self.msg_connect((self.satnogs_decoder_8b10b_0, 'pdu'), (self.satnogs_ccsds_rs_decoder_mm_0, 'in')) + self.msg_connect((self.satnogs_fox_telem_mm_0, 'raw'), (self.satnogs_frame_file_sink_0_1_0, 'frame')) self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_doppler_correction_cc_0, 'freq')) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.satnogs_ogg_encoder_0, 0)) diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index 81549ec..22d7ab6 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -54,5 +54,6 @@ install(FILES ${enabled_blocks} satnogs_quad_demod_filter_ff.xml satnogs_decoder_8b10b.xml - satnogs_ccsds_rs_decoder_mm.xml DESTINATION share/gnuradio/grc/blocks + satnogs_ccsds_rs_decoder_mm.xml + satnogs_fox_telem_mm.xml DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/satnogs_block_tree.xml b/grc/satnogs_block_tree.xml index d80bfc0..ed471e7 100644 --- a/grc/satnogs_block_tree.xml +++ b/grc/satnogs_block_tree.xml @@ -13,6 +13,10 @@ satnogs_upsat_transmitter satnogs_qb50_deframer + + AMSAT FOX + satnogs_fox_telem_mm + satnogs_cw_matched_filter_ff satnogs_morse_decoder diff --git a/grc/satnogs_fox_telem_mm.xml b/grc/satnogs_fox_telem_mm.xml new file mode 100644 index 0000000..12bf314 --- /dev/null +++ b/grc/satnogs_fox_telem_mm.xml @@ -0,0 +1,17 @@ + + + FOX telemetry processor + satnogs_fox_telem_mm + import satnogs + satnogs.fox_telem_mm() + + + in + message + + + + raw + message + + diff --git a/include/satnogs/CMakeLists.txt b/include/satnogs/CMakeLists.txt index b2c22de..cf2b26f 100644 --- a/include/satnogs/CMakeLists.txt +++ b/include/satnogs/CMakeLists.txt @@ -69,5 +69,6 @@ install(FILES ${HEADER_FILES} quad_demod_filter_ff.h decoder_8b10b.h - ccsds_rs_decoder_mm.h DESTINATION include/satnogs + ccsds_rs_decoder_mm.h + fox_telem_mm.h DESTINATION include/satnogs ) \ No newline at end of file diff --git a/include/satnogs/fox_telem_mm.h b/include/satnogs/fox_telem_mm.h new file mode 100644 index 0000000..c366c5d --- /dev/null +++ b/include/satnogs/fox_telem_mm.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module + * + * Copyright (C) 2018, Libre Space Foundation + * + * 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 . + */ + +#ifndef INCLUDED_SATNOGS_FOX_TELEM_MM_H +#define INCLUDED_SATNOGS_FOX_TELEM_MM_H + +#include +#include + +namespace gr +{ + namespace satnogs + { + + /*! + * \brief This block takes a AMSAT FOX telemetry frame from the CCSDS + * RS decoder, discards the pad bytes, checks if the frame is originating + * from a valid spacecraft and outputs the data to another message port. + * \ingroup satnogs + * + */ + class SATNOGS_API fox_telem_mm : virtual public gr::block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * \brief This block takes a AMSAT FOX telemetry frame from the CCSDS + * RS decoder, discards the pad bytes, checks if the frame is originating + * from a valid spacecraft and outputs the data to another message port. + */ + static sptr + make (); + }; + + } // namespace satnogs +} // namespace gr + +#endif /* INCLUDED_SATNOGS_FOX_TELEM_MM_H */ + diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index e2a6153..7661f73 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -68,7 +68,8 @@ list(APPEND satnogs_sources iq_sink_impl.cc quad_demod_filter_ff_impl.cc decoder_8b10b_impl.cc - ccsds_rs_decoder_mm_impl.cc) + ccsds_rs_decoder_mm_impl.cc + fox_telem_mm_impl.cc) if(${INCLUDE_DEBUG_BLOCKS}) list(APPEND satnogs_sources ${satnogs_debug_sources}) diff --git a/lib/fox_telem_mm_impl.cc b/lib/fox_telem_mm_impl.cc new file mode 100644 index 0000000..549669d --- /dev/null +++ b/lib/fox_telem_mm_impl.cc @@ -0,0 +1,103 @@ +/* -*- c++ -*- */ +/* + * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module + * + * Copyright (C) 2018, Libre Space Foundation + * + * 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 . + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "fox_telem_mm_impl.h" + +#include + +namespace gr { + namespace satnogs { + + /** + * AMSAT FOX spacecraft IDs + */ + const uint8_t fox_telem_mm_impl::fox_id[] = {0x1, 0x2, 0x3}; + + fox_telem_mm::sptr + fox_telem_mm::make() + { + return gnuradio::get_initial_sptr + (new fox_telem_mm_impl()); + } + + /* + * The private constructor + */ + fox_telem_mm_impl::fox_telem_mm_impl() + : gr::block("fox_telem_mm", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(0, 0, 0)), + /* 6 header, 58 payload */ + d_frame_size (6 + 58) + { + message_port_register_in (pmt::mp ("in")); + message_port_register_out (pmt::mp ("raw")); + + set_msg_handler ( + pmt::mp ("in"), + boost::bind (&fox_telem_mm_impl::process_frame, this, _1)); + } + + static inline bool + is_spacecraft_valid(uint8_t id) + { + for (size_t i = 0; i < sizeof(fox_telem_mm_impl::fox_id); i++) { + if (fox_telem_mm_impl::fox_id[i] == id) { + return true; + } + } + return false; + } + + void + fox_telem_mm_impl::process_frame (pmt::pmt_t msg) + { + uint8_t fox_id; + const uint8_t *data = (const uint8_t *) pmt::blob_data(msg); + size_t data_len = pmt::blob_length(msg); + + if(data_len != 223) { + LOG_ERROR("Invalid message"); + } + + /* Check the spacecraft ID */ + fox_id = data[0] & 0x3; + if(!is_spacecraft_valid(fox_id)) { + return; + } + + message_port_pub(pmt::mp("raw"), pmt::make_blob(data, d_frame_size)); + } + + /* + * Our virtual destructor. + */ + fox_telem_mm_impl::~fox_telem_mm_impl() + { + } + + } /* namespace satnogs */ +} /* namespace gr */ + diff --git a/lib/fox_telem_mm_impl.h b/lib/fox_telem_mm_impl.h new file mode 100644 index 0000000..1aafa71 --- /dev/null +++ b/lib/fox_telem_mm_impl.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module + * + * Copyright (C) 2018, Libre Space Foundation + * + * 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 . + */ + +#ifndef INCLUDED_SATNOGS_FOX_TELEM_MM_IMPL_H +#define INCLUDED_SATNOGS_FOX_TELEM_MM_IMPL_H + +#include + +namespace gr +{ + namespace satnogs + { + + class fox_telem_mm_impl : public fox_telem_mm + { + private: + const size_t d_frame_size; + + void + process_frame (pmt::pmt_t msg); + + public: + static const uint8_t fox_id[]; + + fox_telem_mm_impl (); + ~fox_telem_mm_impl (); + }; + + } // namespace satnogs +} // namespace gr + +#endif /* INCLUDED_SATNOGS_FOX_TELEM_MM_IMPL_H */ + diff --git a/swig/satnogs_swig0.i b/swig/satnogs_swig0.i index a374178..90af799 100644 --- a/swig/satnogs_swig0.i +++ b/swig/satnogs_swig0.i @@ -34,6 +34,7 @@ #include "satnogs/quad_demod_filter_ff.h" #include "satnogs/decoder_8b10b.h" #include "satnogs/ccsds_rs_decoder_mm.h" +#include "satnogs/fox_telem_mm.h" %} @@ -109,3 +110,6 @@ GR_SWIG_BLOCK_MAGIC2(satnogs, decoder_8b10b); %include "satnogs/ccsds_rs_decoder_mm.h" GR_SWIG_BLOCK_MAGIC2(satnogs, ccsds_rs_decoder_mm); + +%include "satnogs/fox_telem_mm.h" +GR_SWIG_BLOCK_MAGIC2(satnogs, fox_telem_mm);