Update solar panel and debug schematic, update grc modules
This commit is contained in:
parent
6dcc05810c
commit
8d4b31044e
Binary file not shown.
Binary file not shown.
|
@ -39,13 +39,6 @@ install(FILES
|
|||
kcsa_sync_det_b.xml
|
||||
kcsa_halfduplex_pdu_to_stream.xml
|
||||
kcsa_fullduplex_pdu_to_stream.xml
|
||||
kcsa_feedforward_agc.xml
|
||||
variable_kcsa_pncode.xml
|
||||
kcsa_dsss_rx.xml
|
||||
kcsa_dsss_tx.xml
|
||||
#kcsa_psk_rx.xml
|
||||
#kcsa_framesync.xml
|
||||
kcsa_qpskdiffsplit.xml
|
||||
kcsa_power_sensor.xml
|
||||
kcsa_pdu_to_stream2.xml DESTINATION share/gnuradio/grc/blocks
|
||||
)
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
<param>
|
||||
<name>Filler</name>
|
||||
<key>filler</key>
|
||||
<value>0x00</value>
|
||||
<value>0x55</value>
|
||||
<type>raw</type>
|
||||
</param>
|
||||
<sink>
|
||||
<name>in</name>
|
||||
<type>complex</type>
|
||||
</sink>
|
||||
</sink>
|
||||
<sink>
|
||||
<name>pdu</name>
|
||||
<type>message</type>
|
||||
|
@ -34,4 +34,3 @@
|
|||
<type>byte</type>
|
||||
</source>
|
||||
</block>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<param>
|
||||
<name>First fill</name>
|
||||
<key>firstfill</key>
|
||||
<value>1024</value>
|
||||
<value>32</value>
|
||||
<type>int</type>
|
||||
</param>
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0"?>
|
||||
<block>
|
||||
<name>Power Sensor</name>
|
||||
<key>kcsa_power_sensor</key>
|
||||
<category>[KCSA]</category>
|
||||
<import>import kcsa</import>
|
||||
<make>kcsa.power_sensor($decim, $cal)</make>
|
||||
<param>
|
||||
<name>Decimation</name>
|
||||
<key>decim</key>
|
||||
<value>1024</value>
|
||||
<type>int</type>
|
||||
</param>
|
||||
<param>
|
||||
<name>Cal offset</name>
|
||||
<key>cal</key>
|
||||
<value>0</value>
|
||||
<type>float</type>
|
||||
</param>
|
||||
<sink>
|
||||
<name>in</name>
|
||||
<type>complex</type>
|
||||
</sink>
|
||||
<source>
|
||||
<name>out</name>
|
||||
<type>float</type>
|
||||
<optional>1</optional>
|
||||
</source>
|
||||
</block>
|
|
@ -21,7 +21,7 @@
|
|||
# Install public header files
|
||||
########################################################################
|
||||
install(FILES
|
||||
api.h
|
||||
api.h
|
||||
kiss_server.h
|
||||
ccsds_tc.h
|
||||
ccsds_udp_tc.h
|
||||
|
@ -34,6 +34,7 @@ install(FILES
|
|||
clock_recovery_gardner_cc.h
|
||||
halfduplex_tc.h
|
||||
pdu_to_stream.h
|
||||
pdu_to_stream2.h
|
||||
byte_interpolator.h
|
||||
gating_cbc.h
|
||||
afsk1200_raw_rx.h
|
||||
|
@ -43,5 +44,5 @@ install(FILES
|
|||
sync_det_b.h
|
||||
halfduplex_pdu_to_stream.h
|
||||
fullduplex_pdu_to_stream.h
|
||||
pdu_to_stream2.h DESTINATION include/kcsa
|
||||
power_sensor.h DESTINATION include/kcsa
|
||||
)
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2018 <+YOU OR YOUR COMPANY+>.
|
||||
*
|
||||
* This 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This software 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef INCLUDED_KCSA_POWER_SENSOR_H
|
||||
#define INCLUDED_KCSA_POWER_SENSOR_H
|
||||
|
||||
#include <kcsa/api.h>
|
||||
#include <gnuradio/sync_decimator.h>
|
||||
|
||||
namespace gr {
|
||||
namespace kcsa {
|
||||
|
||||
/*!
|
||||
* \brief <+description of block+>
|
||||
* \ingroup kcsa
|
||||
*
|
||||
*/
|
||||
class KCSA_API power_sensor : virtual public gr::sync_decimator
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<power_sensor> sptr;
|
||||
|
||||
/*!
|
||||
* \brief Return a shared_ptr to a new instance of kcsa::power_sensor.
|
||||
*
|
||||
* To avoid accidental use of raw pointers, kcsa::power_sensor's
|
||||
* constructor is in a private implementation
|
||||
* class. kcsa::power_sensor::make is the public interface for
|
||||
* creating new instances.
|
||||
*/
|
||||
static sptr make(int decim, float cal);
|
||||
|
||||
virtual float power() = 0;
|
||||
virtual float cal() = 0;
|
||||
virtual void set_cal(float _cal) = 0;
|
||||
};
|
||||
|
||||
} // namespace kcsa
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_KCSA_POWER_SENSOR_H */
|
|
@ -1,17 +1,17 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
/*
|
||||
* Copyright 2017 <+YOU OR YOUR COMPANY+>.
|
||||
*
|
||||
*
|
||||
* This 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
*
|
||||
* This software 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
|
@ -46,6 +46,8 @@ namespace gr {
|
|||
* class. kcsa::sync_det_b::make is the public interface for
|
||||
* creating new instances.
|
||||
*/
|
||||
|
||||
//len_mode : true = fixed, false = variable
|
||||
static sptr make(uint64_t sync_word, uint64_t sync_mask, bool len_mode, int len, uint8_t nrz, int maxerrs);
|
||||
};
|
||||
|
||||
|
@ -53,4 +55,3 @@ namespace gr {
|
|||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_KCSA_SYNC_DET_B_H */
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ list(APPEND kcsa_sources
|
|||
clock_recovery_gardner_cc_impl.cc
|
||||
halfduplex_tc_impl.cc
|
||||
pdu_to_stream_impl.cc
|
||||
pdu_to_stream2_impl.cc
|
||||
byte_interpolator_impl.cc
|
||||
gating_cbc_impl.cc
|
||||
afsk1200_raw_rx_impl.cc
|
||||
|
@ -59,7 +60,7 @@ list(APPEND kcsa_sources
|
|||
sync_det_b_impl.cc
|
||||
halfduplex_pdu_to_stream_impl.cc
|
||||
fullduplex_pdu_to_stream_impl.cc
|
||||
pdu_to_stream2_impl.cc
|
||||
power_sensor_impl.cc
|
||||
)
|
||||
|
||||
set(kcsa_sources "${kcsa_sources}" PARENT_SCOPE)
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2018 <+YOU OR YOUR COMPANY+>.
|
||||
*
|
||||
* This 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This software 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
* Copyright 2018 <+YOU OR YOUR COMPANY+>.
|
||||
*
|
||||
* This 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This software 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
|
@ -26,106 +26,109 @@
|
|||
#include "pdu_to_stream2_impl.h"
|
||||
|
||||
namespace gr {
|
||||
namespace kcsa {
|
||||
namespace kcsa {
|
||||
|
||||
pdu_to_stream2::sptr
|
||||
pdu_to_stream2::make(double decim, unsigned char filler, int firstfill)
|
||||
{
|
||||
return gnuradio::get_initial_sptr
|
||||
(new pdu_to_stream2_impl(decim, filler, firstfill));
|
||||
}
|
||||
|
||||
/*
|
||||
* The private constructor
|
||||
*/
|
||||
pdu_to_stream2_impl::pdu_to_stream2_impl(double _decim, unsigned char filler, int firstfill)
|
||||
: gr::block("pdu_to_stream2",
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex)),
|
||||
gr::io_signature::make(1, 2, sizeof(unsigned char))),
|
||||
d_decim(_decim),
|
||||
rem_samples(0)
|
||||
{
|
||||
d_pdu_port = pmt::mp("pdu");
|
||||
message_port_register_in(d_pdu_port);
|
||||
set_msg_handler(d_pdu_port, boost::bind(&pdu_to_stream2_impl::pdu_callback, this ,_1) );
|
||||
set_relative_rate(1.0 / d_decim);
|
||||
}
|
||||
|
||||
/*
|
||||
* Our virtual destructor.
|
||||
*/
|
||||
pdu_to_stream2_impl::~pdu_to_stream2_impl()
|
||||
{
|
||||
}
|
||||
|
||||
void pdu_to_stream2_impl::pdu_callback(pmt::pmt_t msg)
|
||||
{
|
||||
//pmt::pmt_t meta(pmt::car(msg));
|
||||
pmt::pmt_t data(pmt::cdr(msg));
|
||||
|
||||
//get a message, push into queue
|
||||
size_t msg_len;
|
||||
const uint8_t* bytes_in = pmt::u8vector_elements(data, msg_len);
|
||||
|
||||
gr::thread::scoped_lock guard(d_mutex);
|
||||
for(size_t i = 0; i < msg_len; i++)
|
||||
pdu_to_stream2::sptr
|
||||
pdu_to_stream2::make(double decim, unsigned char filler, int firstfill)
|
||||
{
|
||||
q.push(bytes_in[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pdu_to_stream2_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required)
|
||||
{
|
||||
double req_real = ((double)noutput_items) * d_decim;
|
||||
if(req_real > 1048576.0*64.0) req_real = 1048576.0*64.0;
|
||||
ninput_items_required[0] = floor(req_real) + 1;
|
||||
}
|
||||
|
||||
int
|
||||
pdu_to_stream2_impl::general_work (int noutput_items,
|
||||
gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
uint8_t *out = (uint8_t *) output_items[0];
|
||||
uint8_t *amp = nullptr;
|
||||
if(output_items.size())
|
||||
amp = (uint8_t *) output_items[1];
|
||||
|
||||
double possible_nout = ninput_items[0] / d_decim;
|
||||
if(possible_nout > noutput_items)
|
||||
noutput_items = floor(possible_nout);
|
||||
|
||||
//static int counter = 0;
|
||||
// Do <+signal processing+>
|
||||
for(int i = 0; i < noutput_items; i++)
|
||||
{
|
||||
gr::thread::scoped_lock guard(d_mutex);
|
||||
if(q.empty()) {
|
||||
//if(counter) {
|
||||
//std::cout << "packet " << counter << " bytes" << std::endl;
|
||||
// counter = 0;
|
||||
//}
|
||||
*out++ = d_filler;
|
||||
if(amp) *amp++ = 0;
|
||||
} else {
|
||||
//counter++;
|
||||
*out++ = q.front();
|
||||
//std::cout << (int)q.front() << ",";
|
||||
q.pop();
|
||||
if(amp) *amp++ = 1;
|
||||
}
|
||||
return gnuradio::get_initial_sptr
|
||||
(new pdu_to_stream2_impl(decim, filler, firstfill));
|
||||
}
|
||||
|
||||
rem_samples += noutput_items * d_decim;
|
||||
int to_consume = floor(rem_samples);
|
||||
rem_samples -= to_consume;
|
||||
consume_each(to_consume);
|
||||
/*
|
||||
* The private constructor
|
||||
*/
|
||||
pdu_to_stream2_impl::pdu_to_stream2_impl(double _decim, unsigned char filler, int firstfill)
|
||||
: gr::block("pdu_to_stream2",
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex)),
|
||||
gr::io_signature::make(1, 2, sizeof(unsigned char))),
|
||||
d_decim(_decim),
|
||||
to_fill(firstfill),
|
||||
rem_samples(0.0)
|
||||
{
|
||||
d_pdu_port = pmt::mp("pdu");
|
||||
message_port_register_in(d_pdu_port);
|
||||
set_msg_handler(d_pdu_port, boost::bind(&pdu_to_stream2_impl::pdu_callback, this ,_1) );
|
||||
set_relative_rate(1.0 / d_decim);
|
||||
}
|
||||
|
||||
// Tell runtime system how many output items we produced.
|
||||
return noutput_items;
|
||||
}
|
||||
/*
|
||||
* Our virtual destructor.
|
||||
*/
|
||||
pdu_to_stream2_impl::~pdu_to_stream2_impl()
|
||||
{
|
||||
}
|
||||
|
||||
} /* namespace kcsa */
|
||||
} /* namespace gr */
|
||||
void pdu_to_stream2_impl::pdu_callback(pmt::pmt_t msg)
|
||||
{
|
||||
//pmt::pmt_t meta(pmt::car(msg));
|
||||
pmt::pmt_t data(pmt::cdr(msg));
|
||||
|
||||
//get a message, push into queue
|
||||
size_t msg_len;
|
||||
const uint8_t* bytes_in = pmt::u8vector_elements(data, msg_len);
|
||||
|
||||
gr::thread::scoped_lock guard(d_mutex);
|
||||
for(size_t i = 0; i < msg_len; i++)
|
||||
{
|
||||
q.push(bytes_in[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pdu_to_stream2_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required)
|
||||
{
|
||||
double req_real = ((double)noutput_items) * d_decim;
|
||||
//if(req_real > 1048576.0*64.0) req_real = 1048576.0*64.0;
|
||||
ninput_items_required[0] = floor(req_real) + 1;
|
||||
}
|
||||
|
||||
int
|
||||
pdu_to_stream2_impl::general_work (int noutput_items,
|
||||
gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
uint8_t *out = (uint8_t *) output_items[0];
|
||||
uint8_t *amp = NULL;
|
||||
if(output_items.size() > 1)
|
||||
amp = (uint8_t *) output_items[1];
|
||||
|
||||
#define MIN(X, Y) (X < Y ? X : Y)
|
||||
noutput_items = MIN(floor(ninput_items[0] / d_decim), noutput_items);
|
||||
|
||||
if(to_fill > 0) {
|
||||
int i;
|
||||
for(i = 0; i < MIN(noutput_items, to_fill); i++)
|
||||
{
|
||||
*out++ = d_filler;
|
||||
if(amp) *amp++ = 0;
|
||||
}
|
||||
to_fill -= i;
|
||||
return i;
|
||||
} else {
|
||||
// Do <+signal processing+>
|
||||
for(int i = 0; i < noutput_items; i++)
|
||||
{
|
||||
gr::thread::scoped_lock guard(d_mutex);
|
||||
if(q.empty()) {
|
||||
*out++ = d_filler;
|
||||
if(amp) *amp++ = 0;
|
||||
} else {
|
||||
*out++ = q.front();
|
||||
q.pop();
|
||||
if(amp) *amp++ = 1;
|
||||
}
|
||||
}
|
||||
rem_samples += noutput_items * d_decim;
|
||||
int to_consume = floor(rem_samples);
|
||||
rem_samples -= to_consume;
|
||||
consume_each(to_consume);
|
||||
}
|
||||
//std::cout << nitems_read(0) << ", " << nitems_written(0) << std::endl;
|
||||
// Tell runtime system how many output items we produced.
|
||||
return noutput_items;
|
||||
}
|
||||
|
||||
} /* namespace kcsa */
|
||||
} /* namespace gr */
|
||||
|
|
|
@ -38,7 +38,8 @@ namespace gr {
|
|||
//message input buffer
|
||||
std::queue<uint8_t> q;
|
||||
gr::thread::mutex d_mutex;
|
||||
double rem_samples;
|
||||
int to_fill;
|
||||
long double rem_samples;
|
||||
|
||||
void pdu_callback(pmt::pmt_t msg);
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
/*
|
||||
* Copyright 2016 <+YOU OR YOUR COMPANY+>.
|
||||
*
|
||||
*
|
||||
* This 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
*
|
||||
* This software 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
|
@ -41,7 +41,8 @@ namespace gr {
|
|||
pdu_to_stream_impl::pdu_to_stream_impl(int decim, uint8_t filler)
|
||||
: gr::sync_decimator("pdu_to_stream",
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex)),
|
||||
gr::io_signature::make(2, 2, sizeof(uint8_t)), decim)
|
||||
gr::io_signature::make(2, 2, sizeof(uint8_t)), decim),
|
||||
d_filler(filler)
|
||||
{
|
||||
d_pdu_port = pmt::mp("pdu");
|
||||
message_port_register_in(d_pdu_port);
|
||||
|
@ -66,7 +67,7 @@ namespace gr {
|
|||
|
||||
gr::thread::scoped_lock guard(d_mutex);
|
||||
for(size_t i = 0; i < msg_len; i++)
|
||||
{
|
||||
{
|
||||
q.push(bytes_in[i]);
|
||||
}
|
||||
}
|
||||
|
@ -106,4 +107,3 @@ namespace gr {
|
|||
|
||||
} /* namespace kcsa */
|
||||
} /* namespace gr */
|
||||
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2018 <+YOU OR YOUR COMPANY+>.
|
||||
*
|
||||
* This 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This software 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <gnuradio/config.h>
|
||||
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include "power_sensor_impl.h"
|
||||
#include <volk/volk.h>
|
||||
#include <gnuradio/rpcregisterhelpers.h>
|
||||
|
||||
#ifndef GR_CTRLPORT
|
||||
#error "gr-ctrlport must be enabled"
|
||||
#endif
|
||||
|
||||
namespace gr {
|
||||
namespace kcsa {
|
||||
|
||||
power_sensor::sptr
|
||||
power_sensor::make(int decim, float cal)
|
||||
{
|
||||
return gnuradio::get_initial_sptr
|
||||
(new power_sensor_impl(decim, cal));
|
||||
}
|
||||
|
||||
/*
|
||||
* The private constructor
|
||||
*/
|
||||
power_sensor_impl::power_sensor_impl(int decim, float _cal)
|
||||
: gr::sync_decimator("power_sensor",
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex)),
|
||||
gr::io_signature::make(0, 1, sizeof(float)), decim),
|
||||
result(0),
|
||||
d_cal(_cal)
|
||||
{
|
||||
magsqr = (float*)volk_malloc(sizeof(float) * decim, volk_get_alignment());
|
||||
sumout = (float*)volk_malloc(sizeof(float), volk_get_alignment());
|
||||
}
|
||||
|
||||
/*
|
||||
* Our virtual destructor.
|
||||
*/
|
||||
power_sensor_impl::~power_sensor_impl()
|
||||
{
|
||||
volk_free(magsqr);
|
||||
volk_free(sumout);
|
||||
}
|
||||
|
||||
void power_sensor_impl::setup_rpc()
|
||||
{
|
||||
//#ifdef GR_CTRLPORT
|
||||
add_rpc_variable(
|
||||
rpcbasic_sptr(new rpcbasic_register_get<power_sensor, float>(
|
||||
alias(), "power",
|
||||
&power_sensor::power,
|
||||
pmt::mp(-300.0), pmt::mp(100.0), pmt::mp(-300.0),
|
||||
"dBW", "Get power readout", RPC_PRIVLVL_MIN,
|
||||
DISPTIME)));
|
||||
|
||||
add_rpc_variable(
|
||||
rpcbasic_sptr(new rpcbasic_register_get<power_sensor, float>(
|
||||
alias(), "cal",
|
||||
&power_sensor::cal,
|
||||
pmt::mp(-300.0), pmt::mp(300.0), pmt::mp(0.0),
|
||||
"dB", "Get cal offset", RPC_PRIVLVL_MIN,
|
||||
DISPNULL)));
|
||||
|
||||
add_rpc_variable(
|
||||
rpcbasic_sptr(new rpcbasic_register_set<power_sensor, float>(
|
||||
alias(), "cal",
|
||||
&power_sensor::set_cal,
|
||||
pmt::mp(-300.0), pmt::mp(300.0), pmt::mp(0.0),
|
||||
"dB", "Set cal offset", RPC_PRIVLVL_MIN,
|
||||
DISPNULL)));
|
||||
//#endif /* GR_CTRLPORT */
|
||||
}
|
||||
|
||||
int
|
||||
power_sensor_impl::work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
const gr_complex *in = (const gr_complex *) input_items[0];
|
||||
float *out = NULL;
|
||||
if(output_items.size()) out = (float *) output_items[0];
|
||||
|
||||
// Do <+signal processing+>
|
||||
for(int i = 0; i < noutput_items; i++) {
|
||||
volk_32fc_magnitude_squared_32f(magsqr, in, decimation());
|
||||
volk_32f_accumulator_s32f(sumout, magsqr, decimation());
|
||||
in += decimation();
|
||||
result = 10.0 * log10( *sumout / decimation());
|
||||
if(out) *out++ = result;
|
||||
}
|
||||
|
||||
// Tell runtime system how many output items we produced.
|
||||
return noutput_items;
|
||||
}
|
||||
|
||||
} /* namespace kcsa */
|
||||
} /* namespace gr */
|
|
@ -0,0 +1,54 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2018 <+YOU OR YOUR COMPANY+>.
|
||||
*
|
||||
* This 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This software 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_KCSA_POWER_SENSOR_IMPL_H
|
||||
#define INCLUDED_KCSA_POWER_SENSOR_IMPL_H
|
||||
|
||||
#include <kcsa/power_sensor.h>
|
||||
|
||||
namespace gr {
|
||||
namespace kcsa {
|
||||
|
||||
class power_sensor_impl : public power_sensor
|
||||
{
|
||||
private:
|
||||
float *magsqr, *sumout;
|
||||
float result, d_cal;
|
||||
|
||||
public:
|
||||
power_sensor_impl(int decim, float cal);
|
||||
~power_sensor_impl();
|
||||
|
||||
float power() { return result + d_cal; }
|
||||
float cal() { return d_cal; }
|
||||
void set_cal(float _cal) { d_cal = _cal; }
|
||||
|
||||
void setup_rpc();
|
||||
|
||||
// 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 kcsa
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_KCSA_POWER_SENSOR_IMPL_H */
|
|
@ -20,6 +20,7 @@
|
|||
#include "kcsa/clock_recovery_gardner_cc.h"
|
||||
#include "kcsa/halfduplex_tc.h"
|
||||
#include "kcsa/pdu_to_stream.h"
|
||||
#include "kcsa/pdu_to_stream2.h"
|
||||
#include "kcsa/byte_interpolator.h"
|
||||
#include "kcsa/gating_cbc.h"
|
||||
#include "kcsa/afsk1200_raw_rx.h"
|
||||
|
@ -29,7 +30,7 @@
|
|||
#include "kcsa/sync_det_b.h"
|
||||
#include "kcsa/halfduplex_pdu_to_stream.h"
|
||||
#include "kcsa/fullduplex_pdu_to_stream.h"
|
||||
#include "kcsa/pdu_to_stream2.h"
|
||||
#include "kcsa/power_sensor.h"
|
||||
%}
|
||||
|
||||
%include "kcsa/kiss_server.h"
|
||||
|
@ -54,6 +55,9 @@ GR_SWIG_BLOCK_MAGIC2(kcsa, clock_recovery_gardner_ff);
|
|||
GR_SWIG_BLOCK_MAGIC2(kcsa, clock_recovery_gardner_cc);
|
||||
%include "kcsa/halfduplex_tc.h"
|
||||
GR_SWIG_BLOCK_MAGIC2(kcsa, halfduplex_tc);
|
||||
%include "kcsa/power_sensor.h"
|
||||
GR_SWIG_BLOCK_MAGIC2(kcsa, power_sensor);
|
||||
|
||||
|
||||
|
||||
%include "kcsa/pdu_to_stream.h"
|
||||
|
|
Loading…
Reference in New Issue