From b7ebcd5db5c25c0f5c48146fe594e4ce26206741 Mon Sep 17 00:00:00 2001 From: Sleepwalker Date: Thu, 12 May 2016 17:25:13 +0300 Subject: [PATCH 1/3] Added satnogs transmitter hierarchy block --- grc/CMakeLists.txt | 1 + grc/satnogs_transmitter.xml | 181 ++++++++++++++++++++++++++++++++++ python/CMakeLists.txt | 1 + python/__init__.py | 1 + python/satnogs_transmitter.py | 111 +++++++++++++++++++++ 5 files changed, 295 insertions(+) create mode 100644 grc/satnogs_transmitter.xml create mode 100644 python/satnogs_transmitter.py diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index eb059df..d6520d5 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -36,5 +36,6 @@ install(FILES satnogs_upsat_fsk_frame_encoder.xml satnogs_whitening.xml satnogs_udp_msg_sink.xml + satnogs_transmitter.xml satnogs_coarse_doppler_correction_cc.xml DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/satnogs_transmitter.xml b/grc/satnogs_transmitter.xml new file mode 100644 index 0000000..b10ae16 --- /dev/null +++ b/grc/satnogs_transmitter.xml @@ -0,0 +1,181 @@ + + Satnogs Transmitter + satnogs_transmitter + satnogs + import satnogs + + satnogs.satnogs_transmitter(frame_preamble=$frame_preamble, + sync_word=$sync_word, + append_crc=$append_crc, + whitening=$whitening, + manchester=$manchester, + msb_first=$msb_first, + ax25_format=$ax25_format, + dest_addr=$dest_addr, + dest_ssid=$dest_ssid, + src_addr=$src_addr, + src_ssid=$src_ssid, + settling_samples=$settling_samples, + samps_per_symbol=$interp, + interpolation_taps=$taps, + samp_rate=$samp_rate, + lo_offset=$lo_offset, + deviation=$deviation, + baud_rate=$baud_rate) + + + Frame Preamble + frame_preamble + raw + + + Synchronization Word + sync_word + raw + + + Append CRC + append_crc + enum + + + + + + Whitening + whitening + enum + + + + + + Use Manchester Coding + manchester + enum + + + + + + Send MS bit first + msb_first + enum + + + + + + Use AX.25 encapsulation + ax25_format + enum + + + + + + Destination Callsign + dest_addr + string + + + + Destination SSID + dest_ssid + int + + + + Source Callsign + src_addr + string + + + + Source SSID + src_ssid + int + + + + Number of zero settling samples + settling_samples + 64 + int + + + + FIR filter Interpolation + interp + 1 + int + + + Interpolation Taps + taps + real_vector + + + Sampling rate + samp_rate + real + + + LO offset + lo_offset + real + + + baud rate + baud_rate + real + + + Deviation + deviation + real + + + + + in + message + + + + out + complex + + + + \ No newline at end of file diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index fdacd7f..c42ba84 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -31,6 +31,7 @@ endif() GR_PYTHON_INSTALL( FILES __init__.py + satnogs_transmitter.py DESTINATION ${GR_PYTHON_DIR}/satnogs ) diff --git a/python/__init__.py b/python/__init__.py index 170ffd3..5638907 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -27,6 +27,7 @@ description here (python/__init__.py). try: # this might fail if the module is python-only from satnogs_swig import * + from satnogs_transmitter import * except ImportError: pass diff --git a/python/satnogs_transmitter.py b/python/satnogs_transmitter.py new file mode 100644 index 0000000..4e0dcad --- /dev/null +++ b/python/satnogs_transmitter.py @@ -0,0 +1,111 @@ +#! /usr/bin/python + +import satnogs +import satnogs_swig +import math +from gnuradio import blocks +from gnuradio import filter +from gnuradio import analog +from gnuradio import gr +from gnuradio.filter import firdes +from gnuradio.gr.runtime_swig import sizeof_gr_complex + + +class satnogs_transmitter(gr.hier_block2): + + def __init__(self, + frame_preamble, + sync_word, + append_crc, + whitening, + manchester, + msb_first, + ax25_format, + dest_addr, + dest_ssid, + src_addr, + src_ssid, + settling_samples, + samps_per_symbol, + interpolation_taps, + samp_rate, + lo_offset, + deviation, + baud_rate): + gr.hier_block2.__init__(self, "satnogs_transmitter", + gr.io_signature(0 , 0 , 0), + # Output 0: The complex TX signal for the SDR device + # Output 1: The constellation output for the vector analyzer + gr.io_signature(1, 1, sizeof_gr_complex)) + self.frame_preamble = frame_preamble + self.sync_word = sync_word + self.append_crc = append_crc + self.whitening = whitening + self.manchester = manchester + self.msb_first = msb_first + self.ax25_format = ax25_format + self.dest_addr = dest_addr + self.dest_ssid = dest_ssid + self.src_addr = src_addr + self.src_ssid = src_ssid + self.settling_samples = settling_samples + self.samps_per_symbol = samps_per_symbol + self.interpolation_taps = interpolation_taps + self.samp_rate = samp_rate + self.lo_offset = lo_offset + self.deviation=deviation + self.baud_rate=baud_rate + self.message_port_register_hier_out("in") + + + self.modulation_index = self.deviation/(self.baud_rate / 2.0) + self.sensitivity = (math.pi*self.modulation_index) / self.samps_per_symbol + self.resampling_rate = self.samp_rate / (self.baud_rate*self.samps_per_symbol ) + self.par_taps = filter.firdes.low_pass_2(32, 32, 0.8, 0.1, 60) + self.num_filters = 32 + +#================================================================= +# TX Related blocks +#================================================================= + + self.fsk_frame_encoder = satnogs_swig.upsat_fsk_frame_encoder(self.frame_preamble, + self.sync_word, + self.append_crc, + self.whitening, + self.manchester, + self.msb_first, + self.ax25_format, + self.dest_addr, + self.dest_ssid, + self.src_addr, + self.src_ssid, + self.settling_samples + ) + + self.interp_fir_filter = filter.interp_fir_filter_fff(self.samps_per_symbol, + self.interpolation_taps + ) + + self.frequency_modulator = analog.frequency_modulator_fc(self.sensitivity) + self.signal_source = analog.sig_source_c(self.samp_rate, + 102, + self.lo_offset, + 1, + 0) + self.polyphase_arbitrary_resampler = filter.pfb_arb_resampler_ccf(self.resampling_rate, + self.par_taps, + self.num_filters) + self.multiply = blocks.multiply_cc(1) + +#================================================================= +# Connections +#================================================================= + self.msg_connect((self, "in"), (self.fsk_frame_encoder, "pdu")) + self.connect((self.fsk_frame_encoder, 0), (self.interp_fir_filter, 0)) + self.connect((self.interp_fir_filter, 0), (self.frequency_modulator, 0)) + self.connect((self.frequency_modulator, 0), (self.polyphase_arbitrary_resampler, 0)) + self.connect((self.signal_source, 0) , (self.multiply, 0)) + self.connect((self.polyphase_arbitrary_resampler, 0) , (self.multiply, 1)) + self.connect((self.multiply, 0), self) + + From 455e19e4663749e568521e5e5a3e953ce496746e Mon Sep 17 00:00:00 2001 From: George Vardakis Date: Fri, 13 May 2016 15:57:33 +0300 Subject: [PATCH 2/3] Added hex and binary output sink --- grc/CMakeLists.txt | 2 +- grc/satnogs_clear_text_msg_sink.xml | 13 ------- grc/satnogs_multi_format_msg_sink.xml | 31 +++++++++++++++ include/satnogs/CMakeLists.txt | 2 +- ...ext_msg_sink.h => multi_format_msg_sink.h} | 12 +++--- lib/CMakeLists.txt | 2 +- ..._impl.cc => multi_format_msg_sink_impl.cc} | 38 ++++++++++++++----- ...nk_impl.h => multi_format_msg_sink_impl.h} | 14 ++++--- swig/satnogs_swig.i | 6 +-- 9 files changed, 79 insertions(+), 41 deletions(-) delete mode 100644 grc/satnogs_clear_text_msg_sink.xml create mode 100644 grc/satnogs_multi_format_msg_sink.xml rename include/satnogs/{clear_text_msg_sink.h => multi_format_msg_sink.h} (82%) rename lib/{clear_text_msg_sink_impl.cc => multi_format_msg_sink_impl.cc} (54%) rename lib/{clear_text_msg_sink_impl.h => multi_format_msg_sink_impl.h} (73%) diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index d6520d5..91398c7 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -20,7 +20,7 @@ install(FILES satnogs_cw_matched_filter_ff.xml satnogs_morse_decoder.xml satnogs_morse_debug_source.xml - satnogs_clear_text_msg_sink.xml + satnogs_multi_format_msg_sink.xml satnogs_cw_to_symbol.xml satnogs_afsk_decoder.xml satnogs_sine_matched_filter_ff.xml diff --git a/grc/satnogs_clear_text_msg_sink.xml b/grc/satnogs_clear_text_msg_sink.xml deleted file mode 100644 index 497c8f5..0000000 --- a/grc/satnogs_clear_text_msg_sink.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - Clear Text Message Sink - satnogs_clear_text_msg_sink - satnogs - import satnogs - satnogs.clear_text_msg_sink() - - - in - message - - diff --git a/grc/satnogs_multi_format_msg_sink.xml b/grc/satnogs_multi_format_msg_sink.xml new file mode 100644 index 0000000..a1cbd07 --- /dev/null +++ b/grc/satnogs_multi_format_msg_sink.xml @@ -0,0 +1,31 @@ + + + Multi Format Message Sink + satnogs_multi_format_msg_sink + satnogs + import satnogs + satnogs.multi_format_msg_sink($format) + + + Output format + format + enum + + + + + + + in + message + + diff --git a/include/satnogs/CMakeLists.txt b/include/satnogs/CMakeLists.txt index 1741ed3..23f41a3 100644 --- a/include/satnogs/CMakeLists.txt +++ b/include/satnogs/CMakeLists.txt @@ -30,7 +30,7 @@ install(FILES morse.h morse_decoder.h morse_debug_source.h - clear_text_msg_sink.h + multi_format_msg_sink.h cw_to_symbol.h afsk_decoder.h sine_matched_filter_ff.h diff --git a/include/satnogs/clear_text_msg_sink.h b/include/satnogs/multi_format_msg_sink.h similarity index 82% rename from include/satnogs/clear_text_msg_sink.h rename to include/satnogs/multi_format_msg_sink.h index 4164581..e281a87 100644 --- a/include/satnogs/clear_text_msg_sink.h +++ b/include/satnogs/multi_format_msg_sink.h @@ -18,8 +18,8 @@ * along with this program. If not, see . */ -#ifndef INCLUDED_SATNOGS_CLEAR_TEXT_MSG_SINK_H -#define INCLUDED_SATNOGS_CLEAR_TEXT_MSG_SINK_H +#ifndef INCLUDED_SATNOGS_MULTI_FORMAT_MSG_SINK_H +#define INCLUDED_SATNOGS_MULTI_FORMAT_MSG_SINK_H #include #include @@ -37,10 +37,10 @@ namespace gr * \ingroup satnogs * */ - class SATNOGS_API clear_text_msg_sink : virtual public gr::block + class SATNOGS_API multi_format_msg_sink : virtual public gr::block { public: - typedef boost::shared_ptr sptr; + typedef boost::shared_ptr sptr; /*! * \brief Block accepting clear text messages from various decoders. @@ -49,11 +49,11 @@ namespace gr * */ static sptr - make (); + make (size_t format); }; } // namespace satnogs } // namespace gr -#endif /* INCLUDED_SATNOGS_CLEAR_TEXT_MSG_SINK_H */ +#endif /* INCLUDED_SATNOGS_multi_format_MSG_SINK_H */ diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 217edcb..436577a 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -29,7 +29,7 @@ list(APPEND satnogs_sources morse_tree.cc morse_decoder_impl.cc morse_debug_source_impl.cc - clear_text_msg_sink_impl.cc + multi_format_msg_sink_impl.cc cw_to_symbol_impl.cc afsk_decoder_impl.cc sine_matched_filter_ff_impl.cc diff --git a/lib/clear_text_msg_sink_impl.cc b/lib/multi_format_msg_sink_impl.cc similarity index 54% rename from lib/clear_text_msg_sink_impl.cc rename to lib/multi_format_msg_sink_impl.cc index e10abc0..61c8f58 100644 --- a/lib/clear_text_msg_sink_impl.cc +++ b/lib/multi_format_msg_sink_impl.cc @@ -23,37 +23,55 @@ #endif #include -#include "clear_text_msg_sink_impl.h" +#include "multi_format_msg_sink_impl.h" namespace gr { namespace satnogs { - clear_text_msg_sink::sptr - clear_text_msg_sink::make() + multi_format_msg_sink::sptr + multi_format_msg_sink::make(size_t format) { return gnuradio::get_initial_sptr - (new clear_text_msg_sink_impl()); + (new multi_format_msg_sink_impl(format)); } void - clear_text_msg_sink_impl::msg_handler (pmt::pmt_t msg) + multi_format_msg_sink_impl::msg_handler (pmt::pmt_t msg) { std::string s((const char *)pmt::blob_data(msg), pmt::blob_length(msg)); - std::cout << "Received text sequence:" << s << " " << std::endl; + switch(d_format){ + case 0: + std::cout << "Received text sequence:" << s << " " << std::endl; + break; + case 1: + //for(size_t i=0; i< pmt::blob_length(msg); i++) + for (size_t i = 0; i < s.length(); ++i) + std::cout << std::hex << std::setfill('0') << std::setw(2) <<(int)s[i]; + std::cout<(((uint8_t*)pmt::blob_data(msg))[i]); + std::cout<. */ -#ifndef INCLUDED_SATNOGS_CLEAR_TEXT_MSG_SINK_IMPL_H -#define INCLUDED_SATNOGS_CLEAR_TEXT_MSG_SINK_IMPL_H +#ifndef INCLUDED_SATNOGS_MULTI_FORMAT_MSG_SINK_IMPL_H +#define INCLUDED_SATNOGS_MULTI_FORMAT_MSG_SINK_IMPL_H -#include +#include namespace gr { namespace satnogs { - class clear_text_msg_sink_impl : public clear_text_msg_sink + class multi_format_msg_sink_impl : public multi_format_msg_sink { private: void msg_handler(pmt::pmt_t msg); + size_t d_format; + public: - clear_text_msg_sink_impl (); + multi_format_msg_sink_impl (size_t format); }; } // namespace satnogs } // namespace gr -#endif /* INCLUDED_SATNOGS_CLEAR_TEXT_MSG_SINK_IMPL_H */ +#endif /* INCLUDED_SATNOGS_multi_format_MSG_SINK_IMPL_H */ diff --git a/swig/satnogs_swig.i b/swig/satnogs_swig.i index f89622b..29442eb 100644 --- a/swig/satnogs_swig.i +++ b/swig/satnogs_swig.i @@ -13,7 +13,7 @@ #include "satnogs/morse_tree.h" #include "satnogs/morse_decoder.h" #include "satnogs/morse_debug_source.h" -#include "satnogs/clear_text_msg_sink.h" +#include "satnogs/multi_format_msg_sink.h" #include "satnogs/cw_to_symbol.h" #include "satnogs/afsk_decoder.h" #include "satnogs/sine_matched_filter_ff.h" @@ -40,8 +40,8 @@ GR_SWIG_BLOCK_MAGIC2(satnogs, cw_matched_filter_ff); GR_SWIG_BLOCK_MAGIC2(satnogs, morse_decoder); %include "satnogs/morse_debug_source.h" GR_SWIG_BLOCK_MAGIC2(satnogs, morse_debug_source); -%include "satnogs/clear_text_msg_sink.h" -GR_SWIG_BLOCK_MAGIC2(satnogs, clear_text_msg_sink); +%include "satnogs/multi_format_msg_sink.h" +GR_SWIG_BLOCK_MAGIC2(satnogs, multi_format_msg_sink); %include "satnogs/cw_to_symbol.h" GR_SWIG_BLOCK_MAGIC2(satnogs, cw_to_symbol); %include "satnogs/afsk_decoder.h" From 855ac47c26ad5fcabf3a8271914cc70ac41edfea Mon Sep 17 00:00:00 2001 From: George Vardakis Date: Fri, 13 May 2016 16:19:47 +0300 Subject: [PATCH 3/3] Added the "0x" prefix to hex representation --- lib/multi_format_msg_sink_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/multi_format_msg_sink_impl.cc b/lib/multi_format_msg_sink_impl.cc index 61c8f58..336bff1 100644 --- a/lib/multi_format_msg_sink_impl.cc +++ b/lib/multi_format_msg_sink_impl.cc @@ -46,7 +46,7 @@ namespace gr { case 1: //for(size_t i=0; i< pmt::blob_length(msg); i++) for (size_t i = 0; i < s.length(); ++i) - std::cout << std::hex << std::setfill('0') << std::setw(2) <<(int)s[i]; + std::cout << "0x" << std::hex<< std::setfill('0') << std::setw(2)<< std::dec <<(int)s[i] << " "; std::cout<