From b772b5b2cb8b0c55187142e69e4abe22ef27df5c Mon Sep 17 00:00:00 2001 From: Lars Amsel Date: Fri, 19 Jun 2020 13:29:33 +0200 Subject: cal: change default extension of calibration files Flatbuffers offers an option to set the default extension for binary files. Our calibration files have the extension .cal. Set the extension in all schema files to ease conversion between binary and text representation of calibration files. Updated documentation accordingly. --- host/docs/calibration.dox | 4 ++-- host/include/uhd/cal/iq_cal.fbs | 1 + host/include/uhd/cal/iq_cal_generated.h | 28 +++++++++++++++++++--------- host/include/uhd/cal/pwr_cal.fbs | 1 + host/include/uhd/cal/pwr_cal_generated.h | 12 +++++++----- 5 files changed, 30 insertions(+), 16 deletions(-) (limited to 'host') diff --git a/host/docs/calibration.dox b/host/docs/calibration.dox index 162bd8825..90beda82d 100644 --- a/host/docs/calibration.dox +++ b/host/docs/calibration.dox @@ -97,8 +97,8 @@ The JSON data can be converted back to binary using flatc -b /include/uhd/cal/_cal.fbs .json -This generates a `.bin` that can be read by the calibration routines -of UHD. To make UHD reading these files you need to rename it to `.cal`. +This generates a `.cal` that can be read by the calibration routines +of UHD. \subsection calibration_data_csv Converting UHD 3.x calibration data to UHD 4 diff --git a/host/include/uhd/cal/iq_cal.fbs b/host/include/uhd/cal/iq_cal.fbs index 55c9ae3de..8aeda185e 100644 --- a/host/include/uhd/cal/iq_cal.fbs +++ b/host/include/uhd/cal/iq_cal.fbs @@ -30,3 +30,4 @@ table IQCalCoeffs root_type IQCalCoeffs; file_identifier "IQ/f"; // I/Q data per frequency +file_extension "cal"; diff --git a/host/include/uhd/cal/iq_cal_generated.h b/host/include/uhd/cal/iq_cal_generated.h index f0dfa0b82..0e5aabb1c 100644 --- a/host/include/uhd/cal/iq_cal_generated.h +++ b/host/include/uhd/cal/iq_cal_generated.h @@ -15,6 +15,7 @@ namespace cal { struct IQCalCoeff; struct IQCalCoeffs; +struct IQCalCoeffsBuilder; FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) IQCalCoeff FLATBUFFERS_FINAL_CLASS { private: @@ -25,8 +26,12 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) IQCalCoeff FLATBUFFERS_FINAL_CLASS { double suppression_delta_; public: - IQCalCoeff() { - memset(static_cast(this), 0, sizeof(IQCalCoeff)); + IQCalCoeff() + : freq_(0), + coeff_real_(0), + coeff_imag_(0), + suppression_abs_(0), + suppression_delta_(0) { } IQCalCoeff(double _freq, double _coeff_real, double _coeff_imag, double _suppression_abs, double _suppression_delta) : freq_(flatbuffers::EndianScalar(_freq)), @@ -54,6 +59,7 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) IQCalCoeff FLATBUFFERS_FINAL_CLASS { FLATBUFFERS_STRUCT_END(IQCalCoeff, 40); struct IQCalCoeffs FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef IQCalCoeffsBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_METADATA = 4, VT_COEFFS = 6 @@ -61,8 +67,8 @@ struct IQCalCoeffs FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { const Metadata *metadata() const { return GetPointer(VT_METADATA); } - const flatbuffers::Vector *coeffs() const { - return GetPointer *>(VT_COEFFS); + const flatbuffers::Vector *coeffs() const { + return GetPointer *>(VT_COEFFS); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && @@ -75,19 +81,19 @@ struct IQCalCoeffs FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { }; struct IQCalCoeffsBuilder { + typedef IQCalCoeffs Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_metadata(flatbuffers::Offset metadata) { fbb_.AddOffset(IQCalCoeffs::VT_METADATA, metadata); } - void add_coeffs(flatbuffers::Offset> coeffs) { + void add_coeffs(flatbuffers::Offset> coeffs) { fbb_.AddOffset(IQCalCoeffs::VT_COEFFS, coeffs); } explicit IQCalCoeffsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - IQCalCoeffsBuilder &operator=(const IQCalCoeffsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -98,7 +104,7 @@ struct IQCalCoeffsBuilder { inline flatbuffers::Offset CreateIQCalCoeffs( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset metadata = 0, - flatbuffers::Offset> coeffs = 0) { + flatbuffers::Offset> coeffs = 0) { IQCalCoeffsBuilder builder_(_fbb); builder_.add_coeffs(coeffs); builder_.add_metadata(metadata); @@ -108,8 +114,8 @@ inline flatbuffers::Offset CreateIQCalCoeffs( inline flatbuffers::Offset CreateIQCalCoeffsDirect( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset metadata = 0, - const std::vector *coeffs = nullptr) { - auto coeffs__ = coeffs ? _fbb.CreateVectorOfStructs(*coeffs) : 0; + const std::vector *coeffs = nullptr) { + auto coeffs__ = coeffs ? _fbb.CreateVectorOfStructs(*coeffs) : 0; return uhd::usrp::cal::CreateIQCalCoeffs( _fbb, metadata, @@ -143,6 +149,10 @@ inline bool VerifySizePrefixedIQCalCoeffsBuffer( return verifier.VerifySizePrefixedBuffer(IQCalCoeffsIdentifier()); } +inline const char *IQCalCoeffsExtension() { + return "cal"; +} + inline void FinishIQCalCoeffsBuffer( flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset root) { diff --git a/host/include/uhd/cal/pwr_cal.fbs b/host/include/uhd/cal/pwr_cal.fbs index 7cf66feee..6aa19d10f 100644 --- a/host/include/uhd/cal/pwr_cal.fbs +++ b/host/include/uhd/cal/pwr_cal.fbs @@ -44,3 +44,4 @@ table PowerCal root_type PowerCal; file_identifier "dB/m"; // dB per dBm +file_extension "cal"; diff --git a/host/include/uhd/cal/pwr_cal_generated.h b/host/include/uhd/cal/pwr_cal_generated.h index f7ea8d8a7..6dc6cc103 100644 --- a/host/include/uhd/cal/pwr_cal_generated.h +++ b/host/include/uhd/cal/pwr_cal_generated.h @@ -29,8 +29,9 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) PowerMap FLATBUFFERS_FINAL_CLASS { double power_dbm_; public: - PowerMap() { - memset(static_cast(this), 0, sizeof(PowerMap)); + PowerMap() + : gain_(0), + power_dbm_(0) { } PowerMap(double _gain, double _power_dbm) : gain_(flatbuffers::EndianScalar(_gain)), @@ -108,7 +109,6 @@ struct FreqPowerMapBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - FreqPowerMapBuilder &operator=(const FreqPowerMapBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -187,7 +187,6 @@ struct TempFreqMapBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TempFreqMapBuilder &operator=(const TempFreqMapBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -261,7 +260,6 @@ struct PowerCalBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - PowerCalBuilder &operator=(const PowerCalBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -321,6 +319,10 @@ inline bool VerifySizePrefixedPowerCalBuffer( return verifier.VerifySizePrefixedBuffer(PowerCalIdentifier()); } +inline const char *PowerCalExtension() { + return "cal"; +} + inline void FinishPowerCalBuffer( flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset root) { -- cgit v1.2.3