Skip to content

Commit

Permalink
Add first iteration of SigMF support
Browse files Browse the repository at this point in the history
  • Loading branch information
BatchDrake committed Dec 27, 2023
1 parent a3dd241 commit 8d7541b
Show file tree
Hide file tree
Showing 4 changed files with 245 additions and 67 deletions.
16 changes: 16 additions & 0 deletions Default/SourceConfig/FileSourcePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ FileSourcePage::guessParamsFromFileName()
SigDiggerHelpers *hlp = SigDiggerHelpers::instance();
CaptureFileParams params;
bool changes = false;
bool refresh = false;

if (m_config == nullptr)
return false;
Expand All @@ -133,8 +134,22 @@ FileSourcePage::guessParamsFromFileName()
m_config->setFreq(shiftedFc);
changes = true;
}

if (params.havePath && params.path != m_config->getPath()) {
m_config->setPath(params.path);
ui->pathEdit->setText(QString::fromStdString(params.path));
changes = refresh = true;
}

if (params.haveFmt && params.format != m_config->getFormat()) {
m_config->setFormat(params.format);
changes = refresh = true;
}
}

if (refresh)
refreshUi();

return changes;
}

Expand Down Expand Up @@ -183,6 +198,7 @@ FileSourcePage::onBrowseCaptureFile()
<< "Raw complex 8-bit signed (*.s8 *.cs8)"
<< "Raw complex 16-bit signed (*.s16 *.cs16)"
<< "WAV files (*.wav)"
<< "SigMF signal rcordings (*.sigmf-data *.sigmf-meta)"
<< "All files (*)";
break;

Expand Down
8 changes: 6 additions & 2 deletions Misc/FileViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ FileViewer::FileViewer(QObject *parent)
<< "Raw complex 8-bit signed (*.s8 *.cs8)"
<< "Raw complex 16-bit signed (*.s16 *.cs16)"
<< "WAV files (*.wav)"
<< "SigMF signal rcordings (*.sigmf-data *.sigmf-meta)"
<< "All files (*)";

m_dialog->setFileMode(QFileDialog::ExistingFile);
Expand Down Expand Up @@ -51,11 +52,11 @@ FileViewer::processFile(QString path)
return;
}

if (!params.isRaw) {
if (params.format != SUSCAN_SOURCE_FORMAT_RAW_FLOAT32) {
QMessageBox::warning(
nullptr,
"Unsupported file format",
"The selected file has been recognized, but its storage format is not raw. "
"The selected file has been recognized, but its storage format is not float32. "
"FileViewer currently relies on memory-mapped files to display large files, "
"and non-native sample formats cannot be converted on the go.");
return;
Expand All @@ -70,6 +71,9 @@ FileViewer::processFile(QString path)
return;
}

if (params.havePath)
path = QString::fromStdString(params.path);

QFile file(path);

if (!file.open(QIODevice::ReadOnly)) {
Expand Down
Loading

0 comments on commit 8d7541b

Please sign in to comment.