diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index 94d4e32..cc90fda 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -31,5 +31,6 @@ install(FILES satnogs_json_to_ecss_src.xml satnogs_tcp_rigctl_msg_source.xml satnogs_frame_encoder.xml - satnogs_doppler_correction_cc.xml DESTINATION share/gnuradio/grc/blocks + satnogs_doppler_correction_cc.xml + satnogs_upsat_fsk_frame_acquisition.xml DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/satnogs_upsat_fsk_frame_acquisition.xml b/grc/satnogs_upsat_fsk_frame_acquisition.xml new file mode 100644 index 0000000..8c78be7 --- /dev/null +++ b/grc/satnogs_upsat_fsk_frame_acquisition.xml @@ -0,0 +1,38 @@ + + + upsat_fsk_frame_acquisition + satnogs_upsat_fsk_frame_acquisition + satnogs + import satnogs + satnogs.upsat_fsk_frame_acquisition($&preamble, $&sync_word, $whitening, $manchester) + + + ... + ... + ... + + + + + in + + + + + + out + + + diff --git a/include/satnogs/CMakeLists.txt b/include/satnogs/CMakeLists.txt index 104307a..e11ed74 100644 --- a/include/satnogs/CMakeLists.txt +++ b/include/satnogs/CMakeLists.txt @@ -44,5 +44,6 @@ install(FILES frame_encoder.h doppler_correction_cc.h doppler_fit.h - freq_drift.h DESTINATION include/satnogs + freq_drift.h + upsat_fsk_frame_acquisition.h DESTINATION include/satnogs ) diff --git a/include/satnogs/upsat_fsk_frame_acquisition.h b/include/satnogs/upsat_fsk_frame_acquisition.h new file mode 100644 index 0000000..490ebcc --- /dev/null +++ b/include/satnogs/upsat_fsk_frame_acquisition.h @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* + * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module + * + * Copyright (C) 2016, 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_UPSAT_FSK_FRAME_ACQUISITION_H +#define INCLUDED_SATNOGS_UPSAT_FSK_FRAME_ACQUISITION_H + +#include +#include + +namespace gr +{ + namespace satnogs + { + + /*! + * \brief This block takes samples after the Clock Recovery block + * and tries to extract frames. This is performed by searching for a + * known preamble. For the byte synchronization the block tries to + * search for the specified synchronization word that should be present + * before the start of the payload. + * + * \ingroup satnogs + * + */ + class SATNOGS_API upsat_fsk_frame_acquisition : virtual public gr::sync_block + { + public: + typedef boost::shared_ptr sptr; + + /*! + * Creates the FSK frame acquisition block for the UPSAT satellite. + * @param preamble the bytes that consist the preamble of the frame + * @param sync_word the byte synchronization word + * @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 &preamble, + const std::vector &sync_word, bool whitening = false, + bool manchester = false); + }; + + } // namespace satnogs +} // namespace gr + +#endif /* INCLUDED_SATNOGS_UPSAT_FSK_FRAME_ACQUISITION_H */ + diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index b8401cf..ada644d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -42,7 +42,8 @@ list(APPEND satnogs_sources doppler_correction_cc_impl.cc frame_encoder_impl.cc doppler_fit.cc - freq_drift.cc ) + freq_drift.cc + upsat_fsk_frame_acquisition_impl.cc ) set(satnogs_sources "${satnogs_sources}" PARENT_SCOPE) if(NOT satnogs_sources) diff --git a/lib/upsat_fsk_frame_acquisition_impl.cc b/lib/upsat_fsk_frame_acquisition_impl.cc new file mode 100644 index 0000000..3527d24 --- /dev/null +++ b/lib/upsat_fsk_frame_acquisition_impl.cc @@ -0,0 +1,77 @@ +/* -*- c++ -*- */ +/* + * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module + * + * Copyright (C) 2016, 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 "upsat_fsk_frame_acquisition_impl.h" + +namespace gr +{ + namespace satnogs + { + + upsat_fsk_frame_acquisition::sptr + upsat_fsk_frame_acquisition::make (const std::vector &preamble, + const std::vector &sync_word, + bool whitening, bool manchester) + { + return gnuradio::get_initial_sptr ( + new upsat_fsk_frame_acquisition_impl (preamble, sync_word, whitening, + manchester)); + } + + /* + * The private constructor + */ + upsat_fsk_frame_acquisition_impl::upsat_fsk_frame_acquisition_impl ( + const std::vector &preamble, + const std::vector &sync_word, bool whitening, bool manchester) : + gr::sync_block ("upsat_fsk_frame_acquisition", + gr::io_signature::make (1, 1, sizeof(float)), + gr::io_signature::make (0, 0, 0)) + { + } + + /* + * Our virtual destructor. + */ + upsat_fsk_frame_acquisition_impl::~upsat_fsk_frame_acquisition_impl () + { + } + + int + upsat_fsk_frame_acquisition_impl::work ( + int noutput_items, gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const float *in = (const float *) input_items[0]; + + // Do <+signal processing+> + + // Tell runtime system how many output items we produced. + return noutput_items; + } + + } /* namespace satnogs */ +} /* namespace gr */ + diff --git a/lib/upsat_fsk_frame_acquisition_impl.h b/lib/upsat_fsk_frame_acquisition_impl.h new file mode 100644 index 0000000..df269c2 --- /dev/null +++ b/lib/upsat_fsk_frame_acquisition_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module + * + * Copyright (C) 2016, 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_UPSAT_FSK_FRAME_ACQUISITION_IMPL_H +#define INCLUDED_SATNOGS_UPSAT_FSK_FRAME_ACQUISITION_IMPL_H + +#include + +namespace gr +{ + namespace satnogs + { + + class upsat_fsk_frame_acquisition_impl : public upsat_fsk_frame_acquisition + { + private: + // Nothing to declare in this block. + + public: + upsat_fsk_frame_acquisition_impl (const std::vector &preamble, + const std::vector &sync_word, + bool whitening, bool manchester); + ~upsat_fsk_frame_acquisition_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_ACQUISITION_IMPL_H */ + diff --git a/swig/satnogs_swig.i b/swig/satnogs_swig.i index 2b40315..fb2fba3 100644 --- a/swig/satnogs_swig.i +++ b/swig/satnogs_swig.i @@ -25,6 +25,7 @@ #include "satnogs/json_to_ecss_src.h" #include "satnogs/doppler_correction_cc.h" #include "satnogs/frame_encoder.h" +#include "satnogs/upsat_fsk_frame_acquisition.h" %} @@ -59,3 +60,5 @@ GR_SWIG_BLOCK_MAGIC2(satnogs, json_to_ecss_src); GR_SWIG_BLOCK_MAGIC2(satnogs, frame_encoder); %include "satnogs/doppler_correction_cc.h" GR_SWIG_BLOCK_MAGIC2(satnogs, doppler_correction_cc); +%include "satnogs/upsat_fsk_frame_acquisition.h" +GR_SWIG_BLOCK_MAGIC2(satnogs, upsat_fsk_frame_acquisition);