diff options
Diffstat (limited to 'host/lib/utils/serial_number.cpp')
-rw-r--r-- | host/lib/utils/serial_number.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/host/lib/utils/serial_number.cpp b/host/lib/utils/serial_number.cpp new file mode 100644 index 000000000..7fd0863d6 --- /dev/null +++ b/host/lib/utils/serial_number.cpp @@ -0,0 +1,23 @@ +// +// Copyright 2020 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#include <uhdlib/utils/serial_number.hpp> +#include <stdexcept> +#include <string> + +namespace uhd +{ + bool serial_numbers_match(const std::string& serial_a, const std::string& serial_b) + { + try { + const uint32_t a = std::stoi(serial_a, 0, 16); + const uint32_t b = std::stoi(serial_b, 0, 16); + return a == b; + } catch (std::out_of_range& e) { + return false; + } + } +} |