diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-05-19 11:12:34 -0700 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-05-20 07:30:15 -0500 |
commit | d7287678358b59993d5cace77ffbd0564ebe7593 (patch) | |
tree | c3729ae04412178a5b6cf004cec8f220f959f05d /host/include | |
parent | 746f9c7f0e3fb8c2f9e480ba2bad4527ce9eb34a (diff) | |
download | uhd-d7287678358b59993d5cace77ffbd0564ebe7593.tar.gz uhd-d7287678358b59993d5cace77ffbd0564ebe7593.tar.bz2 uhd-d7287678358b59993d5cace77ffbd0564ebe7593.zip |
cal: database: Add option to register flash cal callbacks
This adds the possibility to read cal data from flash/EEPROM by adding
callbacks to the database. Unlike the RC and FILESYSTEM data, this is
very device-specific, but we can let devices register callbacks in the
database so that reading cal data from flash can use the same APIs as
from RC or filesystem.
Note that this also gives a convenient way to inject call data during
unit tests, if desired.
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/cal/database.hpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/host/include/uhd/cal/database.hpp b/host/include/uhd/cal/database.hpp index a4c233030..b6abbb6df 100644 --- a/host/include/uhd/cal/database.hpp +++ b/host/include/uhd/cal/database.hpp @@ -10,6 +10,7 @@ #include <stddef.h> #include <string> #include <vector> +#include <functional> namespace uhd { namespace usrp { namespace cal { @@ -65,7 +66,6 @@ enum class source { class UHD_API database { public: - //! Return a calibration data set as a serialized string // // Note: the \p source_type parameter can be used to specify where to read @@ -130,6 +130,28 @@ public: const std::string& serial, const std::vector<uint8_t>& cal_data, const std::string& backup_ext = ""); + + //! Function type to look up if there is cal data given a key and serial + using has_data_fn_type = std::function<bool(const std::string&, const std::string&)>; + + //! Function type to return serialized cal data key and serial + // + // These functions should throw a uhd::runtime_error if called with invalid + // key/serial pairs, although database will internally always call the + // corresponding 'has' function before calling this. + using get_data_fn_type = + std::function<std::vector<uint8_t>(const std::string&, const std::string&)>; + + //! Register a lookup function for cal data + // + // \param has_cal_data A function object to a function that returns true if + // cal data is available + // \param get_cal_data A function object to a function that returns serialized + // cal data + // \param source_type Reserved. Must be source::FLASH. + static void register_lookup(has_data_fn_type has_cal_data, + get_data_fn_type get_cal_data, + const source source_type = source::FLASH); }; |