Advertisement
Guest User

Untitled

a guest
Apr 6th, 2012
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. Index: Transceiver52M/UHDDevice.cpp
  2. ===================================================================
  3. --- Transceiver52M/UHDDevice.cpp (revision 3400)
  4. +++ Transceiver52M/UHDDevice.cpp (working copy)
  5. @@ -65,14 +65,12 @@
  6. */
  7. uhd::time_spec_t convert_time(TIMESTAMP ticks, double rate)
  8. {
  9. - double secs = (double) ticks / rate;
  10. - return uhd::time_spec_t(secs);
  11. + return uhd::time_spec_t::from_ticks(ticks, rate);
  12. }
  13.  
  14. TIMESTAMP convert_time(uhd::time_spec_t ts, double rate)
  15. {
  16. - TIMESTAMP ticks = ts.get_full_secs() * rate;
  17. - return ts.get_tick_count(rate) + ticks;
  18. + return ts.to_ticks(rate);
  19. }
  20.  
  21. /*
  22. @@ -204,6 +202,8 @@
  23.  
  24. private:
  25. uhd::usrp::multi_usrp::sptr usrp_dev;
  26. + uhd::tx_streamer::sptr tx_stream;
  27. + uhd::rx_streamer::sptr rx_stream;
  28. enum busType bus;
  29.  
  30. double desired_smpl_rt, actual_smpl_rt;
  31. @@ -452,9 +452,14 @@
  32. set_ref_clk(true);
  33. #endif
  34.  
  35. + //create a TX and RX streamers
  36. + uhd::stream_args_t stream_args("sc16"); //complex shorts
  37. + tx_stream = usrp_dev->get_tx_stream(stream_args);
  38. + rx_stream = usrp_dev->get_rx_stream(stream_args);
  39. +
  40. // Number of samples per over-the-wire packet
  41. - tx_spp = usrp_dev->get_device()->get_max_send_samps_per_packet();
  42. - rx_spp = usrp_dev->get_device()->get_max_recv_samps_per_packet();
  43. + tx_spp = tx_stream->get_max_num_samps();
  44. + rx_spp = rx_stream->get_max_num_samps();
  45.  
  46. // Set rates
  47. actual_smpl_rt = set_rates(desired_smpl_rt);
  48. @@ -488,13 +493,12 @@
  49. timeout = .01;
  50.  
  51. for (size_t i = 0; i < num_pkts; i++) {
  52. - num_smpls = usrp_dev->get_device()->recv(
  53. + num_smpls = rx_stream->recv(
  54. buff,
  55. rx_spp,
  56. md,
  57. - uhd::io_type_t::COMPLEX_INT16,
  58. - uhd::device::RECV_MODE_ONE_PACKET,
  59. - timeout);
  60. + timeout,
  61. + true/*one pkt*/);
  62.  
  63. if (!num_smpls) {
  64. switch (md.error_code) {
  65. @@ -634,12 +638,12 @@
  66.  
  67. // Receive samples from the usrp until we have enough
  68. while (rx_smpl_buf->avail_smpls(timestamp) < len) {
  69. - size_t num_smpls = usrp_dev->get_device()->recv(
  70. + size_t num_smpls = rx_stream->recv(
  71. (void*)pkt_buf,
  72. rx_spp,
  73. metadata,
  74. - uhd::io_type_t::COMPLEX_INT16,
  75. - uhd::device::RECV_MODE_ONE_PACKET);
  76. + 0.1 /*timeout secs*/,
  77. + true /*one pkt*/);
  78.  
  79. rx_pkt_cnt++;
  80.  
  81. @@ -718,11 +722,7 @@
  82. }
  83. }
  84.  
  85. - size_t num_smpls = usrp_dev->get_device()->send(buf,
  86. - len,
  87. - metadata,
  88. - uhd::io_type_t::COMPLEX_INT16,
  89. - uhd::device::SEND_MODE_FULL_BUFF);
  90. + size_t num_smpls = tx_stream->send(buf, len, metadata);
  91.  
  92. if (num_smpls != (unsigned) len) {
  93. LOG(ALERT) << "UHD: Device send timed out";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement