summaryrefslogtreecommitdiff
path: root/usrp2/host
diff options
context:
space:
mode:
authorJohnathan Corgan2009-09-17 10:37:27 -0700
committerJohnathan Corgan2009-12-03 15:49:12 -0800
commit7f28201b45a63735b3b710105e1c86dbe1f4e514 (patch)
treec7514f6284d327db73beedace311a0f4850dff7c /usrp2/host
parenta198e5134b00a1d5b98b5447aafd3cdba8508609 (diff)
downloadgnuradio-7f28201b45a63735b3b710105e1c86dbe1f4e514.tar.gz
gnuradio-7f28201b45a63735b3b710105e1c86dbe1f4e514.tar.bz2
gnuradio-7f28201b45a63735b3b710105e1c86dbe1f4e514.zip
Applied 'start streaming at' patch from Douglas Geiger
Diffstat (limited to 'usrp2/host')
-rw-r--r--usrp2/host/include/usrp2/usrp2.h21
-rw-r--r--usrp2/host/lib/control.h8
-rw-r--r--usrp2/host/lib/usrp2.cc12
-rw-r--r--usrp2/host/lib/usrp2_impl.cc104
-rw-r--r--usrp2/host/lib/usrp2_impl.h2
5 files changed, 147 insertions, 0 deletions
diff --git a/usrp2/host/include/usrp2/usrp2.h b/usrp2/host/include/usrp2/usrp2.h
index 7a612f945..07e5bf1df 100644
--- a/usrp2/host/include/usrp2/usrp2.h
+++ b/usrp2/host/include/usrp2/usrp2.h
@@ -177,6 +177,27 @@ namespace usrp2 {
* \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);
+
+ /*!
+ * Start streaming receive mode at specified timestamp. 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.
+ * \param time Timestamp to start streaming at
+ */
+ bool start_rx_streaming_at(unsigned int channel=0, unsigned int items_per_frame=0, unsigned int time=0);
+
+ /*!
+ * Sync to PPS and start streaming receive mode at specified timestamp.
+ * Just like calling sync_to_pps() and start_rx_streaming_at().
+ *
+ * \param channel Stream channel number (0-30)
+ * \param items_per_frame Number of 32-bit items per frame.
+ * \param time Timestamp to start streaming at
+ */
+ bool sync_and_start_rx_streaming_at(unsigned int channel=0, unsigned int items_per_frame=0, uint32_t time=0);
/*!
* Stop streaming receive mode.
diff --git a/usrp2/host/lib/control.h b/usrp2/host/lib/control.h
index 8769e4522..376c281a7 100644
--- a/usrp2/host/lib/control.h
+++ b/usrp2/host/lib/control.h
@@ -46,6 +46,14 @@ namespace usrp2 {
op_start_rx_streaming_t op;
op_generic_t eop;
};
+
+ struct op_sync_and_start_rx_streaming_cmd
+ {
+ u2_eth_packet_t h;
+ op_generic_t sync_op;
+ op_start_rx_streaming_t rx_op;
+ op_generic_t eop;
+ };
struct op_stop_rx_cmd {
u2_eth_packet_t h;
diff --git a/usrp2/host/lib/usrp2.cc b/usrp2/host/lib/usrp2.cc
index a2a9ecc11..ec3be5541 100644
--- a/usrp2/host/lib/usrp2.cc
+++ b/usrp2/host/lib/usrp2.cc
@@ -242,6 +242,18 @@ namespace usrp2 {
}
bool
+ usrp2::start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time)
+ {
+ return d_impl->start_rx_streaming_at(channel, items_per_frame,time);
+ }
+
+ bool
+ usrp2::sync_and_start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time)
+ {
+ return d_impl->sync_and_start_rx_streaming_at(channel, items_per_frame, time);
+ }
+
+ bool
usrp2::rx_samples(unsigned int channel, rx_sample_handler *handler)
{
return d_impl->rx_samples(channel, handler);
diff --git a/usrp2/host/lib/usrp2_impl.cc b/usrp2/host/lib/usrp2_impl.cc
index 3d0304324..ad1ea74b8 100644
--- a/usrp2/host/lib/usrp2_impl.cc
+++ b/usrp2/host/lib/usrp2_impl.cc
@@ -666,6 +666,110 @@ namespace usrp2 {
return success;
}
}
+
+ bool
+ usrp2::impl::start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time)
+ {
+ 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;
+ }
+
+ {
+ omni_mutex_lock l(d_channel_rings_mutex);
+ if (d_channel_rings[channel]) {
+ std::cerr << "usrp2: channel " << channel
+ << " already streaming" << std::endl;
+ return false;
+ }
+
+ if (items_per_frame == 0)
+ items_per_frame = U2_MAX_SAMPLES; // minimize overhead
+
+ op_start_rx_streaming_cmd cmd;
+ op_generic_t reply;
+
+ memset(&cmd, 0, sizeof(cmd));
+ init_etf_hdrs(&cmd.h, d_addr, 0, CONTROL_CHAN, time);
+ cmd.op.opcode = OP_START_RX_STREAMING;
+ cmd.op.len = sizeof(cmd.op);
+ cmd.op.rid = d_next_rid++;
+ cmd.op.items_per_frame = htonl(items_per_frame);
+ cmd.eop.opcode = OP_EOP;
+ cmd.eop.len = sizeof(cmd.eop);
+
+ bool success = false;
+ pending_reply p(cmd.op.rid, &reply, sizeof(reply));
+ success = transmit_cmd(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT);
+ success = success && (ntohx(reply.ok) == 1);
+
+ if (success)
+ d_channel_rings[channel] = ring_sptr(new ring(d_eth_buf->max_frames()));
+
+ return success;
+ }
+ }
+
+ bool
+ usrp2::impl::sync_and_start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time)
+ {
+
+ 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;
+ }
+
+ {
+ omni_mutex_lock l(d_channel_rings_mutex);
+ if (d_channel_rings[channel]) {
+ std::cerr << "usrp2: channel " << channel
+ << " already streaming" << std::endl;
+ return false;
+ }
+
+ if (items_per_frame == 0)
+ items_per_frame = U2_MAX_SAMPLES; // minimize overhead
+
+ op_sync_and_start_rx_streaming_cmd cmd;
+ op_generic_t reply;
+
+ memset(&cmd, 0, sizeof(cmd));
+ init_etf_hdrs(&cmd.h, d_addr, 0, CONTROL_CHAN, time);
+ cmd.sync_op.opcode = OP_SYNC_TO_PPS;
+ cmd.sync_op.len = sizeof(cmd.sync_op);
+ cmd.sync_op.rid = d_next_rid++;
+ cmd.rx_op.opcode = OP_START_RX_STREAMING;
+ cmd.rx_op.len = sizeof(cmd.rx_op);
+ cmd.rx_op.rid = d_next_rid++;
+ cmd.rx_op.items_per_frame = htonl(items_per_frame);
+ cmd.eop.opcode = OP_EOP;
+ cmd.eop.len = sizeof(cmd.eop);
+
+ bool success = false;
+ pending_reply p(cmd.sync_op.rid, &reply, sizeof(reply));
+ success = transmit_cmd(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT);
+ success = success && (ntohx(reply.ok) == 1);
+
+ if (success)
+ d_channel_rings[channel] = ring_sptr(new ring(d_eth_buf->max_frames()));
+
+ return success;
+ }
+ }
bool
usrp2::impl::stop_rx_streaming(unsigned int channel)
diff --git a/usrp2/host/lib/usrp2_impl.h b/usrp2/host/lib/usrp2_impl.h
index ed71a6ba3..aaed66bc7 100644
--- a/usrp2/host/lib/usrp2_impl.h
+++ b/usrp2/host/lib/usrp2_impl.h
@@ -143,6 +143,8 @@ namespace usrp2 {
bool write_gpio(int bank, uint16_t value, uint16_t mask);
bool read_gpio(int bank, uint16_t *value);
bool start_rx_streaming(unsigned int channel, unsigned int items_per_frame);
+ bool start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time);
+ bool sync_and_start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time);
bool rx_samples(unsigned int channel, rx_sample_handler *handler);
bool flush_rx_samples(unsigned int channel);
bool stop_rx_streaming(unsigned int channel);