aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/utils/serial_number.cpp
blob: 61296a913903de75facfb48669cd85a2bba471b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//
// 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 { namespace utils {
   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;
      } catch (std::invalid_argument& e) {
         return false;
      }
   }
}}