summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichael-west <michael.west@ettus.com>2014-06-12 14:41:02 -0700
committerBen Hilburn <ben.hilburn@ettus.com>2014-07-17 18:16:04 -0700
commit208d85167838b0bb90d0938c791c1eae4b788e4d (patch)
tree5f0da4eb6cad249c9b6e332676f1ec234b0ed251
parent8f6e2ac9972151318bf6883d45ee099a5013ae1e (diff)
downloaduhd-208d85167838b0bb90d0938c791c1eae4b788e4d.tar.gz
uhd-208d85167838b0bb90d0938c791c1eae4b788e4d.tar.bz2
uhd-208d85167838b0bb90d0938c791c1eae4b788e4d.zip
Addressing comments from review.
- Corrected types of some variables to be boost types. - Removed debugging code accidentally left in. - Changed some compiled out error messages to log messages.
-rw-r--r--firmware/x300/x300/x300_main.c11
-rw-r--r--host/lib/usrp/gps_ctrl.cpp20
-rw-r--r--host/lib/usrp/x300/x300_fw_uart.cpp16
3 files changed, 23 insertions, 24 deletions
diff --git a/firmware/x300/x300/x300_main.c b/firmware/x300/x300/x300_main.c
index 8717bf690..d865e1d09 100644
--- a/firmware/x300/x300/x300_main.c
+++ b/firmware/x300/x300/x300_main.c
@@ -1,4 +1,4 @@
-// Copyright 2013 Ettus Research LLC
+// Copyright 2013-2014 Ettus Research LLC
#include "x300_init.h"
#include "x300_defs.h"
@@ -445,24 +445,17 @@ int main(void)
static const uint32_t tick_delta = CPU_CLOCK/1000;
if (ticks_passed > tick_delta)
{
-// handle_link_state(); //deal with router table update
+ handle_link_state(); //deal with router table update
handle_claim(); //deal with the host claim register
-handle_uarts(); //udp_uart_poll();
update_leds(); //run the link and activity leds
-handle_uarts(); //udp_uart_poll();
garp(); //send periodic garps
-handle_uarts(); //udp_uart_poll();
xge_poll_sfpp_status(0); // Every so often poll XGE Phy to look for SFP+ hotplug events.
-handle_uarts(); //udp_uart_poll();
xge_poll_sfpp_status(1); // Every so often poll XGE Phy to look for SFP+ hotplug events.
-handle_uarts(); //udp_uart_poll();
last_cronjob = wb_peek32(SR_ADDR(RB0_BASE, RB_COUNTER));
}
-//handle_uarts(); //udp_uart_poll();
//run the network stack - poll and handle
u3_net_stack_handle_one();
-handle_uarts(); //udp_uart_poll();
//run the PCIe listener - poll and fwd to wishbone
forward_pcie_user_xact_to_wb();
diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp
index b211ba027..3d7684849 100644
--- a/host/lib/usrp/gps_ctrl.cpp
+++ b/host/lib/usrp/gps_ctrl.cpp
@@ -17,6 +17,7 @@
#include <uhd/usrp/gps_ctrl.hpp>
#include <uhd/utils/msg.hpp>
+#include <uhd/utils/log.hpp>
#include <uhd/exception.hpp>
#include <uhd/types/sensors.hpp>
#include <boost/algorithm/string.hpp>
@@ -67,12 +68,19 @@ private:
if (nmea.length() < 5 || nmea[0] != '$' || nmea[nmea.length()-3] != '*')
return false;
- uint8_t string_crc = uint8_t(strtol(nmea.substr(nmea.length()-2, 2).c_str(), NULL, 16));
- uint8_t calculated_crc = 0;
+ std::stringstream ss;
+ boost::uint8_t string_crc;
+ boost::uint8_t calculated_crc = 0;
+ // get crc from string
+ ss << std::hex << nmea.substr(nmea.length()-2, 2);
+ ss >> string_crc;
+
+ // calculate crc
for (size_t i = 1; i < nmea.length()-3; i++)
calculated_crc ^= nmea[i];
+ // return comparison
return (string_crc == calculated_crc);
}
@@ -97,9 +105,7 @@ private:
if (msg.length() < 6)
{
-#ifdef DEBUG_GPS
- UHD_MSG(error) << __FUNCTION__ << ": Short NMEA string: " << msg << std::endl;
-#endif
+ UHD_LOGV(regularly) << __FUNCTION__ << ": Short NMEA string: " << msg << std::endl;
continue;
}
@@ -112,12 +118,10 @@ private:
{
msgs[msg.substr(1,5)] = msg;
}
-#ifdef DEBUG_GPS
else
{
- UHD_MSG(error) << __FUNCTION__ << ": Malformed NMEA string: " << msg << std::endl;
+ UHD_LOGV(regularly) << __FUNCTION__ << ": Malformed NMEA string: " << msg << std::endl;
}
-#endif
}
boost::system_time time = boost::get_system_time();
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)