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: f068c2a7d492
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: ae8540c3154f
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Nov 22, 2020

  1. Copy the full SHA
    7c86bca View commit details
  2. Copy the full SHA
    ae8540c View commit details
Showing with 93 additions and 33 deletions.
  1. +1 −1 lib
  2. +70 −30 src/glscopeclient/OscilloscopeWindow.cpp
  3. +22 −2 src/glscopeclient/masks/pcie-gen2-5gbps-rx.yml
100 changes: 70 additions & 30 deletions src/glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -687,37 +687,98 @@ void OscilloscopeWindow::DoImportCSV(const string& filename)
std::map<int, AnalogWaveform*> waveforms;

char line[1024];
bool first = true;
size_t nrow = 0;
size_t ncols = 0;
vector<string> channel_names;
while(!feof(fp))
{
nrow ++;

if(!fgets(line, sizeof(line), fp))
break;

//Parse the samples for each row
//TODO: be more efficient about this
vector<float> row;
string tmp;
for(size_t i=0; i < sizeof(line); i++)
{
if(line[i] == '\0' || line[i] == ',')
{
float f;
sscanf(tmp.c_str(), "%f", &f);
row.push_back(f);

if(line[i] == '\0')
break;
else
tmp = "";
}
else
tmp += line[i];
}

//If this is the first line, figure out how many columns we have.
//First column is always timestamp in seconds.
//TODO: support timestamp in abstract sample units instead
if(first)
if(nrow == 1)
{
for(size_t i=0; i<sizeof(line); i++)
ncols = row.size() - 1;

//See if the first row is numeric
bool numeric = true;
for(size_t i=0; (i<sizeof(line)) && (line[i] != '\0'); i++)
{
if(line[i] == '\0')
if(!isdigit(line[i]) && !isspace(line[i]) && (line[i] != ',') && (line[i] != '.') )
{
numeric = false;
break;
else if(line[i] == ',')
ncols ++;
}
}

if(!numeric)
{
LogDebug("Found %zu signal columns, with header row\n", ncols);

//Extract names of the headers
tmp = "";
for(size_t i=0; i < sizeof(line); i++)
{
if(line[i] == '\0' || line[i] == ',')
{
channel_names.push_back(tmp);

if(line[i] == '\0')
break;
else
tmp = "";
}
else
tmp += line[i];
}

continue;
}

LogDebug("Found %zu signal columns, no header row\n", ncols);
else
{
for(size_t i=0; i<ncols; i++)
channel_names.push_back(string("CH") + to_string(i+1));

first = false;
LogDebug("Found %zu signal columns, no header row\n", ncols);
}
}

//If we don't have any channels, create them
if(scope->GetChannelCount() == 0)
{
//Create the columns
for(size_t i=0; i<ncols; i++)
{
//Create the channel
auto chan = new OscilloscopeChannel(
scope,
string("CH") + to_string(i+1),
channel_names[i],
OscilloscopeChannel::CHANNEL_TYPE_ANALOG,
GetDefaultChannelColor(i),
1,
@@ -737,27 +798,6 @@ void OscilloscopeWindow::DoImportCSV(const string& filename)
}
}

//Parse the samples for each row
//TODO: be more efficient about this
vector<float> row;
string tmp;
for(size_t i=0; i < sizeof(line); i++)
{
if(line[i] == '\0' || line[i] == ',')
{
float f;
sscanf(tmp.c_str(), "%f", &f);
row.push_back(f);

if(line[i] == '\0')
break;
else
tmp = "";
}
else
tmp += line[i];
}

int64_t timestamp = row[0] * 1e12;
for(size_t i=0; i<ncols; i++)
{
24 changes: 22 additions & 2 deletions src/glscopeclient/masks/pcie-gen2-5gbps-rx.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
protocol:
name: PCIe gen 2 RX (5 Gbps)
reference: PCIe 2.0 base spec, table 4-11, figure 4-41
name: PCIe gen 2 RX (5 Gbps) data clocked
reference: PCIe 2.0 base spec, table 4-11, table 4-12, figure 4-41
displaylimits:
ymin: -500
ymax: 500
@@ -18,5 +18,25 @@ mask:
- x: 0
y: -50

- points:
- x: -1
y: 600
- x: 1
y: 600
- x: 1
y: 800
- x: -1
y: 800

- points:
- x: -1
y: -600
- x: 1
y: -600
- x: 1
y: -800
- x: -1
y: -800

conditions:
hitrate: 0