From f2739771002e3336a01dbad5dba0243f9dadcbfc Mon Sep 17 00:00:00 2001
From: jsiegle <jsiegle@mit.edu>
Date: Wed, 22 Jan 2014 19:16:44 -0500
Subject: [PATCH] Fix issue with re-loading FPGA

---
 Source/Processors/DataThreads/RHD2000Thread.cpp | 5 ++++-
 Source/Processors/SpikeDetector.cpp             | 6 +++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Source/Processors/DataThreads/RHD2000Thread.cpp b/Source/Processors/DataThreads/RHD2000Thread.cpp
index 2d733a524..eeee37843 100644
--- a/Source/Processors/DataThreads/RHD2000Thread.cpp
+++ b/Source/Processors/DataThreads/RHD2000Thread.cpp
@@ -109,7 +109,10 @@ RHD2000Thread::~RHD2000Thread()
     }
 
 	if (deviceFound)
+    {
 		evalBoard->resetFpga();
+    }
+
 
     deleteAndZero(dataBlock);
 
@@ -276,7 +279,7 @@ void RHD2000Thread::initializeBoard()
     Rhd2000DataBlock* dataBlock = new Rhd2000DataBlock(evalBoard->getNumEnabledDataStreams());
 
 
-    evalBoard->readDataBlock(dataBlock);
+   // evalBoard->readDataBlock(dataBlock);
 
     // Now that ADC calibration has been performed, we switch to the command sequence
     // that does not execute ADC calibration.
diff --git a/Source/Processors/SpikeDetector.cpp b/Source/Processors/SpikeDetector.cpp
index 4b4908bea..663979f59 100755
--- a/Source/Processors/SpikeDetector.cpp
+++ b/Source/Processors/SpikeDetector.cpp
@@ -213,7 +213,11 @@ void SpikeDetector::setChannel(int electrodeIndex, int channelNum, int newChanne
 
 int SpikeDetector::getNumChannels(int index)
 {
-    return electrodes[index]->numChannels;
+
+    if (index < electrodes.size())
+        return electrodes[index]->numChannels;
+    else
+        return 0;
 }
 
 int SpikeDetector::getChannel(int index, int i)
-- 
GitLab