diff options
-rw-r--r-- | host/lib/usrp/b200/b200_impl.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_uart.cpp | 23 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_uart.hpp | 1 |
3 files changed, 12 insertions, 20 deletions
diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index d7663c68e..5389e4773 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -460,6 +460,10 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //////////////////////////////////////////////////////////////////// _async_task_data.reset(new AsyncTaskData()); _async_task_data->async_md.reset(new async_md_type(1000/*messages deep*/)); + if (_gpsdo_capable) + { + _async_task_data->gpsdo_uart = b200_uart::make(_ctrl_transport, B200_TX_GPS_UART_SID); + } _async_task = uhd::msg_task::make(boost::bind(&b200_impl::handle_async_task, this, _ctrl_transport, _async_task_data)); //////////////////////////////////////////////////////////////////// @@ -480,10 +484,6 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //////////////////////////////////////////////////////////////////// if (_gpsdo_capable) { - _async_task_data->gpsdo_uart = b200_uart::make(_ctrl_transport, B200_TX_GPS_UART_SID); - _async_task_data->gpsdo_uart->set_baud_divider(B200_BUS_CLOCK_RATE/115200); - _async_task_data->gpsdo_uart->write_uart("\n"); //cause the baud and response to be setup - boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for a little propagation if ((_local_ctrl->peek32(RB32_CORE_STATUS) & 0xff) != B200_GPSDO_ST_NONE) { diff --git a/host/lib/usrp/b200/b200_uart.cpp b/host/lib/usrp/b200/b200_uart.cpp index f86b41609..065aa49ce 100644 --- a/host/lib/usrp/b200/b200_uart.cpp +++ b/host/lib/usrp/b200/b200_uart.cpp @@ -16,12 +16,14 @@ // #include "b200_uart.hpp" +#include "b200_impl.hpp" #include <uhd/transport/bounded_buffer.hpp> #include <uhd/transport/vrt_if_packet.hpp> #include <uhd/utils/byteswap.hpp> #include <uhd/utils/msg.hpp> #include <uhd/types/time_spec.hpp> #include <uhd/exception.hpp> +#include <boost/foreach.hpp> using namespace uhd; using namespace uhd::transport; @@ -32,10 +34,10 @@ struct b200_uart_impl : b200_uart _xport(xport), _sid(sid), _count(0), + _baud_div(std::floor(B200_BUS_CLOCK_RATE/115200 + 0.5)), _line_queue(4096) { - //this default baud divider is over 9000 - this->set_baud_divider(9001); + /*NOP*/ } void send_char(const char ch) @@ -67,10 +69,9 @@ struct b200_uart_impl : b200_uart void write_uart(const std::string &buff) { - for (size_t i = 0; i < buff.size(); i++) + BOOST_FOREACH(const char ch, buff) { - if (buff[i] == '\n') this->send_char('\r'); - this->send_char(buff[i]); + this->send_char(ch); } } @@ -89,22 +90,14 @@ struct b200_uart_impl : b200_uart packet_info.num_packet_words32 = buff->size()/sizeof(boost::uint32_t); vrt::if_hdr_unpack_le(packet_buff, packet_info); const char ch = char(uhd::wtohx(packet_buff[packet_info.num_header_words32+1])); - if (ch != '\r') - _line += ch; + _line += ch; if (ch == '\n') { - // Don't store empty strings - if (_line.length() > 1) - _line_queue.push_with_pop_on_full(_line); + _line_queue.push_with_pop_on_full(_line); _line.clear(); } } - void set_baud_divider(const double baud_div) - { - _baud_div = size_t(baud_div + 0.5); - } - const zero_copy_if::sptr _xport; const boost::uint32_t _sid; size_t _count; diff --git a/host/lib/usrp/b200/b200_uart.hpp b/host/lib/usrp/b200/b200_uart.hpp index 1c8e44ddc..f58479888 100644 --- a/host/lib/usrp/b200/b200_uart.hpp +++ b/host/lib/usrp/b200/b200_uart.hpp @@ -29,7 +29,6 @@ public: typedef boost::shared_ptr<b200_uart> sptr; static sptr make(uhd::transport::zero_copy_if::sptr, const boost::uint32_t sid); virtual void handle_uart_packet(uhd::transport::managed_recv_buffer::sptr buff) = 0; - virtual void set_baud_divider(const double baud_div) = 0; }; |