Commit graph

58 commits

Author SHA1 Message Date
Martin Braun
2d9a833747 uhd: Fix non-standard function name macros
Throughout UHD, we are using a random mix of __FUNCTION__, __func__,
__PRETTY_FUNCTION__, and BOOST_CURRENT_FUNCTION. Note that the first two
macros are non-standard (although many compilers understand them), and
the last requires Boost. __func__ is available since C++11, but is not
the best choice because the C++ standard doesn't require it to be of any
specific value.

We thus define UHD_FUNCTION and UHD_PRETTY_FUNCTION as portable macros.
The former simply contains the undecorated function name, the latter the
expanded function with full signature.

As it happens, our currently supported compilers didn't have any issues
using non-standard macros, so the main fix here is the removal of the
Boost macros and the harmonization of the other macros.
2022-01-12 15:07:54 -06:00
Martin Braun
b6119e581e uhd: Replace Boost mutexes and locks with standard options
This is a very mechanical task that could almost have been done with
sed. Boost versions of mutexes and locks were removed, and replaced with
std:: versions. The replacement tables are as follows:

== Mutexes ==
- boost::mutex -> std::mutex
- boost::recursive_mutex -> std::recursive_mutex

Mutexes behave identically between Boost and std:: and have the same
API.

== Locks ==
C++11 has only two types of lock that we use/need in UHD:
- std::lock_guard: Identical to boost::lock_guard
- std::unique_lock: Identical to boost::unique_lock

Boost also has boost::mutex::scoped_lock, which is a typedef for
boost::unique_lock<>. However, we often have used scoped_lock where we
meant to use lock_guard<>. The name is a bit misleading, "scoped lock"
sounding a bit like an RAII mechanism. Therefore, some previous
boost::mutex::scoped_lock are now std::lock_guard<>.

std::unique_lock is required when doing more than RAII locking (i.e.,
unlocking, relocking, usage with condition variables, etc.).

== Condition Variables ==
Condition variables were out of the scope of this lock/mutex change, but
in UHD, we inconsistently use boost::condition vs.
boost::condition_variable. The former is a templated version of the
latter, and thus works fine with std::mutex'es. Therefore, some
boost::condition_variable where changed to boost::condition.

All locks and mutexes use `#include <mutex>`. The corresponding Boost
includes were removed. In some cases, this exposed issues with implicit
Boost includes elsewhere. The missing explicit includes were added.
2021-10-19 12:21:33 -07:00
Martin Braun
107a49c0c2 host: Update code base using clang-tidy
The checks from the new clang-tidy file are applied to the source tree
using:

$ find . -name "*.cpp" | sort -u | xargs \
    --max-procs 8 --max-args 1 clang-tidy --format-style=file \
    --fix -p /path/to/compile_commands.json
2021-03-04 08:07:26 -06:00
Martin Braun
876d4150aa uhd: Apply clang-format against all .cpp and .hpp files in host/
Note: template_lvbitx.{cpp,hpp} need to be excluded from the list of
files that clang-format gets applied against.
2020-03-03 08:51:32 -06:00
Martin Braun
72b45bb8de uhd: Remove all usages of boost::tuple and friends
This replaces all of the following with standard C++ features:

- boost::tuple
- boost::make_tuple
- boost::tuple::get
- #include <boost/tuple/tuple.hpp>

All usages were replaced with search-and-replace scripts (the usages of
get could be automatically replaced with a vim macro, the rest was
straightforward search-and-replace).
2019-11-26 12:21:32 -08:00
Martin Braun
f773cf9fb9 uhd: Replace boost::regex with std::regex
boost::regex was a requirement until the minimum version of gcc was
increased. Since it is at version 5.3 now, using Boost.Regex is no
longer necessary.
This change is a pure search-and-replace; Boost and std versions of
regex are compatible and use the same syntax.
2019-11-26 12:21:32 -08:00
Martin Braun
8e3ea14c94 uhd: Remove usage of time_t (except when required)
The C/C++ standards don't define what time_t is, only that it is
arithmetic (and real for C11, and integral for C++). It should not be
used in portable software and is only used as the return value for some
libc calls.
A common definition for time_t is int64_t, so we'll switch to that
permanently in our own APIs. System APIs will of course stick with
time_t.
2018-08-20 16:56:43 -07:00
Martin Braun
5d9a7c92d3 lib: Purge use of boost::assign, except for uhd::dict
Replaced with initialization lists.
Note: uhd::dict does not work with initializer lists without making
changes to said data structure. This commit has no functional changes,
so keeping the boost::assigns for uhd::dict.
2018-05-02 17:01:21 -07:00
Martin Braun
0303f1ed55 lib: Purge all references to boost::this_thread::sleep()
Replace with std::this_thread::sleep_for().
2018-04-30 17:10:26 -07:00
Martin Braun
dc73f9df15 gps_ctrl: Replace boost::this_thread::sleep()
Use std::this_thread::sleep_for() instead.
2018-04-17 16:48:53 -07:00
Martin Braun
ae5211d71d uhd: Update license headers
All copyright is now attributed to "Ettus Research, a National
Instruments company".

SPDX headers were also updated to latest version 3.0.
2018-02-19 16:54:52 -08:00
Martin Braun
4f948e2c8b Move all license headers to SPDX format. 2017-12-22 10:45:51 -08:00
Andrej Rode
2ae347f12e gps_ctrl: dont use gmtime 2017-04-12 12:15:02 -07:00
Andrej Rode
3634302ff3 gps_ctrl: yeah windows, my friend 2017-04-12 12:15:02 -07:00
Andrej Rode
18cd5c46fc usrp: remove gregorian and lexical casting in gps_ctrl 2017-04-12 12:15:02 -07:00
Andrej Rode
21aad77c9c utils: introduce new logging API and remove msg API 2017-02-20 17:13:15 -08:00
Andrej Rode
26cc20847c uhd: replace BOOST_FOREACH with C++11 range-based for loop
Note: This is the first commit that uses for-range, and range-based
for-loops are now usable for UHD development.
2017-02-10 16:44:33 -08:00
michael-west
63fcfb9574 GPSDO: Improved detection
- Added re-sending of *IDN? command if no reply or unexpected string (i.e. during GPSDO firmware initialization)
- Shortened detection timeout to return sooner if no GPSDO present (faster initialization)
2017-02-01 15:20:04 -08:00
michael-west
c613c7edb4 GPS: Improvements to query_gpsdo_sensor
- Reordered operations to make sure setting clock and time sources is first
- Reduced delay waiting for ref lock
- Added wait for GPSDO warm up
- Made warning messages in gps_ctrl function into log messages to prevent unnecessary output
2017-01-30 09:36:38 +01:00
Martin Braun
99c2730bc9 Remove all boost:: namespace prefix for uint32_t, int32_t etc. (fixed-width types)
- Also removes all references to boost/cstdint.hpp and replaces it with
  stdint.h (The 'correct' replacement would be <cstdint>, but not all of our
  compilers support that).
2016-11-08 08:02:22 -08:00
Martin Braun
4b6d3db7eb gps: Removed redundant error message in case no GPS present
Signed-off-by: Martin Braun <martin.braun@ettus.com>
Reviewed-By: Moritz Fischer <moritz.fischer@ettus.com>
2016-09-27 09:02:10 -07:00
michael-west
23198a9092 Fix TXCO GPSDO recognition 2016-09-08 11:09:25 -07:00
michael-west
90a5d3153e gps_ctrl: Multiple fixes
- Check for updates if cached data is older than one millisecond
- Removed timeouts when checking for updated data from UART
- Subscribe to SERVO:TRACe message every second and process like NMEA strings
- Refactored code for simplification
2016-09-02 11:10:46 -07:00
michael-west
196e93a387 Add thread safety to gps_ctrl cached sensors 2016-09-02 11:10:46 -07:00
Nicholas Corgan
9b51e4cfbe gps_ctrl: code cleanup 2015-08-14 12:30:53 -07:00
Nicholas Corgan
654c5b06c0 Added missing pure virtual destructors to base classes 2014-09-01 17:58:24 +02:00
michael-west
afb4cb4d4a Updated copyright year. 2014-07-17 18:16:04 -07:00
michael-west
863953d972 - Changed variables from uint8_t to uint32_t so parsing of hex strings would work properly. 2014-07-17 18:16:04 -07:00
michael-west
208d851678 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.
2014-07-17 18:16:04 -07:00
michael-west
8f6e2ac997 Fix for BUG #469: Bad/Empty GPS NMEA strings returned when the queries are made in a random wait iterative fashion
Fix for BUG #460:  X300: GPGGA sensor most often empty, while RMC is usually OK
- Added checksum verification of NMEA strings
- Improved handling of short or malformed strings
- Fixed GPSDO data synchronization between X300 firmware and host
2014-07-17 18:16:04 -07:00
michael-west
d878f8e42b BUG #460: X300: GPGGA sensor most often empty, while RMC is usually OK
- It was found that strings containing only a newline character were being returned by N-series and X-series devices.
- Added better handling of strings received under 6 bytes.
- Added erasing of end of line characters.
2014-05-06 16:11:10 -07:00
Moritz Fischer
c1222d751a gps: Removed superfluous include.
* This file doesn't need boost::container::vector.

Tested-by: Marcus D. Leech <mleech@ripnet.com>
Signed-off-by: Moritz Fischer <moritz@ettus.com>
2014-03-23 20:27:19 +01:00
Ben Hilburn
ff1546f813 Pushing the bulk of UHD-3.7.0 code. 2014-02-14 12:05:07 -08:00
Ben Hilburn
178ac3f1c9 Merging USRP X300 and X310 support!! 2014-02-04 11:04:07 -08:00
Ben Hilburn
6f26689e35 cleaning up gpsdo docs 2013-12-19 16:13:41 -08:00
Ben Hilburn
9e47ad607b Squashed merge of Coverity fixes. 2013-11-27 12:11:23 -08:00
Josh Blum
f01d1a28e2 gps: only enable SERV:TRAC when requested 2013-04-09 21:20:26 -05:00
Josh Blum
31f0e964aa gps: flush uart buffer before waiting for time
This addresses a bug only on the master branch.
Also turn off the servo sensor, its too long a delay.
We will need to conditionally enable this in a later commit.
2013-04-09 20:34:23 -05:00
Moritz Fischer
a288d3bb2f gps_ctrl: Lower the number of retries to two when waiting for the time. 2012-11-13 14:47:06 -08:00
Moritz Fischer
99c9949eb1 gps_ctrl.cpp: Partially rewritten, to use caching instead of throwing
away the 'wrong' messages.

The old way to do this was when a sensor was requested, to wait for the
corresponding NMEA message to pass by, throwing away all the 'wrong'
ones in the meantime. However, this leads to problems if the user
requests combinations that are based on the same NMEA string.
To avoid this we now try to cache the strings for a 'freshness' period.
2012-10-19 16:45:50 -07:00
Nick Foster
efdc76514d Removed GPGSA from GPS driver since Firefly doesn't actually support it. 2012-05-16 10:54:09 -07:00
Josh Blum
902818f50b uhd: removed wax and props utils 2011-11-07 16:53:47 -08:00
Josh Blum
0d9421b7ab gps: use absolute timeout for communication 2011-09-28 10:32:05 -07:00
Josh Blum
25494489bf usrp2: uart/udp work in host and fw, working 2011-09-28 10:32:05 -07:00
Nick Foster
8009a340f7 gps_ctrl: make GPSDO parsing more robust, add retries 2011-08-11 13:32:47 -07:00
Nick Foster
cbd7ff3ad3 GPS ctrl fixes for uncooperative Firefly devices (Bastien Auneau) 2011-08-05 10:17:50 -07:00
Nick Foster
ab63a54088 Refactor GPS code to duplicate way less stuff, make members private 2011-06-17 16:01:24 -07:00
Nick Foster
9101804e6b USRP2/N210: set VITA time even if GPS not locked. harmless to do so. 2011-06-17 15:13:09 -07:00
Nick Foster
6f6364f73a UHD: implemented gps_locked sensor. usrp2 mboard doesn't init VITA time if time not valid. 2011-06-17 15:09:16 -07:00
Nick Foster
7af605b247 UHD: GPS work.
* Rewrote NMEA acquisition to be more general
* Added GPS sensors instead of member fns for data access
* GPS sensors added to mboard sensors to keep ABI compat
* VITA time initialized to GPS time on init
2011-06-17 13:35:40 -07:00