Skip to content

Commit

Permalink
Merge pull request #10 from nqrduck/dump_from_vector
Browse files Browse the repository at this point in the history
Refactor configuration array to vector. 
Tested with LimeSDR USB - works!
  • Loading branch information
jupfi authored Feb 7, 2024
2 parents 8edfbda + 77b3f90 commit 980ae5a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/limedriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ HDF5 library
#include "H5Cpp.h"
#include "lime/LimeSuite.h"
#include <chrono>
#include <cstddef>
#include <cstdlib>
#include <fstream>
#include <iomanip>
Expand Down Expand Up @@ -370,14 +371,14 @@ std::vector<Config2HDFattr_t> getHDFAttributes(LimeConfig_t& LimeCfg) {
return HDFattr;
}

void dumpConfig(Config2HDFattr_t *config, size_t size) {
void dumpConfig(std::vector<Config2HDFattr_t> &config) {
/* Dump the configuration to stdout in JSON format
@param config: Array of Config2HDFattr_t
@param size: Size of the array
*/

size_t size = config.size();

int ii_oupargs = 0; // TODO: Better name

std::cout << "{" << std::endl;
Expand Down Expand Up @@ -774,10 +775,6 @@ int main(int argc, char **argv) {
std::vector<Config2HDFattr_t> HDFattrVector = getHDFAttributes(LimeCfg);
size_t no_of_attr = HDFattrVector.size();

// Converting to array to maintain compatibility with older code
Config2HDFattr_t HDFattr[no_of_attr];
std::copy(HDFattrVector.begin(), HDFattrVector.end(), HDFattr);

bool dumpFlag = false;

// Checking for dump flag
Expand All @@ -789,7 +786,7 @@ int main(int argc, char **argv) {

// If dump flag is set, dump the config and exit
if (dumpFlag) {
dumpConfig(HDFattr, no_of_attr);
dumpConfig(HDFattrVector);
std::exit(0);
}

Expand All @@ -806,7 +803,8 @@ int main(int argc, char **argv) {
return 1;
}

// Converting to array to maintain compatibility with older code and update
// Converting to array to maintain compatibility with older code
Config2HDFattr_t HDFattr[no_of_attr];
std::copy(HDFattrVector.begin(), HDFattrVector.end(), HDFattr);

// Find devices
Expand Down

0 comments on commit 980ae5a

Please sign in to comment.