summaryrefslogtreecommitdiff
path: root/ezdop/src/host/ezdop/ezdop.cc
diff options
context:
space:
mode:
authorjcorgan2006-09-03 23:46:01 +0000
committerjcorgan2006-09-03 23:46:01 +0000
commit36c175fb855d11d09d5418afa83dcc7a6924efac (patch)
treebac4405a19b66fc040643db32d55f8961cd36cfa /ezdop/src/host/ezdop/ezdop.cc
parentd4697a07812be9e1f91a03b0a2dd61b1948f9925 (diff)
downloadgnuradio-36c175fb855d11d09d5418afa83dcc7a6924efac.tar.gz
gnuradio-36c175fb855d11d09d5418afa83dcc7a6924efac.tar.bz2
gnuradio-36c175fb855d11d09d5418afa83dcc7a6924efac.zip
Merged branch jcorgan/wip into trunk.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@3471 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'ezdop/src/host/ezdop/ezdop.cc')
-rw-r--r--ezdop/src/host/ezdop/ezdop.cc21
1 files changed, 13 insertions, 8 deletions
diff --git a/ezdop/src/host/ezdop/ezdop.cc b/ezdop/src/host/ezdop/ezdop.cc
index 43a70dacb..99997fedf 100644
--- a/ezdop/src/host/ezdop/ezdop.cc
+++ b/ezdop/src/host/ezdop/ezdop.cc
@@ -22,6 +22,9 @@
// Application specific includes
#include "ezdop.h"
+// Boost includes
+#include <boost/scoped_array.hpp>
+
// System includes (FIXME: autoconf these)
#include <cassert>
#include <cstdio>
@@ -219,26 +222,27 @@ int ezdop::read_raw(unsigned char *buffer, unsigned int length)
return rd;
}
-int ezdop::read_iq(complex<float> *buffer, unsigned int samples)
+typedef boost::scoped_array<unsigned char> unsigned_char_scoped_array;
+
+int ezdop::read_iq(complex<float> *buffer, unsigned int samples, float &volume)
{
assert(d_online);
assert(d_device);
assert(buffer);
// 4 phases, d_rate samples per phase, 2 bytes per sample
- int bufsize = 8*d_rate*samples;
- unsigned char *raw = new unsigned char[bufsize];
+ int raw_size = 8*d_rate*samples;
+ unsigned_char_scoped_array raw(new unsigned char[raw_size]);
// Read until required bytes are read. Will block until bytes arrive.
int rd = 0;
- while (rd < bufsize)
- rd += read_raw(&raw[rd], bufsize-rd);
+ while (rd < raw_size)
+ rd += read_raw(&raw[rd], raw_size-rd);
// Iterate through read bytes and invoke state machine
int i = 0, j = 0; // i index inputs, j indexes outputs
- unsigned char ant;
- while (i < bufsize) {
+ while (i < raw_size) {
unsigned char ch = raw[i++];
if (d_state == ST_LO) {
d_val = ch; // Save lo byte
@@ -272,6 +276,7 @@ int ezdop::read_iq(complex<float> *buffer, unsigned int samples)
d_in_phase -= d_val;
else if (d_ant == 1) // -Q
d_quadrature -= d_val;
+
d_val = 0;
// Update expected antenna and sequence
@@ -292,6 +297,6 @@ int ezdop::read_iq(complex<float> *buffer, unsigned int samples)
d_state = ST_LO; // Switch states
};
- delete raw;
+ volume = 0.0;
return j;
}