Message Is Disabling Work Function in Sync Block

2022-11-14 Thread Alon Simon Levin
I am trying to implement a relatively simple block that acts as a
message-enabled timed gate. The block has one stream input, one stream
output, and one input message port for control. The block diagram is shown
here:

#   #
# Signal source # > #   Enable  # > [OUTPUT]
#   #   Timed   #
  MSG > #   Burst   #
#

I want the block to output an all-zero stream until it receives the
message, at which point it should output whatever samples are being sent in
for a fixed number of samples. For some reason though, whenever the block
receives a message, the work function is no longer called. None of the
debug messages in the work function are printed to console, and I do not
see any more samples being outputted from the block. However, the
message-reception block ("on_enable") continues to be called every time a
new message comes in.

I couldn't find any mention of this happening before on the mailing list or
forums. If anyone can shed any light on why this is happening or can give
any advice as to a better way to implement this, it would be really
appreciated. The relevant components of my code are below:

/* The private constructor */
enable_timed_burst_impl::enable_timed_burst_impl(bool debug, int
burst_length)
: gr::sync_block("enable_timed_burst",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex))),
d_debug(debug),
d_burst_length(burst_length),
enable_msg_in_port_name(pmt::mp("enable_msg_in"))
{
// Set enable status to false
enable_burst = false;
//sample_counter = 0;

// Prepare control message port
message_port_register_in(enable_msg_in_port_name);
set_msg_handler(enable_msg_in_port_name,
boost::bind(&enable_timed_burst_impl::on_enable, this, _1));
}

/* On "enable" message */
void enable_timed_burst_impl::on_enable(pmt::pmt_t msg)
{
// Set enable status to true
enable_burst = true;
debug_out("Burst enabled.");
return;
}

/* Work */
int enable_timed_burst_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
debug_out("Work called.");

// Input and output streams
const gr_complex *in = (const gr_complex *)input_items[0];
gr_complex *out = (gr_complex *)output_items[0];

// Number of output and input items is always the burst length
noutput_items = d_burst_length;

// If burst enabled, pass the output; otherwise, pass zeroes
if (enable_burst) {
debug_out("I reached here!");
for (int ticker = 0; ticker < d_burst_length; ticker++)
out[ticker] = in[ticker];

enable_burst = false;
debug_out("Burst disabled.");
}
else {
for (int ticker = 0; ticker < d_burst_length; ticker++)
out[ticker] = 0;
debug_out("Nothing...");
}

// Tell runtime system how many output items we produced.
return noutput_items;
}

Thanks,
Alon


-- 
*Alon S. Levin*
Ph.D. Student
Wireless & Mobile Networking Lab, Columbia University
alon.s.le...@columbia.edu | (347) 225-7433


Message Is Disabling Work Function in Sync Block

2022-11-14 Thread Alon Simon Levin
I am trying to implement a relatively simple block that acts as a
message-enabled timed gate. The block has one stream input, one stream
output, and one input message port for control. The block diagram is shown
here:

#   #
# Signal source # > #   Enable  # > [OUTPUT]
#   #   Timed   #
  MSG > #   Burst   #
#

I want the block to output an all-zero stream until it receives the
message, at which point it should output whatever samples are being sent in
for a fixed number of samples. For some reason though, whenever the block
receives a message, the work function is no longer called. None of the
debug messages in the work function are printed to console, and I do not
see any more samples being outputted from the block. However, the
message-reception block ("on_enable") continues to be called every time a
new message comes in.

I couldn't find any mention of this happening before on the mailing list or
forums. If anyone can shed any light on why this is happening or can give
any advice as to a better way to implement this, it would be really
appreciated. The relevant components of my code are below:

/* The private constructor */
enable_timed_burst_impl::enable_timed_burst_impl(bool debug, int
burst_length)
: gr::sync_block("enable_timed_burst",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex))),
d_debug(debug),
d_burst_length(burst_length),
enable_msg_in_port_name(pmt::mp("enable_msg_in"))
{
// Set enable status to false
enable_burst = false;
//sample_counter = 0;

// Prepare control message port
message_port_register_in(enable_msg_in_port_name);
set_msg_handler(enable_msg_in_port_name,
boost::bind(&enable_timed_burst_impl::on_enable, this, _1));
}

/* On "enable" message */
void enable_timed_burst_impl::on_enable(pmt::pmt_t msg)
{
// Set enable status to true
enable_burst = true;
debug_out("Burst enabled.");
return;
}

/* Work */
int enable_timed_burst_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
debug_out("Work called.");

// Input and output streams
const gr_complex *in = (const gr_complex *)input_items[0];
gr_complex *out = (gr_complex *)output_items[0];

// Number of output and input items is always the burst length
noutput_items = d_burst_length;

// If burst enabled, pass the output; otherwise, pass zeroes
if (enable_burst) {
debug_out("I reached here!");
for (int ticker = 0; ticker < d_burst_length; ticker++)
out[ticker] = in[ticker];

enable_burst = false;
debug_out("Burst disabled.");
}
else {
for (int ticker = 0; ticker < d_burst_length; ticker++)
out[ticker] = 0;
debug_out("Nothing...");
}

// Tell runtime system how many output items we produced.
return noutput_items;
}

Thanks,
Alon


VS Code for QA Tests

2022-11-14 Thread Jeff S
I have been using VS Code for debugging code according to 
https://wiki.gnuradio.org/index.php/UsingVSCode.  I thought I would try doing 
the same thing but using the Python QA tests to start the code rather than the 
flow graph Python.  I can't seem to get the C++ code to break when using the QA 
Test as starting point and just wondered if anyone could, and what the 
launch.json configuration was for doing that.  I've tried both launching from 
VS Code and attaching to a process with the same results.

I'm currently at GR v3.9.5.0 and VSC v1.73.

Regards,
Jeff


Message Is Disabling Work Function in Sync Block

2022-11-14 Thread Alon Simon Levin
Apologies if this has been sent multiple times; I've been having issues
with my mailing list subscription.

I am trying to implement a relatively simple block that acts as a
message-enabled timed gate. The block has one stream input, one stream
output, and one input message port for control. The block diagram is shown
here:

#   #
# Signal source # > #   Enable  # > [OUTPUT]
#   #   Timed   #
  MSG > #   Burst   #
#

I want the block to output an all-zero stream until it receives the
message, at which point it should output whatever samples are being sent in
for a fixed number of samples. For some reason though, whenever the block
receives a message, the work function is no longer called. None of the
debug messages in the work function are printed to console, and I do not
see any more samples being outputted from the block. However, the
message-reception block ("on_enable") continues to be called every time a
new message comes in.

I couldn't find any mention of this happening before on the mailing list or
forums. If anyone can shed any light on why this is happening or can give
any advice as to a better way to implement this, it would be really
appreciated. The relevant components of my code are below:

/* The private constructor */
enable_timed_burst_impl::enable_timed_burst_impl(bool debug, int
burst_length)
: gr::sync_block("enable_timed_burst",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex))),
d_debug(debug),
d_burst_length(burst_length),
enable_msg_in_port_name(pmt::mp("enable_msg_in"))
{
// Set enable status to false
enable_burst = false;
//sample_counter = 0;

// Prepare control message port
message_port_register_in(enable_msg_in_port_name);
set_msg_handler(enable_msg_in_port_name,
boost::bind(&enable_timed_burst_impl::on_enable, this, _1));
}

/* On "enable" message */
void enable_timed_burst_impl::on_enable(pmt::pmt_t msg)
{
// Set enable status to true
enable_burst = true;
debug_out("Burst enabled.");
return;
}

/* Work */
int enable_timed_burst_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
debug_out("Work called.");

// Input and output streams
const gr_complex *in = (const gr_complex *)input_items[0];
gr_complex *out = (gr_complex *)output_items[0];

// Number of output and input items is always the burst length
noutput_items = d_burst_length;

// If burst enabled, pass the output; otherwise, pass zeroes
if (enable_burst) {
debug_out("I reached here!");
for (int ticker = 0; ticker < d_burst_length; ticker++)
out[ticker] = in[ticker];

enable_burst = false;
debug_out("Burst disabled.");
}
else {
for (int ticker = 0; ticker < d_burst_length; ticker++)
out[ticker] = 0;
debug_out("Nothing...");
}

// Tell runtime system how many output items we produced.
return noutput_items;
}

Thanks,
Alon