diff options
| author | Josh Blum <josh@joshknows.com> | 2010-04-03 19:43:20 -0700 | 
|---|---|---|
| committer | Josh Blum <josh@joshknows.com> | 2010-04-03 19:43:20 -0700 | 
| commit | 83bd55d63972804e62f3890a4a90c8288fcbad0c (patch) | |
| tree | b5bf6a8877b37b238f9f540b0b77d1425ed619b9 /host/lib/usrp/usrp2 | |
| parent | f4ccb204473884126bcff6551d224e263dd5102a (diff) | |
| download | uhd-83bd55d63972804e62f3890a4a90c8288fcbad0c.tar.gz uhd-83bd55d63972804e62f3890a4a90c8288fcbad0c.tar.bz2 uhd-83bd55d63972804e62f3890a4a90c8288fcbad0c.zip | |
extended stream cmd with mode enum, and extended fragment flags in metadata
Diffstat (limited to 'host/lib/usrp/usrp2')
| -rw-r--r-- | host/lib/usrp/usrp2/dsp_impl.cpp | 30 | ||||
| -rw-r--r-- | host/lib/usrp/usrp2/fw_common.h | 3 | ||||
| -rw-r--r-- | host/lib/usrp/usrp2/io_impl.cpp | 7 | ||||
| -rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.hpp | 1 | 
4 files changed, 33 insertions, 8 deletions
| 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 | 
