- added and modified

git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@505 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-05-29 13:23:48 +00:00
parent 478a12b4a2
commit 4c255bf3ff
8 changed files with 163 additions and 32 deletions
+26 -19
View File
@@ -64,12 +64,6 @@ namespace gr {
pmt::pmt_t key = pmt::car(pair);
pmt::pmt_t val = pmt::cdr(pair);
if (pmt::symbol_to_string(key) == std::string("gain"))
{
float gain_dB = pmt::to_float(val) - 50.f;
m_gain_target = std::pow(10.f, gain_dB/10);
fprintf(stderr, "Set gain to %0.2f\n", m_gain_target);
}
if (pmt::is_integer(val))
{
fprintf(stderr, "[%s=%d]", pmt::symbol_to_string(key).c_str(), (int)pmt::to_long(val));
@@ -84,25 +78,38 @@ namespace gr {
}
fprintf(stderr, "\n");
}
void squelch_impl::check_pair(pmt::pmt_t pair)
{
pmt::pmt_t key = pmt::car(pair);
pmt::pmt_t val = pmt::cdr(pair);
// Check pair for data
if (pmt::symbol_to_string(key) == std::string("gain"))
{
float gain_dB = pmt::to_float(val) - 40.f;
m_gain_target = std::pow(10.f, gain_dB/10);
}
}
void squelch_impl::on_message(pmt::pmt_t msg)
{
if (pmt::is_pair(msg))
{
print_pair(msg);
}
else if (pmt::is_dict(msg))
if (pmt::is_dict(msg))
{
pmt::pmt_t items = pmt::dict_items(msg);
for (int i=0; i < pmt::length(items); i++)
{
pmt::pmt_t pair = pmt::nth(i, items);
print_pair(pair);
try
{
size_t len_items = pmt::length(items);
for (int i=0; i < len_items; i++)
{
pmt::pmt_t pair = pmt::nth(i, items);
check_pair(pair);
}
}
catch (const std::exception& e)
{
check_pair(msg);
}
}
else
{
fprintf(stderr, "%s\n", pmt::symbol_to_string(msg).c_str());
}
}
+1
View File
@@ -39,6 +39,7 @@ namespace gr {
~squelch_impl();
void print_pair(pmt::pmt_t pair);
void on_message(pmt::pmt_t msg);
void check_pair(pmt::pmt_t pair);
// Where all the action really happens
int work(int noutput_items,