Skip to content

Commit

Permalink
Merge pull request #236 from jdemel/add-sigmf-dataset-support
Browse files Browse the repository at this point in the history
sigmf: Add support for datasets
  • Loading branch information
miek authored Jul 21, 2024
2 parents 009fd2d + 3470a8a commit 6a1ee5a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions src/inputsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void InputSource::cleanup()
}
}

void InputSource::readMetaData(const QString &filename)
QJsonObject InputSource::readMetaData(const QString &filename)
{
QFile datafile(filename);
if (!datafile.open(QFile::ReadOnly | QIODevice::Text)) {
Expand Down Expand Up @@ -349,6 +349,8 @@ void InputSource::readMetaData(const QString &filename)
}
}
}

return root;
}

void InputSource::openFile(const char *filename)
Expand Down Expand Up @@ -406,7 +408,20 @@ void InputSource::openFile(const char *filename)
if (suffix == "sigmf-meta" || suffix == "sigmf-data" || suffix == "sigmf-") {
dataFilename = fileInfo.path() + "/" + fileInfo.completeBaseName() + ".sigmf-data";
metaFilename = fileInfo.path() + "/" + fileInfo.completeBaseName() + ".sigmf-meta";
readMetaData(metaFilename);
auto metaData = readMetaData(metaFilename);
QFile datafile(dataFilename);
if (!datafile.open(QFile::ReadOnly | QIODevice::Text)) {
auto global = metaData["global"].toObject();
if (global.contains("core:dataset")) {
auto datasetfilename = global["core:dataset"].toString();
if(QFileInfo(datasetfilename).isAbsolute()){
dataFilename = datasetfilename;
}
else{
dataFilename = fileInfo.path() + "/" + datasetfilename;
}
}
}
}
else if (suffix == "sigmf") {
throw std::runtime_error("SigMF archives are not supported. Consider extracting a recording.");
Expand Down
2 changes: 1 addition & 1 deletion src/inputsource.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class InputSource : public SampleSource<std::complex<float>>
std::string _fmt;
bool _realSignal = false;

void readMetaData(const QString &filename);
QJsonObject readMetaData(const QString &filename);

public:
InputSource();
Expand Down

0 comments on commit 6a1ee5a

Please sign in to comment.