summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/general/gri_agc2_cc.i5
-rw-r--r--gnuradio-core/src/lib/general/gri_agc2_ff.i10
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink.cc3
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink_base.cc6
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink_base.h7
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink_base.i5
-rw-r--r--gnuradio-core/src/lib/io/gr_oscope_guts.cc69
-rw-r--r--gnuradio-core/src/lib/io/gr_trigger_mode.h1
-rw-r--r--gnuradio-core/src/lib/runtime/Makefile.am1
-rw-r--r--gnuradio-core/src/lib/runtime/gr_unittests.h70
10 files changed, 150 insertions, 27 deletions
diff --git a/gnuradio-core/src/lib/general/gri_agc2_cc.i b/gnuradio-core/src/lib/general/gri_agc2_cc.i
index e7d6da97f..0f97f1d8e 100644
--- a/gnuradio-core/src/lib/general/gri_agc2_cc.i
+++ b/gnuradio-core/src/lib/general/gri_agc2_cc.i
@@ -39,4 +39,9 @@ class gri_agc2_cc {
float reference ();
float gain ();
float max_gain ();
+ void set_decay_rate (float rate);
+ void set_attack_rate (float rate);
+ void set_reference (float reference);
+ void set_gain (float gain);
+ void set_max_gain(float max_gain);
};
diff --git a/gnuradio-core/src/lib/general/gri_agc2_ff.i b/gnuradio-core/src/lib/general/gri_agc2_ff.i
index 3825ce225..d04b638a6 100644
--- a/gnuradio-core/src/lib/general/gri_agc2_ff.i
+++ b/gnuradio-core/src/lib/general/gri_agc2_ff.i
@@ -34,4 +34,14 @@ class gri_agc2_ff {
public:
gri_agc2_ff (float attack_rate = 1e-1, float decay_rate = 1e-2,
float reference = 1.0, float gain = 1.0, float max_gain = 0.0);
+ float attack_rate ();
+ float decay_rate ();
+ float reference ();
+ float gain ();
+ float max_gain ();
+ void set_attack_rate (float rate);
+ void set_decay_rate (float rate);
+ void set_reference (float reference);
+ void set_gain (float gain);
+ void set_max_gain (float max_gain);
};
diff --git a/gnuradio-core/src/lib/io/gr_file_sink.cc b/gnuradio-core/src/lib/io/gr_file_sink.cc
index 706837c7a..aab0158e7 100644
--- a/gnuradio-core/src/lib/io/gr_file_sink.cc
+++ b/gnuradio-core/src/lib/io/gr_file_sink.cc
@@ -70,5 +70,8 @@ gr_file_sink::work (int noutput_items,
nwritten += count;
inbuf += count * d_itemsize;
}
+ if (d_unbuffered)
+ fflush (d_fp);
+
return nwritten;
}
diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.cc b/gnuradio-core/src/lib/io/gr_file_sink_base.cc
index 5ddeeb4d5..c43304b0d 100644
--- a/gnuradio-core/src/lib/io/gr_file_sink_base.cc
+++ b/gnuradio-core/src/lib/io/gr_file_sink_base.cc
@@ -118,3 +118,9 @@ gr_file_sink_base::do_update()
d_updated = false;
}
}
+
+void
+gr_file_sink_base::set_unbuffered(bool unbuffered)
+{
+ d_unbuffered = unbuffered;
+}
diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.h b/gnuradio-core/src/lib/io/gr_file_sink_base.h
index 0c028d7fd..7b96cdb7f 100644
--- a/gnuradio-core/src/lib/io/gr_file_sink_base.h
+++ b/gnuradio-core/src/lib/io/gr_file_sink_base.h
@@ -37,6 +37,7 @@ class gr_file_sink_base
bool d_updated; // is there a new FILE pointer?
bool d_is_binary;
boost::mutex d_mutex;
+ bool d_unbuffered;
protected:
gr_file_sink_base(const char *filename, bool is_binary);
@@ -61,6 +62,12 @@ class gr_file_sink_base
* \brief if we've had an update, do it now.
*/
void do_update();
+
+
+ /*!
+ * \brief turn on unbuffered writes for slower outputs
+ */
+ void set_unbuffered(bool unbuffered);
};
diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.i b/gnuradio-core/src/lib/io/gr_file_sink_base.i
index 05a3353bb..ed4342482 100644
--- a/gnuradio-core/src/lib/io/gr_file_sink_base.i
+++ b/gnuradio-core/src/lib/io/gr_file_sink_base.i
@@ -43,4 +43,9 @@ class gr_file_sink_base
* \brief if we've had an update, do it now.
*/
void do_update();
+
+ /*!
+ *\brief turn on unbuffered mode for slow outputs
+ */
+ void set_unbuffered(bool unbuffered);
};
diff --git a/gnuradio-core/src/lib/io/gr_oscope_guts.cc b/gnuradio-core/src/lib/io/gr_oscope_guts.cc
index 80f78240d..ce7feca13 100644
--- a/gnuradio-core/src/lib/io/gr_oscope_guts.cc
+++ b/gnuradio-core/src/lib/io/gr_oscope_guts.cc
@@ -104,34 +104,49 @@ gr_oscope_guts::process_sample (const float *channel_data)
d_decimator_count = d_decimator_count_init;
- for (int i = 0; i < d_nchannels; i++)
- d_buffer[i][d_obi] = channel_data[i]; // copy data into buffer
-
- switch (d_state){
- case HOLD_OFF:
- d_hold_off_count--;
- if (d_hold_off_count <= 0)
- enter_look_for_trigger ();
- break;
-
- case LOOK_FOR_TRIGGER:
- if (found_trigger ())
- enter_post_trigger ();
- break;
-
- case POST_TRIGGER:
- d_post_trigger_count--;
- if (d_post_trigger_count <= 0){
- write_output_records ();
- enter_hold_off ();
- }
- break;
-
- default:
- assert (0);
+ if (d_trigger_mode != gr_TRIG_MODE_STRIPCHART)
+ {
+ for (int i = 0; i < d_nchannels; i++)
+ d_buffer[i][d_obi] = channel_data[i]; // copy data into buffer
+
+ switch (d_state){
+ case HOLD_OFF:
+ d_hold_off_count--;
+ if (d_hold_off_count <= 0)
+ enter_look_for_trigger ();
+ break;
+
+ case LOOK_FOR_TRIGGER:
+ if (found_trigger ())
+ enter_post_trigger ();
+ break;
+
+ case POST_TRIGGER:
+ d_post_trigger_count--;
+ if (d_post_trigger_count <= 0){
+ write_output_records ();
+ enter_hold_off ();
+ }
+ break;
+
+ default:
+ assert (0);
+ }
+
+ d_obi = incr_bi (d_obi);
+ }
+ else
+ {
+ for (int i = 0; i < d_nchannels; i++)
+ {
+ for (int j = OUTPUT_RECORD_SIZE-1; j >= 0; j--)
+ {
+ d_buffer[i][j] = d_buffer[i][j-1];
+ }
+ d_buffer[i][0] = channel_data[i];
+ }
+ write_output_records();
}
-
- d_obi = incr_bi (d_obi);
}
/*
diff --git a/gnuradio-core/src/lib/io/gr_trigger_mode.h b/gnuradio-core/src/lib/io/gr_trigger_mode.h
index 63f6b1c98..8e1222856 100644
--- a/gnuradio-core/src/lib/io/gr_trigger_mode.h
+++ b/gnuradio-core/src/lib/io/gr_trigger_mode.h
@@ -27,6 +27,7 @@ enum gr_trigger_mode {
gr_TRIG_MODE_FREE,
gr_TRIG_MODE_AUTO,
gr_TRIG_MODE_NORM,
+ gr_TRIG_MODE_STRIPCHART,
};
enum gr_trigger_slope {
diff --git a/gnuradio-core/src/lib/runtime/Makefile.am b/gnuradio-core/src/lib/runtime/Makefile.am
index b0e804277..abd789a1d 100644
--- a/gnuradio-core/src/lib/runtime/Makefile.am
+++ b/gnuradio-core/src/lib/runtime/Makefile.am
@@ -120,6 +120,7 @@ grinclude_HEADERS = \
gr_timer.h \
gr_tmp_path.h \
gr_types.h \
+ gr_unittests.h \
gr_vmcircbuf.h
noinst_HEADERS = \
diff --git a/gnuradio-core/src/lib/runtime/gr_unittests.h b/gnuradio-core/src/lib/runtime/gr_unittests.h
new file mode 100644
index 000000000..680e59ca4
--- /dev/null
+++ b/gnuradio-core/src/lib/runtime/gr_unittests.h
@@ -0,0 +1,70 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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.
+ *
+ * GNU Radio 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 GNU Radio; 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"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+
+#ifdef MKDIR_TAKES_ONE_ARG
+#define gr_mkdir(pathname, mode) mkdir(pathname)
+#else
+#define gr_mkdir(pathname, mode) mkdir((pathname), (mode))
+#endif
+
+/*
+ * Mostly taken from gr_preferences.cc/h
+ * The simplest thing that could possibly work:
+ * the key is the filename; the value is the file contents.
+ */
+
+static void
+ensure_unittest_path (const char *grpath, const char *path)
+{
+ struct stat statbuf;
+ if (stat (path, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
+ return;
+
+ // blindly try to make it // FIXME make this robust. C++ SUCKS!
+ gr_mkdir (grpath, 0750);
+ gr_mkdir (path, 0750);
+}
+
+static void
+get_unittest_path (const char *filename, char *fullpath, size_t pathsize)
+{
+ char path[200];
+ char grpath[200];
+ snprintf (grpath, sizeof(grpath), "%s/.gnuradio", getenv ("HOME"));
+ snprintf (path, sizeof(path), "%s/unittests", grpath);
+ snprintf (fullpath, pathsize, "%s/%s", path, filename);
+
+ ensure_unittest_path(grpath, path);
+}
+