summaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/types.cpp7
-rw-r--r--host/lib/usrp/usrp2/dsp_impl.cpp30
-rw-r--r--host/lib/usrp/usrp2/fw_common.h3
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp7
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp1
5 files changed, 37 insertions, 11 deletions
diff --git a/host/lib/types.cpp b/host/lib/types.cpp
index bf9f8b895..d87238161 100644
--- a/host/lib/types.cpp
+++ b/host/lib/types.cpp
@@ -71,9 +71,9 @@ clock_config_t::clock_config_t(void){
/***********************************************************************
* stream command
**********************************************************************/
-stream_cmd_t::stream_cmd_t(void){
+stream_cmd_t::stream_cmd_t(const stream_mode_t &stream_mode_){
+ stream_mode = stream_mode_;
stream_now = true;
- continuous = false;
num_samps = 0;
}
@@ -85,7 +85,8 @@ rx_metadata_t::rx_metadata_t(void){
has_stream_id = false;
time_spec = time_spec_t();
has_time_spec = false;
- is_fragment = false;
+ more_fragments = false;
+ fragment_offset = 0;
}
tx_metadata_t::tx_metadata_t(void){
diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp
index d70248682..647a8bf1c 100644
--- a/host/lib/usrp/usrp2/dsp_impl.cpp
+++ b/host/lib/usrp/usrp2/dsp_impl.cpp
@@ -67,11 +67,7 @@ void usrp2_impl::init_ddc_config(void){
update_ddc_config();
//initial command that kills streaming (in case if was left on)
- stream_cmd_t stream_cmd_off;
- stream_cmd_off.stream_now = true;
- stream_cmd_off.continuous = false;
- stream_cmd_off.num_samps = 0;
- issue_ddc_stream_cmd(stream_cmd_off);
+ issue_ddc_stream_cmd(stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
}
void usrp2_impl::update_ddc_config(void){
@@ -90,11 +86,33 @@ void usrp2_impl::issue_ddc_stream_cmd(const stream_cmd_t &stream_cmd){
usrp2_ctrl_data_t out_data;
out_data.id = htonl(USRP2_CTRL_ID_SEND_STREAM_COMMAND_FOR_ME_BRO);
out_data.data.stream_cmd.now = (stream_cmd.stream_now)? 1 : 0;
- out_data.data.stream_cmd.continuous = (stream_cmd.continuous)? 1 : 0;
out_data.data.stream_cmd.secs = htonl(stream_cmd.time_spec.secs);
out_data.data.stream_cmd.ticks = htonl(stream_cmd.time_spec.ticks);
+
+ //set these to defaults, then change in the switch statement
+ out_data.data.stream_cmd.continuous = 0;
+ out_data.data.stream_cmd.chain = 0;
out_data.data.stream_cmd.num_samps = htonl(stream_cmd.num_samps);
+ //setup chain, num samps, and continuous below
+ switch(stream_cmd.stream_mode){
+ case stream_cmd_t::STREAM_MODE_START_CONTINUOUS:
+ out_data.data.stream_cmd.continuous = 1;
+ break;
+
+ case stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS:
+ out_data.data.stream_cmd.num_samps = htonl(0);
+ break;
+
+ case stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE:
+ //all set by defaults above
+ break;
+
+ case stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_MORE:
+ out_data.data.stream_cmd.chain = 1;
+ break;
+ }
+
//send and recv
usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_GOT_THAT_STREAM_COMMAND_DUDE);
diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h
index c168614ee..7f35c8abd 100644
--- a/host/lib/usrp/usrp2/fw_common.h
+++ b/host/lib/usrp/usrp2/fw_common.h
@@ -129,7 +129,8 @@ typedef struct{
struct {
_SINS_ uint8_t now; //stream now?
_SINS_ uint8_t continuous; //auto-reload commmands?
- _SINS_ uint8_t _pad[2];
+ _SINS_ uint8_t chain;
+ _SINS_ uint8_t _pad[1];
_SINS_ uint32_t secs;
_SINS_ uint32_t ticks;
_SINS_ uint32_t num_samps;
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index c87884ebb..5820841d7 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -222,12 +222,12 @@ size_t usrp2_impl::recv(
){
//perform a receive if no rx data is waiting to be copied
if (asio::buffer_size(_rx_copy_buff) == 0){
+ _fragment_offset_in_samps = 0;
recv_raw(metadata);
}
//otherwise flag the metadata to show that is is a fragment
else{
metadata = rx_metadata_t();
- metadata.is_fragment = true;
}
//extract the number of samples available to copy
@@ -240,6 +240,11 @@ size_t usrp2_impl::recv(
);
const boost::uint32_t *items = asio::buffer_cast<const boost::uint32_t*>(_rx_copy_buff);
+ //setup the fragment flags and offset
+ metadata.more_fragments = asio::buffer_size(buff)/io_type.size < num_samps;
+ metadata.fragment_offset = _fragment_offset_in_samps;
+ _fragment_offset_in_samps += num_samps; //set for next time
+
//copy the samples from the recv buffer
switch(io_type.tid){
case io_type_t::COMPLEX_FLOAT32:
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 55be420cd..7c55d4c3c 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -135,6 +135,7 @@ private:
;
uhd::transport::smart_buffer::sptr _rx_smart_buff;
boost::asio::const_buffer _rx_copy_buff;
+ size_t _fragment_offset_in_samps;
void io_init(void);
//udp transports for control and data