diff options
Diffstat (limited to 'host/lib/transport/udp_simple.cpp')
-rw-r--r-- | host/lib/transport/udp_simple.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/host/lib/transport/udp_simple.cpp b/host/lib/transport/udp_simple.cpp index 347373c71..8b6e5eb2b 100644 --- a/host/lib/transport/udp_simple.cpp +++ b/host/lib/transport/udp_simple.cpp @@ -114,9 +114,16 @@ public: do{ //drain anything in current buffer while (_off < _len){ - const char ch = _buf[_off]; _off++; - line += std::string(1, ch); - if (ch == '\n' or ch == '\r') return line; + const char ch = _buf[_off++]; + if (ch == '\r') continue; + if (ch == '\n' and _line.empty()) continue; + _line += ch; + if (ch == '\n') + { + line = _line; + _line.clear(); + return line; + } } //recv a new packet into the buffer @@ -131,6 +138,7 @@ private: udp_simple::sptr _udp; size_t _len, _off; boost::uint8_t _buf[udp_simple::mtu]; + std::string _line; }; uhd::uart_iface::sptr udp_simple::make_uart(sptr udp){ |