[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8749 - in usrp2/branches/features/host-ng/host-ng: ap
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r8749 - in usrp2/branches/features/host-ng/host-ng: apps include/usrp2 lib |
Date: |
Sun, 29 Jun 2008 13:50:35 -0600 (MDT) |
Author: jcorgan
Date: 2008-06-29 13:50:34 -0600 (Sun, 29 Jun 2008)
New Revision: 8749
Added:
usrp2/branches/features/host-ng/host-ng/lib/ring.cc
usrp2/branches/features/host-ng/host-ng/lib/ring.h
Modified:
usrp2/branches/features/host-ng/host-ng/apps/Makefile.am
usrp2/branches/features/host-ng/host-ng/apps/test.sh
usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc
usrp2/branches/features/host-ng/host-ng/include/usrp2/usrp2.h
usrp2/branches/features/host-ng/host-ng/lib/Makefile.am
usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc
usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.h
usrp2/branches/features/host-ng/host-ng/lib/usrp2.cc
usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc
usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h
Log:
work-in-progress, partial implementation of channel rings, disabled for now
Modified: usrp2/branches/features/host-ng/host-ng/apps/Makefile.am
===================================================================
--- usrp2/branches/features/host-ng/host-ng/apps/Makefile.am 2008-06-29
06:34:18 UTC (rev 8748)
+++ usrp2/branches/features/host-ng/host-ng/apps/Makefile.am 2008-06-29
19:50:34 UTC (rev 8749)
@@ -21,7 +21,8 @@
INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES)
LDADD = \
- ../lib/libusrp2ng.la
+ ../lib/libusrp2ng.la \
+ -lgruel
noinst_PROGRAMS = \
test_usrp2
Modified: usrp2/branches/features/host-ng/host-ng/apps/test.sh
===================================================================
--- usrp2/branches/features/host-ng/host-ng/apps/test.sh 2008-06-29
06:34:18 UTC (rev 8748)
+++ usrp2/branches/features/host-ng/host-ng/apps/test.sh 2008-06-29
19:50:34 UTC (rev 8749)
@@ -1,5 +1,5 @@
#!/bin/sh
-sudo ./test_usrp2 1>cerr 2>&1
+sudo ./test_usrp2 -d 5 1>cerr 2>&1
Modified: usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc 2008-06-29
06:34:18 UTC (rev 8748)
+++ usrp2/branches/features/host-ng/host-ng/apps/test_usrp2.cc 2008-06-29
19:50:34 UTC (rev 8749)
@@ -23,7 +23,7 @@
#include <usrp2/usrp2.h>
#include <usrp2/tune_result.h>
#include <usrp2/strtod_si.h>
-#include <gr_realtime.h>
+#include <gruel/realtime.h>
#include <iostream>
#include <string.h>
@@ -101,11 +101,11 @@
exit(1);
}
}
-#if 0
- gr_rt_status_t rt = gr_enable_realtime_scheduling();
- if (rt != RT_OK)
+
+ gruel::rt_status_t rt = gruel::enable_realtime_scheduling();
+ if (rt != gruel::RT_OK)
std::cerr << "Failed to enable realtime scheduling" << std::endl;
-#endif
+
usrp2::usrp2::sptr u2 = usrp2::usrp2::make(interface, mac_addr_str);
if (!u2->set_rx_gain(rx_gain)){
@@ -141,9 +141,8 @@
int r = nanosleep(&ts, 0);
if (r == -1)
perror("nanosleep");
-
u2->stop_rx_streaming();
-
+
// Wait to be able to see stray packets
ts.tv_sec = 1;
ts.tv_nsec = 0;
Modified: usrp2/branches/features/host-ng/host-ng/include/usrp2/usrp2.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/include/usrp2/usrp2.h
2008-06-29 06:34:18 UTC (rev 8748)
+++ usrp2/branches/features/host-ng/host-ng/include/usrp2/usrp2.h
2008-06-29 19:50:34 UTC (rev 8749)
@@ -25,106 +25,115 @@
namespace usrp2 {
-/*!
- * Structure to hold properties of USRP2 hardware devices.
- *
- */
-struct props
-{
- std::string addr;
- uint16_t hw_rev;
- uint8_t fpga_md5sum[16];
- uint8_t sw_md5sum[16];
-};
+ /*!
+ * Structure to hold properties of USRP2 hardware devices.
+ *
+ */
+ struct props
+ {
+ std::string addr;
+ uint16_t hw_rev;
+ uint8_t fpga_md5sum[16];
+ uint8_t sw_md5sum[16];
+ };
-typedef std::vector<props> props_vector_t;
+ typedef std::vector<props> props_vector_t;
-props_vector_t find(const std::string &ifc, const std::string &addr="");
+ props_vector_t find(const std::string &ifc, const std::string &addr="");
-class tune_result;
+ class tune_result;
+ class data_handler;
+
+ class usrp2 : boost::noncopyable
+ {
+ public:
+ static const unsigned int MAX_CHAN = 30;
-class usrp2 : boost::noncopyable
-{
-public:
- /*!
- * Shared pointer to this class
- */
- typedef boost::shared_ptr<usrp2> sptr;
+ /*!
+ * Shared pointer to this class
+ */
+ typedef boost::shared_ptr<usrp2> sptr;
- /*!
- * Static function to return an instance of usrp2 as a shared pointer
- *
- * \param ifc Network interface name, e.g., "eth0"
- * \param addr Network mac address, e.g., "01:02:03:04:05:06" or "05:06",
- * default is auto-select
- */
- static sptr make(const std::string &ifc, const std::string &addr="");
+ /*!
+ * Static function to return an instance of usrp2 as a shared pointer
+ *
+ * \param ifc Network interface name, e.g., "eth0"
+ * \param addr Network mac address, e.g., "01:02:03:04:05:06" or "05:06",
+ * default is auto-select
+ */
+ static sptr make(const std::string &ifc, const std::string &addr="");
- /*!
- * Class destructor
- */
- ~usrp2();
+ /*!
+ * Class destructor
+ */
+ ~usrp2();
- /*
- * Rx configuration and control
- */
+ /*
+ * Rx configuration and control
+ */
- /*!
- * Set receiver gain
- */
- bool set_rx_gain(double gain);
+ /*!
+ * Set receiver gain
+ */
+ bool set_rx_gain(double gain);
- /*!
- * Set receiver center frequency
- */
- bool set_rx_center_freq(double frequency, tune_result *result);
+ /*!
+ * Set receiver center frequency
+ */
+ bool set_rx_center_freq(double frequency, tune_result *result);
- /*!
- * Set receiver sample rate decimation
- */
- bool set_rx_decim(int decimation_factor);
+ /*!
+ * Set receiver sample rate decimation
+ */
+ bool set_rx_decim(int decimation_factor);
- /*!
- * Set receiver IQ magnitude scaling
- */
- bool set_rx_scale_iq(int scale_i, int scale_q);
+ /*!
+ * Set receiver IQ magnitude scaling
+ */
+ bool set_rx_scale_iq(int scale_i, int scale_q);
- /*!
- * Set received sample format
- *
- * domain: complex or real
- * type: floating, fixed point, or raw
- * depth: bits per sample
- *
- * Sets format over the wire for samples from USRP2 and determines
- * default reader and writer functors
- *
- */
- // bool set_rx_format(...);
+ /*!
+ * Set received sample format
+ *
+ * domain: complex or real
+ * type: floating, fixed point, or raw
+ * depth: bits per sample
+ *
+ * Sets format over the wire for samples from USRP2 and determines
+ * default reader and writer functors
+ *
+ */
+ // bool set_rx_format(...);
- /*!
- * Start streaming receive mode. USRP2 will send a continuous stream of
- * DSP pipeline samples to host. Call rx_samples(...) to access.
- *
- * \param items_per_frame Number of 32-bit items per frame.
- */
- bool start_rx_streaming(unsigned int items_per_frame=0);
+ /*!
+ * Start streaming receive mode. USRP2 will send a continuous stream of
+ * DSP pipeline samples to host. Call rx_samples(...) to access.
+ *
+ * \param channel Stream channel number (0-30)
+ * \param items_per_frame Number of 32-bit items per frame.
+ */
+ bool start_rx_streaming(unsigned int channel=0, unsigned int
items_per_frame=0);
- /*!
- * Stop streaming receive mode.
- */
- bool stop_rx_streaming();
+ /*!
+ * Receive stream data from specified channel
+ */
+ bool rx_samples(unsigned int channel, data_handler *handler);
- /* Ignore :-) */
- class impl;
+ /*!
+ * Stop streaming receive mode.
+ */
+ bool stop_rx_streaming(unsigned int channel=0);
-private:
- // Only usrp2::make factory function can instantiate this class
- usrp2(const std::string &ifc, const std::string &addr);
+ /* Ignore :-) */
+ class impl;
+
+ private:
+ // Only usrp2::make factory function can instantiate this class
+ usrp2(const std::string &ifc, const std::string &addr);
- // All private state is held in opaque pointer
- std::auto_ptr<impl> d_impl;
-};
+ // All private state is held in opaque pointer
+ std::auto_ptr<impl> d_impl;
+ };
};
Modified: usrp2/branches/features/host-ng/host-ng/lib/Makefile.am
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/Makefile.am 2008-06-29
06:34:18 UTC (rev 8748)
+++ usrp2/branches/features/host-ng/host-ng/lib/Makefile.am 2008-06-29
19:50:34 UTC (rev 8749)
@@ -31,6 +31,7 @@
ethernet.cc \
find.cc \
pktfilter.cc \
+ ring.cc \
strtod_si.c \
usrp2.cc \
usrp2_impl.cc \
@@ -47,5 +48,6 @@
eth_common.h \
ethernet.h \
pktfilter.h \
+ ring.h \
usrp2_impl.h \
usrp2_thread.h
Modified: usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc 2008-06-29
06:34:18 UTC (rev 8748)
+++ usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.cc 2008-06-29
19:50:34 UTC (rev 8749)
@@ -49,7 +49,7 @@
eth_buffer::eth_buffer(size_t rx_bufsize)
: d_fd(0), d_using_tpring(false), d_buflen(0), d_buf(0), d_frame_nr(0),
- d_head(0), d_ring(0), d_ethernet(new ethernet())
+ d_frame_size(0), d_head(0), d_ring(0), d_ethernet(new ethernet())
{
if (rx_bufsize == 0)
d_buflen = (size_t)MAX_MEM_SIZE;
@@ -82,6 +82,7 @@
// Calculate minimum power-of-two aligned size for frames
req.tp_frame_size =
(unsigned int)rint(pow(2,
ceil(log2(TPACKET_ALIGN(TPACKET_HDRLEN)+TPACKET_ALIGN(MAX_PKT_SIZE)))));
+ d_frame_size = req.tp_frame_size;
// Calculate minimum contiguous pages needed to enclose a frame
int npages = (page_size > req.tp_frame_size) ? 1 :
((req.tp_frame_size+page_size-1)/page_size);
@@ -200,6 +201,8 @@
}
}
+ DEBUG_LOG("R");
+
// Iterate through available packets
while (frame_available()) {
// Get start of ethernet frame and length
@@ -209,9 +212,10 @@
// Invoke data handler
data_handler::result r = (*f)(base, len);
-
- // data_handler::KEEP not yet implemented
- hdr->tp_status = TP_STATUS_KERNEL; // mark it free
+ if (!(r & data_handler::KEEP))
+ hdr->tp_status = TP_STATUS_KERNEL; // mark it free
+ else
+ DEBUG_LOG("K");
inc_head();
if (r & data_handler::DONE)
@@ -234,6 +238,18 @@
return 1;
}
+
+ void
+ eth_buffer::release_frame(void *base)
+ {
+ // Get d_frame_size aligned header
+
+ tpacket_hdr *hdr = (tpacket_hdr *)
+ ((((size_t)base+d_frame_size-1) & ~(d_frame_size-1)));
+
+ hdr->tp_status = TP_STATUS_KERNEL; // mark it free
+ DEBUG_LOG("f");
+ }
} // namespace usrp2
Modified: usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.h 2008-06-29
06:34:18 UTC (rev 8748)
+++ usrp2/branches/features/host-ng/host-ng/lib/eth_buffer.h 2008-06-29
19:50:34 UTC (rev 8749)
@@ -49,6 +49,7 @@
size_t d_buflen; // length of our buffer
uint8_t *d_buf; // packet ring
unsigned int d_frame_nr; // max frames on ring
+ size_t d_frame_size; // frame storage size
unsigned int d_head; // pointer to next frame
std::vector<uint8_t *> d_ring; // pointers into buffer
@@ -168,6 +169,20 @@
* \returns -1 if there was an unrecoverable error.
*/
int tx_framev(const eth_iovec *iov, int iovcnt, int flags=0);
+
+ /*
+ * \brief Returns maximum possible number of frames in buffer
+ */
+ unsigned int max_frames() const { return d_frame_nr; }
+
+ /*
+ * \brief Release frame from buffer
+ *
+ * Call to release a frame previously held by a KEEP. The pointer
+ * may be offset from the base of the frame up to its length.
+ */
+ void release_frame(void *p);
+
};
}; // namespace usrp2
Added: usrp2/branches/features/host-ng/host-ng/lib/ring.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/ring.cc
(rev 0)
+++ usrp2/branches/features/host-ng/host-ng/lib/ring.cc 2008-06-29 19:50:34 UTC
(rev 8749)
@@ -0,0 +1,68 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "ring.h"
+
+namespace usrp2 {
+
+ ring::ring(unsigned int entries)
+ : d_max(entries), d_head(0), d_next(0), d_ring(entries),
+ d_mutex(), d_cond(&d_mutex)
+ {
+ for (unsigned int i = 0; i < entries; i++) {
+ d_ring[i].d_base = 0;
+ d_ring[i].d_len = 0;
+ }
+ }
+
+ bool ring::enqueue(void *p, size_t len)
+ {
+ if (d_ring[d_next].d_base != 0)
+ return false;
+
+ d_ring[d_next].d_len = len;
+ d_ring[d_next].d_base = p;
+ inc_next();
+ d_cond.signal();
+
+ return true;
+ }
+
+ bool ring::dequeue(void **p, size_t *len)
+ {
+ void *base = d_ring[d_head].d_base;
+ if (!base)
+ return false;
+
+ *p = base;
+ *len = d_ring[d_head].d_len;
+ d_ring[d_head].d_base = 0;
+ inc_head();
+
+ return true;
+ };
+
+} // namespace usrp2
+
Added: usrp2/branches/features/host-ng/host-ng/lib/ring.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/ring.h
(rev 0)
+++ usrp2/branches/features/host-ng/host-ng/lib/ring.h 2008-06-29 19:50:34 UTC
(rev 8749)
@@ -0,0 +1,77 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_RING_H
+#define INCLUDED_RING_H
+
+#include <omnithread.h>
+#include <stddef.h>
+#include <vector>
+
+namespace usrp2 {
+
+ class ring
+ {
+ private:
+
+ size_t d_max;
+ size_t d_head;
+ size_t d_next;
+
+ struct ring_desc
+ {
+ void *d_base;
+ size_t d_len;
+ };
+ std::vector<ring_desc> d_ring;
+
+ omni_mutex d_mutex;
+ omni_condition d_cond;
+
+ void inc_head()
+ {
+ if (d_head + 1 >= d_max)
+ d_head = 0;
+ else
+ d_head = d_head + 1;
+ }
+
+ void inc_next()
+ {
+ if (d_next + 1 >= d_max)
+ d_next = 0;
+ else
+ d_next = d_next + 1;
+ }
+
+ public:
+
+ ring(unsigned int entries);
+
+ bool not_empty() const { return d_ring[d_head].d_base != 0; }
+ void wait() { d_cond.wait(); }
+
+ bool enqueue(void *p, size_t len);
+ bool dequeue(void **p, size_t *len);
+ };
+
+} // namespace usrp2
+
+#endif /* INCLUDED_RING_H */
Modified: usrp2/branches/features/host-ng/host-ng/lib/usrp2.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/usrp2.cc 2008-06-29
06:34:18 UTC (rev 8748)
+++ usrp2/branches/features/host-ng/host-ng/lib/usrp2.cc 2008-06-29
19:50:34 UTC (rev 8749)
@@ -70,15 +70,21 @@
}
bool
- usrp2::start_rx_streaming(unsigned int items_per_frame)
+ usrp2::start_rx_streaming(unsigned int channel, unsigned int items_per_frame)
{
- return d_impl->start_rx_streaming(items_per_frame);
+ return d_impl->start_rx_streaming(channel, items_per_frame);
}
bool
- usrp2::stop_rx_streaming()
+ usrp2::rx_samples(unsigned int channel, data_handler *handler)
{
- return d_impl->stop_rx_streaming();
+ return d_impl->rx_samples(channel, handler);
}
+ bool
+ usrp2::stop_rx_streaming(unsigned int channel)
+ {
+ return d_impl->stop_rx_streaming(channel);
+ }
+
} // namespace usrp2
Modified: usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc 2008-06-29
06:34:18 UTC (rev 8748)
+++ usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc 2008-06-29
19:50:34 UTC (rev 8749)
@@ -29,6 +29,7 @@
#include "eth_buffer.h"
#include "pktfilter.h"
#include "control.h"
+#include "ring.h"
#include <stdexcept>
#include <iostream>
#include <stdio.h>
@@ -96,6 +97,7 @@
std::cerr << "usrp2 constructor: using USRP2 at " << d_addr << std::endl;
memset(d_pending_replies, 0, sizeof(d_pending_replies));
+ memset(d_channel_rings, 0, sizeof(d_channel_rings));
d_bg_thread = new usrp2_thread(this);
d_bg_thread->start();
@@ -299,11 +301,32 @@
}
bool
- usrp2::impl::start_rx_streaming(unsigned int items_per_frame)
+ usrp2::impl::start_rx_streaming(unsigned int channel, unsigned int
items_per_frame)
{
if (USRP2_IMPL_DEBUG)
- std::cerr << "usrp2: starting rx streaming...";
+ std::cerr << "usrp2: starting rx streaming on channel "
+ << channel << "...";
+ if (channel > MAX_CHAN) {
+ std::cerr << "usrp2: invalid channel number (" << channel
+ << ")" << std::endl;
+ return false;
+ }
+
+ if (channel > 0) { // until firmware supports multiple streams
+ std::cerr << "usrp2: channel " << channel
+ << " not implemented" << std::endl;
+ return false;
+ }
+
+ if (d_channel_rings[channel]) {
+ std::cerr << "usrp2: channel " << channel
+ << " already streaming" << std::endl;
+ return false;
+ }
+
+ d_channel_rings[channel] = new ring(d_buffer->max_frames());
+
if (items_per_frame == 0)
items_per_frame = U2_MAX_SAMPLES; // minimize overhead
@@ -330,11 +353,30 @@
}
bool
- usrp2::impl::stop_rx_streaming()
+ usrp2::impl::stop_rx_streaming(unsigned int channel)
{
if (USRP2_IMPL_DEBUG)
- std::cerr << "usrp2: stopping rx streaming...";
+ std::cerr << "usrp2: stopping rx streaming on channel "
+ << channel << std::endl;
+ if (channel > MAX_CHAN) {
+ std::cerr << "usrp2: invalid channel number (" << channel
+ << ")" << std::endl;
+ return false;
+ }
+
+ if (channel > 0) { // until firmware supports multiple streams
+ std::cerr << "usrp2: channel " << channel
+ << " not implemented" << std::endl;
+ return false;
+ }
+
+ if (!d_channel_rings[channel]) {
+ std::cerr << "usrp2: channel " << channel
+ << " not streaming" << std::endl;
+ return false;
+ }
+
op_stop_rx_cmd cmd;
op_generic_t reply;
@@ -353,6 +395,13 @@
bool success = (ntohx(reply.ok) == 1);
if (USRP2_IMPL_DEBUG)
std::cerr << (success ? "ok." : "fail.") << std::endl;
+
+ if (success) {
+ ring *rp = d_channel_rings[channel];
+ d_channel_rings[channel] = 0;
+ delete rp;
+ }
+
return success;
}
@@ -462,9 +511,66 @@
}
d_rx_seqno = pkt->hdrs.thdr.seqno;
+// incomplete channel ring functionality disabled
+#if 0
+ unsigned int chan = u2p_chan(&pkt->hdrs.fixed);
+ if (d_channel_rings[chan] == 0) {
+ DEBUG_LOG("?");
+ return 0; // discard packet, no channel handler
+ }
+
+ if (d_channel_rings[chan]->enqueue(&pkt->samples, 0)) {
+ DEBUG_LOG("e");
+ return KEEP; // channel ring runner will mark frame done
+ }
+ else {
+ DEBUG_LOG("!");
+ return 0; // discard, no room in channel ring
+ }
+#endif
+ return 0;
+ }
- // enqueue in channel ring here
- return 0; // will be KEEP, as the channel ring runner will retire packet
+ bool
+ usrp2::impl::rx_samples(unsigned int channel, data_handler *handler)
+ {
+ if (channel > MAX_CHAN) {
+ std::cerr << "usrp2: invalid channel (" << channel
+ << " )" << std::endl;
+ return false;
+ }
+
+ if (channel > 0) {
+ std::cerr << "usrp2: channel " << channel
+ << " not implemented" << std::endl;
+ return false;
+ }
+
+ ring *rp = d_channel_rings[channel];
+ if (rp == 0) {
+ std::cerr << "usrp2: channel " << channel
+ << " not streaming" << std::endl;
+ return false;
+ }
+
+ // Wait for frames available in channel ring
+ while (!rp->not_empty()) {
+ DEBUG_LOG("w");
+ rp->wait();
+ }
+
+ // Iterate through frames and present to user
+ void *p;
+ size_t len;
+ while (rp->dequeue(&p, &len)) {
+ DEBUG_LOG("d");
+ // Invoke user callback, handle KEEP and DONE
+
+ // Release frame
+ d_buffer->release_frame(p);
+ }
+
+ return true;
}
void
Modified: usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h 2008-06-29
06:34:18 UTC (rev 8748)
+++ usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h 2008-06-29
19:50:34 UTC (rev 8749)
@@ -32,10 +32,12 @@
class usrp2_thread;
class usrp2_tune_result;
class pending_reply;
+ class ring;
class usrp2::impl : public data_handler
{
static const size_t NRIDS = 256;
+ static const size_t NCHANS = 32;
eth_buffer *d_buffer;
pktfilter *d_pf;
@@ -52,6 +54,7 @@
unsigned int d_num_rx_bytes;
pending_reply *d_pending_replies[NRIDS]; // indexed by 8-bit reply id
+ ring *d_channel_rings[NCHANS]; // indexed by 5-bit channel number
static bool parse_mac_addr(const std::string &s, u2_mac_addr_t *p);
void init_et_hdrs(u2_eth_packet_t *p, const std::string &dst);
@@ -73,9 +76,9 @@
bool set_rx_center_freq(double frequency, tune_result *result);
bool set_rx_decim(int decimation_factor);
bool set_rx_scale_iq(int scale_i, int scale_q);
- bool start_rx_streaming(unsigned int items_per_frame);
- bool stop_rx_streaming();
-
+ bool start_rx_streaming(unsigned int channel, unsigned int
items_per_frame);
+ bool rx_samples(unsigned int channel, data_handler *handler);
+ bool stop_rx_streaming(unsigned int channel);
};
} // namespace usrp2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8749 - in usrp2/branches/features/host-ng/host-ng: apps include/usrp2 lib,
jcorgan <=