Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 909b6280b8b5
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dcadd77921b1
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Feb 24, 2020

  1. Copy the full SHA
    df2e84e View commit details
  2. Copy the full SHA
    dcadd77 View commit details
Showing with 41 additions and 2 deletions.
  1. +41 −2 glscopeclient/main.cpp
43 changes: 41 additions & 2 deletions glscopeclient/main.cpp
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@
#include "../scopehal/RohdeSchwarzOscilloscope.h"
#include "../scopehal/AntikernelLogicAnalyzer.h"
#include <thread>
#include <libgen.h>

using namespace std;

@@ -135,8 +136,6 @@ int main(int argc, char* argv[])
{
auto app = ScopeApp::create();

//FIXME: proper way to locate shaders etc
chdir("/nfs4/home/azonenberg/code/scopehal-cmake/src/glscopeclient/");

//Global settings
Severity console_verbosity = Severity::NOTICE;
@@ -174,6 +173,46 @@ int main(int argc, char* argv[])
//Set up logging
g_log_sinks.emplace(g_log_sinks.begin(), new ColoredSTDLogSink(console_verbosity));


//Change to the binary's directory so we can use relative paths for external resources
//FIXME: portability warning: this only works on Linux

char binDir[1024];

//Get our binary's full path
ssize_t readlinkReturn = readlink("/proc/self/exe", binDir, (sizeof(binDir) - 1) );

if ( readlinkReturn < 0 )
{
//FIXME: add errno output
LogError("Error: readlink() failed.\n");
return 1;
}
else if ( readlinkReturn == 0 )
{
LogError("Error: readlink() returned 0.\n");
return 1;
}
else if ( (unsigned) readlinkReturn > (sizeof(binDir) - 1) )
{
LogError("Error: readlink() returned a path larger than our buffer.\n");
return 1;
}
else
{
//Null terminate result
binDir[readlinkReturn - 1] = 0;

//Change to our binary's directory
if ( chdir(dirname(binDir)) != 0 )
{
//FIXME: add errno output
LogError("Error: chdir() failed.\n");
return 1;
}
}


//Initialize the protocol decoder and measurement libraries
ScopeProtocolStaticInit();
ScopeMeasurementStaticInit();