aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/b200/b200_uart.cpp
diff options
context:
space:
mode:
authormichael-west <michael.west@ettus.com>2016-08-15 11:18:37 -0700
committerMartin Braun <martin.braun@ettus.com>2016-09-02 11:10:46 -0700
commitb229a1972c421c90420363ce1f93be91cc9bd2aa (patch)
tree4d69673e6e5e18f13620a2cda54453325a420288 /host/lib/usrp/b200/b200_uart.cpp
parent90a5d3153e04b6d0b95e51bc84cf396a4e009c07 (diff)
downloaduhd-b229a1972c421c90420363ce1f93be91cc9bd2aa.tar.gz
uhd-b229a1972c421c90420363ce1f93be91cc9bd2aa.tar.bz2
uhd-b229a1972c421c90420363ce1f93be91cc9bd2aa.zip
B200: GPSDO fixes
- Fix initialization order - Initialize to proper baud rate divisor - Remove unused function to change baud rate divisor - Simplify UART code so it does not strip or add characters
Diffstat (limited to 'host/lib/usrp/b200/b200_uart.cpp')
-rw-r--r--host/lib/usrp/b200/b200_uart.cpp23
1 files changed, 8 insertions, 15 deletions
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;