diff options
author | michael-west <michael.west@ettus.com> | 2014-06-12 14:41:02 -0700 |
---|---|---|
committer | Ben Hilburn <ben.hilburn@ettus.com> | 2014-07-17 18:16:04 -0700 |
commit | 208d85167838b0bb90d0938c791c1eae4b788e4d (patch) | |
tree | 5f0da4eb6cad249c9b6e332676f1ec234b0ed251 /host/lib/usrp/gps_ctrl.cpp | |
parent | 8f6e2ac9972151318bf6883d45ee099a5013ae1e (diff) | |
download | uhd-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.
Diffstat (limited to 'host/lib/usrp/gps_ctrl.cpp')
-rw-r--r-- | host/lib/usrp/gps_ctrl.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
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(); |