diff --git a/grc/satnogs_iq_sink.block.yml b/grc/satnogs_iq_sink.block.yml index b3cb30d..6678ca8 100644 --- a/grc/satnogs_iq_sink.block.yml +++ b/grc/satnogs_iq_sink.block.yml @@ -33,7 +33,5 @@ inputs: templates: imports: import satnogs make: satnogs.iq_sink(${scale}, ${filename}, ${append}, ${activate}) - callbacks: - - open(${filename}) file_format: 1 diff --git a/include/satnogs/iq_sink.h b/include/satnogs/iq_sink.h index 23e9ff2..651982d 100644 --- a/include/satnogs/iq_sink.h +++ b/include/satnogs/iq_sink.h @@ -23,7 +23,6 @@ #include #include -#include namespace gr { namespace satnogs { @@ -36,8 +35,7 @@ namespace satnogs { * \ingroup satnogs * */ -class SATNOGS_API iq_sink : virtual public gr::sync_block, - virtual public gr::blocks::file_sink_base { +class SATNOGS_API iq_sink : virtual public gr::sync_block { public: typedef boost::shared_ptr sptr; diff --git a/lib/iq_sink_impl.cc b/lib/iq_sink_impl.cc index f600d8a..dade3fa 100644 --- a/lib/iq_sink_impl.cc +++ b/lib/iq_sink_impl.cc @@ -26,6 +26,7 @@ #include "iq_sink_impl.h" #include #include +#include namespace gr { namespace satnogs { @@ -46,11 +47,27 @@ iq_sink_impl::iq_sink_impl(const float scale, const char *filename, gr::sync_block("iq_sink", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(0, 0, 0)), - file_sink_base(filename, true, append), + file_sink_base(), d_scale(scale), d_num_points(16384), d_status((iq_sink_status_t) status) { + d_fp = 0; + d_new_fp = 0; + d_updated = false; + d_is_binary = true; + d_append = append; + /* + * Because the constructor of the derived class explicitly calls the open() + * and we want to avoid trying to open and invalid file in case of the + * user option is for bypassing this block, we call it explicitly + */ + if (status == IQ_SINK_STATUS_ACTIVE) { + if (!open(filename)) { + throw std::invalid_argument("IQ File Sink: Could not open file"); + } + } + set_max_noutput_items(d_num_points); unsigned int alignment = volk_get_alignment(); d_out = (int16_t *) volk_malloc(sizeof(int16_t) * d_num_points * 2, diff --git a/lib/iq_sink_impl.h b/lib/iq_sink_impl.h index ff78a8c..24db436 100644 --- a/lib/iq_sink_impl.h +++ b/lib/iq_sink_impl.h @@ -22,13 +22,14 @@ #define INCLUDED_SATNOGS_IQ_SINK_IMPL_H #include +#include #include #include namespace gr { namespace satnogs { -class iq_sink_impl : public iq_sink { +class iq_sink_impl : public iq_sink, public gr::blocks::file_sink_base { private: /** * The different values for iq sink status