Skip to content

Commit

Permalink
Initialise OOK modulator rate limiting on first call.
Browse files Browse the repository at this point in the history
  • Loading branch information
zynaptic committed Jun 20, 2018
1 parent 92dddaf commit c865445
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions gnuradio/gr-scratch_radio/lib/ook_modulator_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ namespace gr {
gr::io_signature::make(1, 1, sizeof(uint8_t)),
gr::io_signature::make(1, 1, sizeof(gr_complex)))
{
struct timespec ts_now;
d_sample_rate = sample_rate;
d_sample_count = 0;
d_current_symbol = 0;
clock_gettime (CLOCK_MONOTONIC, &ts_now);
d_timestamp = (int64_t) ts_now.tv_sec * 1000000000 + ts_now.tv_nsec;
d_timestamp = 0;
d_first_call = true;

// Build the table of modulated symbol samples.
d_symbol_length = sample_rate / baud_rate;
Expand Down Expand Up @@ -83,6 +82,7 @@ namespace gr {
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
struct timespec ts_now;
const uint8_t *in = (const uint8_t *) input_items[0];
gr_complex *out = (gr_complex *) output_items[0];
int in_i = 0;
Expand All @@ -91,8 +91,12 @@ namespace gr {
// Perform basic output rate limiting to prevent transmit buffer
// bloat. This approach should be replaced by proper output buffer
// latency management when possible. Stalls on idle cycles only.
if (d_first_call) {
d_first_call = false;
clock_gettime (CLOCK_MONOTONIC, &ts_now);
d_timestamp = (int64_t) ts_now.tv_sec * 1000000000 + ts_now.tv_nsec;
}
if (in[0] == 0xFF) {
struct timespec ts_now;
int64_t now;
clock_gettime (CLOCK_MONOTONIC, &ts_now);
now = (int64_t) ts_now.tv_sec * 1000000000 + ts_now.tv_nsec;
Expand Down
3 changes: 2 additions & 1 deletion gnuradio/gr-scratch_radio/lib/ook_modulator_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <scratch_radio/ook_modulator.h>

#define OUTPUT_LATENCY 1000
#define OUTPUT_LATENCY 250

namespace gr {
namespace scratch_radio {
Expand All @@ -35,6 +35,7 @@ namespace gr {
int d_sample_count;
int d_current_symbol;
int64_t d_timestamp;
bool d_first_call;
int d_symbol_length;
gr_complex* d_sample_table;

Expand Down

0 comments on commit c865445

Please sign in to comment.