diff options
Diffstat (limited to 'host/lib/usrp/x300')
-rw-r--r-- | host/lib/usrp/x300/x300_fw_uart.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/host/lib/usrp/x300/x300_fw_uart.cpp b/host/lib/usrp/x300/x300_fw_uart.cpp index 4bf103c5a..d87b9ab9f 100644 --- a/host/lib/usrp/x300/x300_fw_uart.cpp +++ b/host/lib/usrp/x300/x300_fw_uart.cpp @@ -69,25 +69,25 @@ struct x300_uart_iface : uart_iface return -1; rxoffset++; - return int(_rxcache[((rxoffset)/4) % poolsize] >> ((rxoffset%4)*8) & 0xFF); + return static_cast<int>(_rxcache[(rxoffset/4) % poolsize] >> ((rxoffset%4)*8) & 0xFF); } void update_cache(void) { - uint32_t device_rxoffset = _iface->peek32(SR_ADDR(X300_FW_SHMEM_BASE, X300_FW_SHMEM_UART_RX_INDEX)); - uint32_t delta = device_rxoffset - rxoffset; + boost::uint32_t device_rxoffset = _iface->peek32(SR_ADDR(X300_FW_SHMEM_BASE, X300_FW_SHMEM_UART_RX_INDEX)); + boost::uint32_t delta = device_rxoffset - rxoffset; while (delta) { if (delta >= poolsize*4) { // all the data is new - reload the entire cache - for (uint32_t i = 0; i < poolsize; i++) + for (boost::uint32_t i = 0; i < poolsize; i++) _rxcache[i] = _iface->peek32(SR_ADDR(rxpool, i)); // set rxoffset to the end of the first string rxoffset = device_rxoffset - (poolsize*4) + 1; - while (uint8_t(_rxcache[(rxoffset/4) % poolsize] >> ((rxoffset % 4) * 8)) != '\n') + while (static_cast<char>((_rxcache[(rxoffset/4) % poolsize] >> ((rxoffset%4)*8) & 0xFF)) != '\n') ++rxoffset; // clear the partial string in the buffer; @@ -96,7 +96,7 @@ struct x300_uart_iface : uart_iface else if (rxoffset == _last_device_rxoffset) { // new data was added - refresh the portion of the cache that was updated - for (uint32_t i = ((_last_device_rxoffset+1)/4) % poolsize; i != (((device_rxoffset)/4)+1) % poolsize; i = (i+1) % poolsize) + for (boost::uint32_t i = ((_last_device_rxoffset+1)/4) % poolsize; i != (((device_rxoffset)/4)+1) % poolsize; i = (i+1) % poolsize) { _rxcache[i] = _iface->peek32(SR_ADDR(rxpool, i)); } @@ -115,6 +115,7 @@ struct x300_uart_iface : uart_iface std::string read_uart(double timeout) { + boost::mutex::scoped_lock(_read_mutex); const boost::system_time exit_time = boost::get_system_time() + boost::posix_time::microseconds(long(timeout*1e6)); std::string buff; @@ -153,8 +154,9 @@ struct x300_uart_iface : uart_iface wb_iface::sptr _iface; boost::uint32_t rxoffset, txoffset, txword32, rxpool, txpool, poolsize; boost::uint32_t _last_device_rxoffset; - std::vector<uint32_t> _rxcache; + std::vector<boost::uint32_t> _rxcache; std::string _rxbuff; + boost::mutex _read_mutex; }; uart_iface::sptr x300_make_uart_iface(wb_iface::sptr iface) |