7
mirror of https://github.com/EEVengers/ThunderScope.git synced 2025-04-22 17:43:44 +00:00

cleaned up gitignore and trailing spaces

lots and lots of trailing spaces
repeat entries in top level gitignore also removed
This commit is contained in:
Alex Vandenberg 2020-06-03 17:14:44 -04:00
parent 085f6ebf15
commit eeea8b8c93
15 changed files with 125 additions and 118 deletions

9
.gitignore vendored
View File

@ -1,6 +1,5 @@
# Xcode Project specifc
*.xcuserstate
DSO_Software/Xcode_Project/Scope/Scope.xcodeproj/project.xcworkspace/xcuserdata/danielvasile.xcuserdatad/UserInterfaceState.xcuserstate
DSO_Software/Xcode_Project/Scope/Scope.xcodeproj/project.xcworkspace/xcuserdata/danielvasile.xcuserdatad/UserInterfaceState.xcuserstate
DSO_Software/Xcode_Project/Scope/Scope.xcodeproj/project.xcworkspace/xcuserdata/danielvasile.xcuserdatad/UserInterfaceState.xcuserstate
*.xcuserstate
*.xcuserstate
# vim specifc
tags

2
Software/scope_link/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# scope_link output executable
scope

View File

@ -21,11 +21,11 @@ DataTransferHandler::DataTransferHandler()
killFTDIDataTransferThread = true;
InitFTDISuperSpeedChip(&superSpeedFIFOBridgeHandle);
threadSharedCache = new EVSharedCache(MEDIUM_BUFF_SIZE,10);
CopyFunc = [](unsigned char* buff, unsigned int& idx, unsigned int size, void* obj){ return; };
} catch (EVException e) {
std::cout << "DataTransferHandler:Constructor - " << e.what << std::endl;
assert(false);
@ -33,7 +33,7 @@ DataTransferHandler::DataTransferHandler()
std::cout << "DataTransferHandler:Constructor - " << e.what() << std::endl;
assert(false);
}
}
void DataTransferHandler::FTDITransferThread(DataTransferHandler* handler)
@ -69,9 +69,9 @@ void DataTransferHandler::FTDITransferThread(DataTransferHandler* handler)
FT_ReleaseOverlapped(handler->superSpeedFIFOBridgeHandle, vOverlapped + i);
}
FT_Close(handler->superSpeedFIFOBridgeHandle);
EVLogger::Debug( (std::string("FTDI Transfer Thread failed to que up async read, error code ") + std::to_string(errorCode)).c_str() );
EVLogger::Debug( (std::string("FTDI Transfer Thread failed to queue up async read, error code ") + std::to_string(errorCode)).c_str() );
assert(false);
}
}
}
unsigned int idx = 0;

View File

@ -24,41 +24,42 @@ enum CopyFuncs
*/
class DataTransferHandler
{
public:
public:
DataTransferHandler();
void StartFTDITransferThread();
void SetFTDITransferCopyFunction();
void SetCopyFunc(CopyFuncs Func);
void StopThread();
unsigned int bytesRead;//used for testing
EVSharedCache* threadSharedCache;
~DataTransferHandler();
private:
private:
static void FTDITransferThread(DataTransferHandler* handler);
FT_HANDLE superSpeedFIFOBridgeHandle;
void (*CopyFunc)(unsigned char* buff, unsigned int& idx, unsigned int size, void* obj);
bool killFTDIDataTransferThread;
bool killDigitalProcessingTransferThread;
bool killElectronTransferThread;
std::thread superSpeedFTDITransferThread;
protected:
protected:
std::mutex lock;
const static unsigned int numAsyncBuffers = 16;
unsigned char asyncDataBuffers[numAsyncBuffers][MEDIUM_BUFF_SIZE];
};

View File

@ -26,7 +26,7 @@ void DigitalProcessor::risingEdgeTriggerMethod(DigitalProcessor* handler) {
unsigned char* tempBuff = (unsigned char*)malloc(sizeof(unsigned char) * MEDIUM_BUFF_SIZE);
//TODO -> Make the actual buffer size the size of the trigger window
unsigned char* buff = (unsigned char*)malloc(sizeof(unsigned char) * MEDIUM_BUFF_SIZE * 8);
while(!handler->killThread) {
//wait for this thread's ID to be the one allowed to access the cache
@ -37,8 +37,8 @@ void DigitalProcessor::risingEdgeTriggerMethod(DigitalProcessor* handler) {
return;
}
std::this_thread::sleep_for(std::chrono::microseconds(100));
}
}
//copy until a trigger has been met
while(1) {
while(handler->cache->CopyReadCache(tempBuff,MEDIUM_BUFF_SIZE)) {
@ -83,7 +83,7 @@ void DigitalProcessor::risingEdgeTriggerMethod(DigitalProcessor* handler) {
free(points);
free(interpolatedPoints);
}
free(tempBuff);
free(buff);
}

View File

@ -16,7 +16,7 @@ class DigitalProcessor
{
public:
DigitalProcessor();
void SetSharedCache(EVSharedCache* cache);
void StartRisingEdgeTriggerThread();
unsigned int bytesProcessed; //Used for DataThroughPut Test
@ -24,9 +24,9 @@ public:
void StopThread();
~DigitalProcessor();
private:
void WriteToCSV(const unsigned char* buff, const unsigned int size, const char* filename);
EVSharedCache* cache;
int orderID;
@ -37,9 +37,9 @@ private:
std::thread processorThread;
static void risingEdgeTriggerMethod(DigitalProcessor* handler);
void startRisingEdgeTriggerThread();
protected:
static volatile int orderIDMax;
static volatile int currentOrderID;

View File

@ -26,7 +26,7 @@ EVException::EVException(int errorCode, const char* subSystem, const char* optio
exceptionText += " - Optional Message: ";
exceptionText += std::string(optionalMessage);
}
what = exceptionText.c_str();
}
@ -93,7 +93,7 @@ EVSharedCache::EVSharedCache(unsigned int cacheSize, unsigned int numCaches)
for(int i = 0; i < numCaches; i++) {
caches[i] = (unsigned char*)malloc(sizeof(unsigned char*) * cacheSize);
}
this->readCache = 0;
this->writeCache = 0;
}
@ -101,7 +101,7 @@ EVSharedCache::EVSharedCache(unsigned int cacheSize, unsigned int numCaches)
void EVSharedCache::SetWriteCache(const unsigned char* buff)
{
this->lock.lock();
//copy data
for(int i = 0; i < cacheSize; i++)
{
@ -113,20 +113,20 @@ void EVSharedCache::SetWriteCache(const unsigned char* buff)
} else {
writeCache++;
}
this->lock.unlock();
}
void EVSharedCache::PartialSetWriteCache(const unsigned char* buff, unsigned int &idx, unsigned int size) {
if(idx + size > cacheSize) throw EVException(EVErrorCodeInvalidValue,"EVSharedCache::PartialSetWriteCache()",nullptr);
this->lock.lock();
for(int i = 0; i < size; i++) {
caches[writeCache][idx + i] = buff[i];
}
idx += size;
//when this buffer is full
if(idx == cacheSize) {
//move onto next buffer
@ -153,7 +153,7 @@ int EVSharedCache::CopyReadCache(unsigned char* buff, unsigned int size)
}
if(this->cacheSize < size) throw EVException(EVErrorCodeInvalidValue,"EVSharedCache::CopyReadCache",nullptr);
//copy data
memcpy(buff,caches[readCache],size);
//advance to next cache
@ -162,9 +162,9 @@ int EVSharedCache::CopyReadCache(unsigned char* buff, unsigned int size)
} else {
readCache++;
}
this->lock.unlock();
return 0;
}
@ -177,7 +177,3 @@ EVSharedCache::~EVSharedCache()
}
//---------------EVCacheCopySignal---------------

View File

@ -42,7 +42,7 @@ enum EVErrorCodes
class EVException: public std::exception
{
public:
const char* what;
@ -69,12 +69,12 @@ public:
class EVCacheCopySignal
{
public:
void Trigger();
void Subscribe();
private:
protected:
};
@ -84,25 +84,25 @@ protected:
class EVSharedCache
{
public:
EVSharedCache(unsigned int cacheSize, unsigned int numCaches);
~EVSharedCache();
void SetWriteCache(const unsigned char* buff);
void PartialSetWriteCache(const unsigned char* buff, unsigned int& idx, unsigned int size);
int CopyReadCache(unsigned char* buff, unsigned int size);
private:
std::mutex lock;
unsigned char** caches;
unsigned int cacheSize;
unsigned int numCaches;
unsigned short writeCache;
unsigned short readCache;
EVCacheCopySignal copySignal;
};
@ -111,10 +111,10 @@ private:
/* EVMath Structs and Enums */
struct DataPoint {
float time;
float value;
};
/* END OF EVMATH STRUCTS AND ENUMS*/

View File

@ -17,13 +17,13 @@ DataPoint* SincInterpolate(DataPoint* buff, int buffSize, int* interpolatedBuffS
float samplingPeriod = buff[1].time - buff[0].time;
float step = samplingPeriod / (float(numPointsBetween) + 1);
int pointIdx = 0;
for(int i = 0; i < buffSize - 1; i++) {
//interpolate the point and the following 'numPointsBetween' points
//Set the start of the 'window' which are the N amount of points that will be used to interpolate
int windowStart = i;
//if window start + window size overflows the input data buffer
if( windowStart + windowSize > buffSize - 1) {
windowStart = (buffSize - windowSize) - 1;
@ -34,26 +34,26 @@ DataPoint* SincInterpolate(DataPoint* buff, int buffSize, int* interpolatedBuffS
} else {
windowStart -= windowSize / 2;
}
//add the measured point
points[pointIdx] = buff[i];
pointIdx++;
for(int q = 1; q < numPointsBetween + 1; q++) {
float t = (float(q) * step);
points[pointIdx].time = buff[i].time + t;
for(int m = windowStart; m < windowStart + windowSize; m++) {
float num, denum, tByDeltaT;
tByDeltaT = ( M_PI * ((t / samplingPeriod) - float(m - i)) ) / float(windowSize);
if(tByDeltaT <= 0.001 && tByDeltaT >= -0.001) {
points[pointIdx].value += buff[m].value;
continue;
}
num = sin(float(windowSize) * tByDeltaT);
denum = float(windowSize) * sin(tByDeltaT);
points[pointIdx].value += buff[m].value * (num / denum);
}
pointIdx++;

View File

@ -14,7 +14,7 @@
* FT_HANDLE *device_handle - A pointer to a variable which will hold the inialized handle to the FIFO SuperSpeed Bridge
*/
void InitFTDISuperSpeedChip(FT_HANDLE *deviceHandle) {
DWORD numDevices;
DWORD error;
DWORD driverVersion;
@ -24,19 +24,19 @@ void InitFTDISuperSpeedChip(FT_HANDLE *deviceHandle) {
//Get library version
FT_GetLibraryVersion(&libraryVersion);
EVLogger::Debug( (std::string("Library Version is: ") + std::to_string(libraryVersion)).c_str() );
//check the driver for a super speed FIFO buffer, if it exists, open it and set its configuration.
if(FT_OK != (error = FT_CreateDeviceInfoList(&numDevices))) {
throw EVException(error,"EVSuperSpeedFIFOBRidge:InitFTDISuperSpeedChip:FT_CreateDeviceList()",nullptr);
}
if( numDevices == 0 ) {
error = EVErrorCodeInvalidValue;
throw EVException(error,"EVSuperSpeedFIFOBRidge:InitFTDISuperSpeedChip",nullptr);
}
FT_DEVICE_LIST_INFO_NODE deviceInfoList[numDevices];
if(FT_OK != (error = FT_GetDeviceInfoList(deviceInfoList, &numDevices))) {
throw EVException(error,"EVSuperSpeedFIFOBRidge:InitFTDISuperSpeedChip:FT_GetDeviceInfoList()",nullptr);
}
@ -56,12 +56,10 @@ void InitFTDISuperSpeedChip(FT_HANDLE *deviceHandle) {
throw EVException(error,"EVSuperSpeedFIFOBRidge:InitFTDISuperSpeedChip:FT_Create",nullptr);
}
//Get Drvier Version for the FTDI chip
FT_GetDriverVersion(*deviceHandle,&driverVersion);
EVLogger::Debug( (std::string("Driver Version for FT601 is: ") + std::to_string(driverVersion)).c_str() );
//Set Channel Config to fifo600_mode and 100Mhz clk with appropiate flags
FT_60XCONFIGURATION oldConfig, newConfig;
if(FT_OK != (error = FT_GetChipConfiguration(*deviceHandle, &oldConfig))) {
@ -76,28 +74,28 @@ void InitFTDISuperSpeedChip(FT_HANDLE *deviceHandle) {
throw new EVException(error,"EVSuperSpeedFIFOBRidge:InitFTDISuperSpeedChip:FT_SetChipConfiguration",nullptr);
}
FT_Close(*deviceHandle);
//Wait For The SuperSpeed FIFO Bridge To Power Cycle
std::this_thread::sleep_for(std::chrono::seconds(1));
//reopen device since configuration causes a reset
*deviceHandle = 0;
deviceInfoList[0] = {0};
if(FT_OK != (error = FT_CreateDeviceInfoList(&numDevices))) {
throw new EVException(error,"EVSuperSpeedFIFOBRidge:InitFTDISuperSpeedChip:FT_CreateDeviceInfoList",nullptr);
}
if( numDevices == 0 ) {
error = EVErrorCodeInvalidValue;
throw new EVException(error,"EVSuperSpeedFIFOBRidge:InitFTDISuperSpeedChip",nullptr);
}
FT_DEVICE_LIST_INFO_NODE _deviceInfoList[numDevices];
if(FT_OK != (error = FT_GetDeviceInfoList(_deviceInfoList, &numDevices))) {
throw new EVException(error,"EVSuperSpeedFIFOBRidge:InitFTDISuperSpeedChip:FT_GetDeviceInfoList",nullptr);
}
chipIdx = -1;
//Find the index of the EVScope USB Transfer Chip
for(int i = 0; i < numDevices; i++) {
@ -109,7 +107,7 @@ void InitFTDISuperSpeedChip(FT_HANDLE *deviceHandle) {
if(chipIdx == -1) {
throw EVException(error,"EVSuperSpeedFIFOBridge:InitFTDISuperSpeedChip:Find_Chip_Idx",nullptr);
}
if(FT_OK != (error = FT_Create( (PVOID)chipIdx, (DWORD)FT_OPEN_BY_INDEX, deviceHandle))){
throw EVException(error,"EVSuperSpeedFIFOBRidge:InitFTDISuperSpeedChip:FT_Create",nullptr);
}
@ -120,10 +118,5 @@ void InitTransferParams() {
for(int i = 0; i < 3; i++) {
FT_TRANSFER_CONF config[1] = {0};
}
}
}

View File

@ -1,25 +1,22 @@
#include "EVTester.hpp"
#include "EVMath.hpp"
#include "EVDigitalProcessing.hpp"
#include "EVDataTransferThread.hpp"
void TestSincInterpolation() {
int numInterpolatedPoints;
int numOriginalPoints = 300;
DataPoint* testPoints = (DataPoint*)malloc(numOriginalPoints * sizeof(DataPoint));
std::ofstream myFile;
for(int i = 0; i < numOriginalPoints; i++) {
testPoints[i].value = sin(double(10 * i) * 0.05) + (2 * sin(double(3 * i) * 0.05));
testPoints[i].time = double(10 * i) * 0.05;
testPoints[i].value = sin(double(10 * i) * 0.05) + (2 * sin(double(3 * i) * 0.05));
testPoints[i].time = double(10 * i) * 0.05;
}
DataPoint* points = SincInterpolate(testPoints, numOriginalPoints, &numInterpolatedPoints, 3, 20);
myFile.open("InterpolatedPoints.csv");
for(int i = 0; i < numInterpolatedPoints; i++) {
myFile << points[i].time;
@ -31,10 +28,10 @@ void TestSincInterpolation() {
myFile.open("OriginalValues.csv");
for(int i = 0; i < numOriginalPoints; i++) {
myFile << testPoints[i].time;
myFile << ",";
myFile << testPoints[i].value;
myFile << "\n";
myFile << testPoints[i].time;
myFile << ",";
myFile << testPoints[i].value;
myFile << "\n";
}
myFile.close();
@ -51,7 +48,7 @@ void TestDataThroughPut() {
dataExchanger = new DataTransferHandler();
dataExchanger->SetCopyFunc(DataTransferFullBuffRead);
for(int i = 0; i < numDigitalProcessors; i++) {
digitalProcessor[i] = new DigitalProcessor();
digitalProcessor[i]->SetSharedCache(dataExchanger->threadSharedCache);
@ -67,7 +64,7 @@ void TestDataThroughPut() {
//start the transfer thread
dataExchanger->StartFTDITransferThread();
//run for 1 minute
std::this_thread::sleep_for(std::chrono::seconds(60));
@ -91,8 +88,4 @@ void TestDataThroughPut() {
std::cout << "Bytes Read: " << bytesRead << "B" << std::endl;
std::cout << "Bytes Processed: " << bytesProcessed << std::endl;
std::cout << "B/s: " << bytesProcessed / 60 << std::endl;
}

View File

@ -1,16 +1,10 @@
#ifndef EVTester_hpp
#define EVTester_hpp
#include "EVLibrary.hpp"
void TestSincInterpolation();
void TestDataThroughPut();
#endif
#endif /* EVTester_hpp */

View File

@ -8,7 +8,7 @@ CCFLAGS_super_fast = -std=c++17 -O3 -o
soruce = main.cpp EVLibrary.cpp EVDataTransferThread.cpp EVDigitalProcessing.cpp EVMath.cpp EVSuperSpeedFIFOBridge.cpp EVTester.cpp
lib = -L/usr/local/lib -lftd3xx -lstdc++
lib_debug =
target = scope
target = scope
all: gen

View File

@ -0,0 +1,30 @@
# Scope Link
## Setup
You will need to download and install the D3XX ftdi drivers
* They can be found on the [ftdi website](https://www.ftdichip.com/Drivers/D3XX.htm).
* Extract the files to the correct locations
* Run the following commands
```
sudo cp libft3xx.so /usr/lib/
sudo cp libft3xx.so.0.5.21 /usr/lib/
sudo cp 51-ftd3xx.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
```
## Running
Only 2 command line arguments are implemented currently
### Test Sinc Interpolation
Not quite sure what this does yet
```
./scope --TestSync
```
### Test Data Throughput
Not quite sure what this does yet either
```
./scope --TestDataThrougput
```

View File

@ -23,7 +23,7 @@ void run()
}
int parseCommandLineArgs(int argc, char** args) {
int flags = 0;
int flags = 0;
for(int i = 1; i < argc; i++) {
if(std::string(args[i]) == "--TestSinc" || std::string(args[i]) == "-s") {
@ -41,4 +41,3 @@ int main(int argc, char** args)
parseCommandLineArgs(argc, args);
return 0;
}