Skip to content

Commit 287578e

Browse files
authored
Merge pull request #44 from open-ephys-plugins/fix-loading-sample-rate
* Fix loading sample rate & bitfile * Package .bit files in shared folder * Show alert when Opal Kelly FPGA bitfile upload fails
2 parents 9003e86 + d376838 commit 287578e

File tree

7 files changed

+42
-14
lines changed

7 files changed

+42
-14
lines changed

.github/workflows/linux.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
echo "PLUGIN_VERSION=$(grep -w Source/OpenEphysLib.cpp -e 'info->libVersion' | grep -Eo "[0-9]+.[0-9]+.[0-9]+")" >> "$GITHUB_OUTPUT"
8484
sudo apt update
8585
cd ../..
86-
git clone https://github.com/open-ephys/plugin-GUI.git --branch testing-juce8
86+
git clone https://github.com/open-ephys/plugin-GUI.git --branch main
8787
sudo ./plugin-GUI/Resources/Scripts/install_linux_dependencies.sh
8888
cd plugin-GUI/Build && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
8989
echo "PLUGIN_API=$(grep -rnw ../Source -e '#define PLUGIN_API_VER' | grep -Eo "[0-9]*" | tail -1)" >> "$GITHUB_OUTPUT"
@@ -132,6 +132,7 @@ jobs:
132132
cp -r $build_dir/*.so plugins
133133
mkdir shared
134134
cp Resources/libokFrontPanel.so shared
135+
cp Resources/*.bit shared
135136
cp -r libONI/linux/*.so shared
136137
zipfile=${package}_${new_plugin_ver}.zip
137138
zip -r -X $zipfile plugins shared

.github/workflows/mac.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
run: |
8383
echo "PLUGIN_VERSION=$(grep -w Source/OpenEphysLib.cpp -e 'info->libVersion' | grep -Eo "[0-9]+.[0-9]+.[0-9]+")" >> "$GITHUB_OUTPUT"
8484
cd ../..
85-
git clone https://github.com/open-ephys/plugin-GUI.git --branch testing-juce8
85+
git clone https://github.com/open-ephys/plugin-GUI.git --branch main
8686
cd plugin-GUI/Build && cmake -G "Xcode" ..
8787
echo "PLUGIN_API=$(grep -rnw ../Source -e '#define PLUGIN_API_VER' | grep -Eo "[0-9]*" | tail -1)" >> "$GITHUB_OUTPUT"
8888
@@ -139,6 +139,7 @@ jobs:
139139
140140
mkdir shared
141141
cp -r Resources/libokFrontPanel.1.dylib shared
142+
cp Resources/*.bit shared
142143
cp -r libONI/osx/*.dylib shared
143144
144145
# Turn our base64-encoded certificate back to a regular .p12 file

.github/workflows/windows.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ jobs:
8282
run: |
8383
echo "PLUGIN_VERSION=$(grep -w Source/OpenEphysLib.cpp -e 'info->libVersion' | grep -Eo "[0-9]+.[0-9]+.[0-9]+")" >> "$GITHUB_OUTPUT"
8484
cd ../..
85-
git clone https://github.com/open-ephys/plugin-GUI.git --branch testing-juce8
85+
git clone https://github.com/open-ephys/plugin-GUI.git --branch main
8686
cd plugin-GUI/Build
8787
cmake -G "Visual Studio 17 2022" -A x64 ..
8888
mkdir Release && cd Release
89-
curl -L https://openephys.jfrog.io/artifactory/GUI-binaries/Libraries/open-ephys-lib-v1.0.0-alpha.zip --output open-ephys-lib.zip
89+
curl -L https://openephys.jfrog.io/artifactory/GUI-binaries/Libraries/open-ephys-lib-v1.0.0.zip --output open-ephys-lib.zip
9090
unzip open-ephys-lib.zip
9191
echo "PLUGIN_API=$(grep -rnw ../../Source -e '#define PLUGIN_API_VER' | grep -Eo "[0-9]*" | tail -1)" >> "$GITHUB_OUTPUT"
9292
shell: bash
@@ -145,6 +145,7 @@ jobs:
145145
mkdir shared
146146
cp libONI/win64/*.dll shared
147147
cp Resources/okFrontPanel.dll shared
148+
cp Resources/*.bit shared
148149
zipfile=${package}_${new_plugin_ver}.zip
149150
powershell Compress-Archive -Path "plugins" -DestinationPath ${zipfile}
150151
powershell Compress-Archive -U -Path "shared" -DestinationPath ${zipfile}

Resources/intan_rhd_usb.bit

-1.42 MB
Binary file not shown.

Source/DeviceEditor.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ DeviceEditor::DeviceEditor (GenericProcessor* parentNode,
6666

6767
if (board->getBoardType() == AcquisitionBoard::BoardType::ONI)
6868
{
69-
if (((AcqBoardONI*)board)->getMemoryMonitorSupport())
69+
if (((AcqBoardONI*) board)->getMemoryMonitorSupport())
7070
{
7171
desiredWidth += 22;
7272

@@ -398,7 +398,7 @@ void DeviceEditor::startAcquisition()
398398
canvas->beginAnimation();
399399
}
400400

401-
if(memoryUsage != nullptr)
401+
if (memoryUsage != nullptr)
402402
memoryUsage->startAcquisition();
403403

404404
acquisitionIsActive = true;
@@ -531,7 +531,13 @@ void DeviceEditor::loadVisualizerEditorParameters (XmlElement* xml)
531531
return;
532532
}
533533

534-
sampleRateInterface->setSelectedId (xml->getIntAttribute ("SampleRate"));
534+
int sampleRateId = xml->getIntAttribute ("SampleRate");
535+
Array<int> sampleRates = board->getAvailableSampleRates();
536+
if (! sampleRates.contains (sampleRateId))
537+
{
538+
sampleRateId = sampleRates.getLast(); // if the requested sample rate is not available, use the last one in the list
539+
}
540+
sampleRateInterface->setSelectedId (sampleRateId);
535541
bandwidthInterface->setLowerBandwidth (xml->getDoubleAttribute ("LowCut"));
536542
bandwidthInterface->setUpperBandwidth (xml->getDoubleAttribute ("HighCut"));
537543
auxButton->setToggleState (xml->getBoolAttribute ("AUXsOn"), sendNotification);

Source/OpenEphysLib.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extern "C" EXPORT void getLibInfo(Plugin::LibraryInfo* info)
4141
{
4242
info->apiVersion = PLUGIN_API_VER;
4343
info->name = "Acquisition Board";
44-
info->libVersion = "1.1.0";
44+
info->libVersion = "1.1.1";
4545
info->numPlugins = NUM_PLUGINS;
4646
}
4747

Source/devices/opalkelly/AcqBoardOpalKelly.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ bool AcqBoardOpalKelly::detectBoard()
110110
}
111111
else if (return_code == -1) // Opal Kelly library not found
112112
{
113-
LOGC ("No Opal Kelly DLL found.");
113+
LOGE ("No Opal Kelly DLL found.");
114114
return false;
115115
}
116116
else if (return_code == -2)
117117
{
118-
LOGC ("No Opal Kelly Acquisition Board found.");
118+
LOGE ("No Opal Kelly Acquisition Board found.");
119119
return false;
120120
}
121121

@@ -144,11 +144,30 @@ bool AcqBoardOpalKelly::initializeBoard()
144144
bitfilename += File::getSeparatorString();
145145
bitfilename += evalBoard->isUSB3() ? "rhd2000_usb3.bit" : "rhd2000.bit";
146146

147-
if (! evalBoard->uploadFpgaBitfile (bitfilename.toStdString()))
147+
if (! File (bitfilename).existsAsFile() || ! evalBoard->uploadFpgaBitfile (bitfilename.toStdString()))
148148
{
149-
LOGC ("Could not upload FPGA bitfile from ", bitfilename);
150-
deviceFound = false;
151-
return false;
149+
// If the bitfile is not found in the executable directory or if the upload fails,
150+
// try to load it from the saved state directory.
151+
152+
bitfilename = CoreServices::getSavedStateDirectory().getFullPathName();
153+
bitfilename += File::getSeparatorString();
154+
bitfilename += "shared-api" + String (PLUGIN_API_VER);
155+
bitfilename += File::getSeparatorString();
156+
bitfilename += evalBoard->isUSB3() ? "rhd2000_usb3.bit" : "rhd2000.bit";
157+
158+
if (! evalBoard->uploadFpgaBitfile (bitfilename.toStdString()))
159+
{
160+
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
161+
"Failed to upload FPGA bitfile",
162+
"The Opal Kelly FPGA bitfile upload failed. Refer to the console for further details.",
163+
"OK",
164+
nullptr,
165+
ModalCallbackFunction::create ([] (int) {}));
166+
167+
LOGE ("Could not upload FPGA bitfile");
168+
deviceFound = false;
169+
return false;
170+
}
152171
}
153172

154173
LOGC ("Successfully uploaded bitfile, initializing board...");

0 commit comments

Comments
 (0)