[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/16: controlport: fixed controlport probe
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/16: controlport: fixed controlport probes. |
Date: |
Sun, 26 Apr 2015 23:18:02 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 3ea2feb63abcd15802d1b5d2cf2d3402ca86616c
Author: Tom Rondeau <address@hidden>
Date: Tue Apr 14 16:07:48 2015 -0400
controlport: fixed controlport probes.
---
gr-blocks/lib/ctrlport_probe2_b_impl.cc | 30 ++++++++++++++++++------------
gr-blocks/lib/ctrlport_probe2_b_impl.h | 2 +-
gr-blocks/lib/ctrlport_probe2_c_impl.cc | 30 ++++++++++++++++++------------
gr-blocks/lib/ctrlport_probe2_c_impl.h | 1 +
gr-blocks/lib/ctrlport_probe2_f_impl.cc | 31 ++++++++++++++++++-------------
gr-blocks/lib/ctrlport_probe2_f_impl.h | 1 +
gr-blocks/lib/ctrlport_probe2_i_impl.cc | 31 +++++++++++++++++++------------
gr-blocks/lib/ctrlport_probe2_i_impl.h | 1 +
gr-blocks/lib/ctrlport_probe2_s_impl.cc | 27 ++++++++++++++++-----------
gr-blocks/lib/ctrlport_probe2_s_impl.h | 1 +
10 files changed, 94 insertions(+), 61 deletions(-)
diff --git a/gr-blocks/lib/ctrlport_probe2_b_impl.cc
b/gr-blocks/lib/ctrlport_probe2_b_impl.cc
index 3cf2ae0..996e997 100644
--- a/gr-blocks/lib/ctrlport_probe2_b_impl.cc
+++ b/gr-blocks/lib/ctrlport_probe2_b_impl.cc
@@ -64,21 +64,26 @@ namespace gr {
}
std::vector<signed char>
- ctrlport_probe2_b_impl::get() {
+ ctrlport_probe2_b_impl::get()
+ {
return buffered_get.get();
}
void
ctrlport_probe2_b_impl::set_length(int len)
{
+ gr::thread::scoped_lock guard(d_setlock);
+
if(len > 8191) {
- std::cerr << "probe2_b: length " << len
- << " exceeds maximum buffer size of 8191" << std::endl;
+ GR_LOG_WARN(d_logger,
+ boost::format("probe2_b: length %1% exceeds maximum"
+ " buffer size of 8191") % len);
len = 8191;
}
d_len = len;
- d_buffer.reserve(d_len);
+ d_buffer.resize(d_len);
+ d_index = 0;
}
int
@@ -94,20 +99,21 @@ namespace gr {
{
const char *in = (const char*)input_items[0];
+ gr::thread::scoped_lock guard(d_setlock);
+
// copy samples to get buffer if we need samples
- if(d_buffer.size() < d_len) {
+ if(d_index < d_len) {
// copy smaller of remaining buffer space and num inputs to work()
- int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items
);
+ int num_copy = std::min( (int)(d_len - d_index), noutput_items );
- // TODO: convert this to a copy operator for speed...
- for(int i = 0; i < num_copy; i++) {
- d_buffer.push_back(in[i]);
- }
+ memcpy(&d_buffer[d_index], in, num_copy*sizeof(char));
+ d_index += num_copy;
}
// notify the waiting get() if we fill up the buffer
- if(d_buffer.size() == d_len) {
- buffered_get.offer_data(d_buffer);
+ if(d_index == d_len) {
+ buffered_get.offer_data(d_buffer);
+ d_index = 0;
}
return noutput_items;
diff --git a/gr-blocks/lib/ctrlport_probe2_b_impl.h
b/gr-blocks/lib/ctrlport_probe2_b_impl.h
index 490af9b..165f0d3 100644
--- a/gr-blocks/lib/ctrlport_probe2_b_impl.h
+++ b/gr-blocks/lib/ctrlport_probe2_b_impl.h
@@ -38,6 +38,7 @@ namespace gr {
size_t d_len;
unsigned int d_disp_mask;
+ size_t d_index;
std::vector<signed char> d_buffer;
rpcbufferedget< std::vector<signed char> > buffered_get;
@@ -64,4 +65,3 @@ namespace gr {
} /* namespace gr */
#endif /* INCLUDED_CTRLPORT_PROBE2_C_IMPL_H */
-
diff --git a/gr-blocks/lib/ctrlport_probe2_c_impl.cc
b/gr-blocks/lib/ctrlport_probe2_c_impl.cc
index bd43130..b8ed0af 100644
--- a/gr-blocks/lib/ctrlport_probe2_c_impl.cc
+++ b/gr-blocks/lib/ctrlport_probe2_c_impl.cc
@@ -65,21 +65,26 @@ namespace gr {
}
std::vector<gr_complex>
- ctrlport_probe2_c_impl::get() {
+ ctrlport_probe2_c_impl::get()
+ {
return buffered_get.get();
}
void
ctrlport_probe2_c_impl::set_length(int len)
{
+ gr::thread::scoped_lock guard(d_setlock);
+
if(len > 8191) {
- std::cerr << "probe2_c: length " << len
- << " exceeds maximum buffer size of 8191" << std::endl;
+ GR_LOG_WARN(d_logger,
+ boost::format("probe2_c: length %1% exceeds maximum"
+ " buffer size of 8191") % len);
len = 8191;
}
d_len = len;
- d_buffer.reserve(d_len);
+ d_buffer.resize(d_len);
+ d_index = 0;
}
int
@@ -95,20 +100,21 @@ namespace gr {
{
const gr_complex *in = (const gr_complex*)input_items[0];
+ gr::thread::scoped_lock guard(d_setlock);
+
// copy samples to get buffer if we need samples
- if(d_buffer.size() < d_len) {
+ if(d_index < d_len) {
// copy smaller of remaining buffer space and num inputs to work()
- int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items
);
+ int num_copy = std::min( (int)(d_len - d_index), noutput_items );
- // TODO: convert this to a copy operator for speed...
- for(int i = 0; i < num_copy; i++) {
- d_buffer.push_back(in[i]);
- }
+ memcpy(&d_buffer[d_index], in, num_copy*sizeof(gr_complex));
+ d_index += num_copy;
}
// notify the waiting get() if we fill up the buffer
- if(d_buffer.size() == d_len) {
- buffered_get.offer_data(d_buffer);
+ if(d_index == d_len) {
+ buffered_get.offer_data(d_buffer);
+ d_index = 0;
}
return noutput_items;
diff --git a/gr-blocks/lib/ctrlport_probe2_c_impl.h
b/gr-blocks/lib/ctrlport_probe2_c_impl.h
index fa74216..119738a 100644
--- a/gr-blocks/lib/ctrlport_probe2_c_impl.h
+++ b/gr-blocks/lib/ctrlport_probe2_c_impl.h
@@ -38,6 +38,7 @@ namespace gr {
size_t d_len;
unsigned int d_disp_mask;
+ size_t d_index;
std::vector<gr_complex> d_buffer;
rpcbufferedget< std::vector<gr_complex> > buffered_get;
diff --git a/gr-blocks/lib/ctrlport_probe2_f_impl.cc
b/gr-blocks/lib/ctrlport_probe2_f_impl.cc
index 05d67da..ff37401 100644
--- a/gr-blocks/lib/ctrlport_probe2_f_impl.cc
+++ b/gr-blocks/lib/ctrlport_probe2_f_impl.cc
@@ -63,21 +63,26 @@ namespace gr {
}
std::vector<float>
- ctrlport_probe2_f_impl::get() {
+ ctrlport_probe2_f_impl::get()
+ {
return buffered_get.get();
}
void
ctrlport_probe2_f_impl::set_length(int len)
{
+ gr::thread::scoped_lock guard(d_setlock);
+
if(len > 8191) {
- std::cerr << "probe2_f: length " << len
- << " exceeds maximum buffer size of 8191" << std::endl;
+ GR_LOG_WARN(d_logger,
+ boost::format("probe2_f: length %1% exceeds maximum"
+ " buffer size of 8191") % len);
len = 8191;
}
d_len = len;
- d_buffer.reserve(d_len);
+ d_buffer.resize(d_len);
+ d_index = 0;
}
int
@@ -93,21 +98,21 @@ namespace gr {
{
const float *in = (const float*)input_items[0];
+ gr::thread::scoped_lock guard(d_setlock);
+
// copy samples to get buffer if we need samples
- if(d_buffer.size() < d_len) {
+ if(d_index < d_len) {
// copy smaller of remaining buffer space and num inputs to work()
- int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items
);
+ int num_copy = std::min( (int)(d_len - d_index), noutput_items );
- // TODO: convert this to a copy operator for speed...
- for(int i = 0; i < num_copy; i++) {
- d_buffer.push_back(in[i]);
- }
+ memcpy(&d_buffer[d_index], in, num_copy*sizeof(float));
+ d_index += num_copy;
}
-
// notify the waiting get() if we fill up the buffer
- if(d_buffer.size() == d_len) {
- buffered_get.offer_data(d_buffer);
+ if(d_index == d_len) {
+ buffered_get.offer_data(d_buffer);
+ d_index = 0;
}
return noutput_items;
diff --git a/gr-blocks/lib/ctrlport_probe2_f_impl.h
b/gr-blocks/lib/ctrlport_probe2_f_impl.h
index 8d406db..6aec078 100644
--- a/gr-blocks/lib/ctrlport_probe2_f_impl.h
+++ b/gr-blocks/lib/ctrlport_probe2_f_impl.h
@@ -38,6 +38,7 @@ namespace gr {
size_t d_len;
unsigned int d_disp_mask;
+ size_t d_index;
std::vector<float> d_buffer;
rpcbufferedget< std::vector<float> > buffered_get;
diff --git a/gr-blocks/lib/ctrlport_probe2_i_impl.cc
b/gr-blocks/lib/ctrlport_probe2_i_impl.cc
index 086ebe7..7e17d8e 100644
--- a/gr-blocks/lib/ctrlport_probe2_i_impl.cc
+++ b/gr-blocks/lib/ctrlport_probe2_i_impl.cc
@@ -65,21 +65,26 @@ namespace gr {
}
std::vector<int>
- ctrlport_probe2_i_impl::get() {
+ ctrlport_probe2_i_impl::get()
+ {
return buffered_get.get();
}
void
ctrlport_probe2_i_impl::set_length(int len)
{
+ gr::thread::scoped_lock guard(d_setlock);
+
if(len > 8191) {
- std::cerr << "probe2_i: length " << len
- << " exceeds maximum buffer size of 8191" << std::endl;
+ GR_LOG_WARN(d_logger,
+ boost::format("probe2_i: length %1% exceeds maximum"
+ " buffer size of 8191") % len);
len = 8191;
}
d_len = len;
- d_buffer.reserve(d_len);
+ d_buffer.resize(d_len);
+ d_index = 0;
}
int
@@ -94,20 +99,22 @@ namespace gr {
gr_vector_void_star &output_items)
{
const int *in = (const int*)input_items[0];
+
+ gr::thread::scoped_lock guard(d_setlock);
+
// copy samples to get buffer if we need samples
- if(d_buffer.size() < d_len) {
+ if(d_index < d_len) {
// copy smaller of remaining buffer space and num inputs to work()
- int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items
);
+ int num_copy = std::min( (int)(d_len - d_index), noutput_items );
- // TODO: convert this to a copy operator for speed...
- for(int i = 0; i < num_copy; i++) {
- d_buffer.push_back(in[i]);
- }
+ memcpy(&d_buffer[d_index], in, num_copy*sizeof(int));
+ d_index += num_copy;
}
// notify the waiting get() if we fill up the buffer
- if(d_buffer.size() == d_len) {
- buffered_get.offer_data(d_buffer);
+ if(d_index == d_len) {
+ buffered_get.offer_data(d_buffer);
+ d_index = 0;
}
return noutput_items;
diff --git a/gr-blocks/lib/ctrlport_probe2_i_impl.h
b/gr-blocks/lib/ctrlport_probe2_i_impl.h
index 3a97655..2832af0 100644
--- a/gr-blocks/lib/ctrlport_probe2_i_impl.h
+++ b/gr-blocks/lib/ctrlport_probe2_i_impl.h
@@ -38,6 +38,7 @@ namespace gr {
size_t d_len;
unsigned int d_disp_mask;
+ size_t d_index;
std::vector<int> d_buffer;
rpcbufferedget< std::vector<int> > buffered_get;
diff --git a/gr-blocks/lib/ctrlport_probe2_s_impl.cc
b/gr-blocks/lib/ctrlport_probe2_s_impl.cc
index d6a15fa..9924243 100644
--- a/gr-blocks/lib/ctrlport_probe2_s_impl.cc
+++ b/gr-blocks/lib/ctrlport_probe2_s_impl.cc
@@ -65,21 +65,26 @@ namespace gr {
}
std::vector<short>
- ctrlport_probe2_s_impl::get() {
+ ctrlport_probe2_s_impl::get()
+ {
return buffered_get.get();
}
void
ctrlport_probe2_s_impl::set_length(int len)
{
+ gr::thread::scoped_lock guard(d_setlock);
+
if(len > 8191) {
- std::cerr << "probe2_s: length " << len
- << " exceeds maximum buffer size of 8191" << std::endl;
+ GR_LOG_WARN(d_logger,
+ boost::format("probe2_s: length %1% exceeds maximum"
+ " buffer size of 8191") % len);
len = 8191;
}
d_len = len;
- d_buffer.reserve(d_len);
+ d_buffer.resize(d_len);
+ d_index = 0;
}
int
@@ -95,19 +100,19 @@ namespace gr {
{
const short *in = (const short*)input_items[0];
+ gr::thread::scoped_lock guard(d_setlock);
+
// copy samples to get buffer if we need samples
- if(d_buffer.size() < d_len) {
+ if(d_index < d_len) {
// copy smaller of remaining buffer space and num inputs to work()
- int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items
);
+ int num_copy = std::min( (int)(d_len - d_index), noutput_items );
- // TODO: convert this to a copy operator for speed...
- for(int i = 0; i < num_copy; i++) {
- d_buffer.push_back(in[i]);
- }
+ memcpy(&d_buffer[d_index], in, num_copy*sizeof(short));
+ d_index += num_copy;
}
// notify the waiting get() if we fill up the buffer
- if(d_buffer.size() == d_len) {
+ if(d_index == d_len) {
buffered_get.offer_data(d_buffer);
}
diff --git a/gr-blocks/lib/ctrlport_probe2_s_impl.h
b/gr-blocks/lib/ctrlport_probe2_s_impl.h
index 49533ce..a608a78 100644
--- a/gr-blocks/lib/ctrlport_probe2_s_impl.h
+++ b/gr-blocks/lib/ctrlport_probe2_s_impl.h
@@ -38,6 +38,7 @@ namespace gr {
size_t d_len;
unsigned int d_disp_mask;
+ size_t d_index;
std::vector<short> d_buffer;
rpcbufferedget< std::vector<short> > buffered_get;
- [Commit-gnuradio] [gnuradio] 14/16: Merge remote-tracking branch 'tom/qtgui/range_type', (continued)
- [Commit-gnuradio] [gnuradio] 14/16: Merge remote-tracking branch 'tom/qtgui/range_type', git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 15/16: Merge remote-tracking branch 'nowls/burst_shaping', git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 04/16: grc: Add check for GTK initialization, git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 13/16: Merge remote-tracking branch 'mmueller/pwr_squelch_add_tags', git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 12/16: Merge remote-tracking branch 'tom/ctrlport/fixes1', git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 06/16: controlport: use proper default return value from prefs get_bool., git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 08/16: digital: fix skipped sample handling in burst_shaper, git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 05/16: qtgui: improved type checking for range block and simplifies python., git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 02/16: controlport: fixed up performance monitor., git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 03/16: qtgui: adds Type setting for Range widget., git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 01/16: controlport: fixed controlport probes.,
git <=
- [Commit-gnuradio] [gnuradio] 07/16: analog: Power Squelch now emit tags on start/end of bursts, git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 09/16: digital: added tag propagation to burst_shaper blocks, git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 10/16: blocks: better implementation of peak_detector2. Address #783., git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 11/16: blocks: more fixups to peak_detector2., git, 2015/04/26