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
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c193ae1cf9b3
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 41bf8fd93001
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on May 18, 2020

  1. Copy the full SHA
    41bf8fd View commit details
6 changes: 3 additions & 3 deletions scopeprotocols/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -36,9 +36,9 @@ set(SCOPEPROTOCOLS_SOURCES
SPIDecoder.cpp
ThresholdDecoder.cpp
TMDSDecoder.cpp
#TopMeasurementDecoder.cpp
#ARTDecoder.cpp
#UartClockRecoveryDecoder.cpp
TopMeasurementDecoder.cpp
UARTDecoder.cpp
UartClockRecoveryDecoder.cpp
#USB2ActivityDecoder.cpp
#USB2PacketDecoder.cpp
#USB2PCSDecoder.cpp
12 changes: 7 additions & 5 deletions scopeprotocols/TopMeasurementDecoder.cpp
Original file line number Diff line number Diff line change
@@ -105,7 +105,7 @@ void TopMeasurementDecoder::Refresh()
SetData(NULL);
return;
}
AnalogCapture* din = dynamic_cast<AnalogCapture*>(m_channels[0]->GetData());
auto din = dynamic_cast<AnalogWaveform*>(m_channels[0]->GetData());
if(din == NULL)
{
SetData(NULL);
@@ -146,7 +146,7 @@ void TopMeasurementDecoder::Refresh()
float global_top = fbin*m_range + min;

//Create the output
AnalogCapture* cap = new AnalogCapture;
auto cap = new AnalogWaveform;

float last = min;
int64_t tedge = 0;
@@ -157,11 +157,11 @@ void TopMeasurementDecoder::Refresh()
float fmax = -99999;
float fmin = 99999;

for(size_t i=0; i < din->m_samples.size(); i++)
for(size_t i=0; i < len; i++)
{
//Wait for a falling edge
float cur = din->m_samples[i];
int64_t tnow = din->m_samples[i].m_offset * din->m_timescale;
int64_t tnow = din->m_offsets[i] * din->m_timescale;

if( (cur > m_midpoint) && (last <= m_midpoint) )
{
@@ -174,7 +174,9 @@ void TopMeasurementDecoder::Refresh()
if(vavg < fmin)
fmin = vavg;

cap->m_samples.push_back(AnalogSample(tedge, tnow-tedge, vavg));
cap->m_offsets.push_back(tedge);
cap->m_durations.push_back(tnow - tedge);
cap->m_samples.push_back(vavg);
}
tedge = tnow;
}
40 changes: 20 additions & 20 deletions scopeprotocols/UARTDecoder.cpp
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ void UARTDecoder::Refresh()
SetData(NULL);
return;
}
DigitalCapture* din = dynamic_cast<DigitalCapture*>(m_channels[0]->GetData());
auto din = dynamic_cast<DigitalWaveform*>(m_channels[0]->GetData());
if(din == NULL)
{
SetData(NULL);
@@ -121,7 +121,7 @@ void UARTDecoder::Refresh()
int64_t scaledbitper = ibitper / din->m_timescale;

//UART processing
AsciiCapture* cap = new AsciiCapture;
auto cap = new AsciiWaveform;
cap->m_timescale = din->m_timescale;
cap->m_startTimestamp = din->m_startTimestamp;
cap->m_startPicoseconds = din->m_startPicoseconds;
@@ -131,22 +131,23 @@ void UARTDecoder::Refresh()
size_t isample = 0;
int64_t tlast = 0;
Packet* pack = NULL;
while(isample < din->m_samples.size())
size_t len = din->m_samples.size();
while(isample < len)
{
//Wait for signal to go high (idle state)
while( (isample < din->m_samples.size()) && !din->m_samples[isample].m_sample)
while( (isample < len) && !din->m_samples[isample])
isample ++;
if(isample >= din->m_samples.size())
if(isample >= len)
break;

//Wait for a falling edge (start bit)
while( (isample < din->m_samples.size()) && din->m_samples[isample].m_sample)
while( (isample < len) && din->m_samples[isample])
isample ++;
if(isample >= din->m_samples.size())
if(isample >= len)
break;

//Time of the start bit
int64_t tstart = din->m_samples[isample].m_offset;
int64_t tstart = din->m_offsets[isample];

//The next data bit should be measured 1.5 bit periods after the falling edge
next_value = tstart + scaledbitper + scaledbitper/2;
@@ -156,34 +157,33 @@ void UARTDecoder::Refresh()
for(int ibit=0; ibit<8; ibit++)
{
//Find the sample of interest
while( (isample < din->m_samples.size()) && ((din->m_samples[isample].m_offset + din->m_samples[isample].m_duration) < next_value))
while( (isample < len) && ((din->m_offsets[isample] + din->m_durations[isample]) < next_value))
isample ++;
if(isample >= din->m_samples.size())
if(isample >= len)
break;

//Got the sample
dval = (dval >> 1) | (din->m_samples[isample].m_sample ? 0x80 : 0);
dval = (dval >> 1) | (din->m_samples[isample] ? 0x80 : 0);

//Go on to the next bit
next_value += scaledbitper;
}

//If we ran out of space before we hit the end of the buffer, abort
if(isample >= din->m_samples.size())
if(isample >= len)
break;

//All good, read the stop bit
while( (isample < din->m_samples.size()) && ((din->m_samples[isample].m_offset + din->m_samples[isample].m_duration) < next_value))
while( (isample < len) && ((din->m_offsets[isample] + din->m_durations[isample]) < next_value))
isample ++;
if(isample >= din->m_samples.size())
if(isample >= len)
break;

//Save the sample
int64_t tend = next_value + (scaledbitper/2);
cap->m_samples.push_back(AsciiSample(
tstart,
tend-tstart,
(char)dval));
cap->m_offsets.push_back(tstart);
cap->m_durations.push_back(tend-tstart);
cap->m_samples.push_back(dval);

//If the last packet was more than 3 byte times ago, start a new one
if(pack != NULL)
@@ -212,7 +212,7 @@ void UARTDecoder::Refresh()
//If we have a packet in progress, add it
if(pack)
{
pack->m_len = (din->m_samples[din->m_samples.size()-1].m_offset * din->m_timescale) - pack->m_offset;
pack->m_len = (din->m_offsets[len-1] * din->m_timescale) - pack->m_offset;
FinishPacket(pack);
}

@@ -235,7 +235,7 @@ void UARTDecoder::FinishPacket(Packet* pack)
m_packets.push_back(pack);
}

Gdk::Color UARTDecoder::GetColor(int i)
Gdk::Color UARTDecoder::GetColor(int /*i*/)
{
return Gdk::Color(m_displaycolor);
}
23 changes: 13 additions & 10 deletions scopeprotocols/UartClockRecoveryDecoder.cpp
Original file line number Diff line number Diff line change
@@ -107,8 +107,8 @@ void UartClockRecoveryDecoder::Refresh()
return;
}

AnalogCapture* din = dynamic_cast<AnalogCapture*>(m_channels[0]->GetData());
if( (din == NULL) || (din->GetDepth() == 0) )
auto din = dynamic_cast<AnalogWaveform*>(m_channels[0]->GetData());
if( (din == NULL) || (din->m_samples.size() == 0) )
{
SetData(NULL);
return;
@@ -119,7 +119,7 @@ void UartClockRecoveryDecoder::Refresh()
int64_t ps = static_cast<int64_t>(1.0e12f / baud);

//Create the output waveform and copy our timescales
DigitalCapture* cap = new DigitalCapture;
auto cap = new DigitalWaveform;
cap->m_startTimestamp = din->m_startTimestamp;
cap->m_startPicoseconds = din->m_startPicoseconds;
cap->m_triggerPhase = 0;
@@ -132,13 +132,13 @@ void UartClockRecoveryDecoder::Refresh()
bool first = true;
bool last = false;
const float threshold = m_parameters[m_threshname].GetFloatVal();
for(size_t i=1; i<din->m_samples.size(); i++)
size_t len = din->m_samples.size();
for(size_t i=1; i<len; i++)
{
auto sin = din->m_samples[i];
bool value = static_cast<float>(sin) > threshold;
bool value = din->m_samples[i] > threshold;

//Start time of the sample, in picoseconds
int64_t t = din->m_triggerPhase + din->m_timescale * sin.m_offset;
int64_t t = din->m_triggerPhase + din->m_timescale * din->m_offsets[i];

//Move to the middle of the sample
t += din->m_timescale/2;
@@ -166,7 +166,8 @@ void UartClockRecoveryDecoder::Refresh()
size_t nedge = 0;
int64_t bcenter = 0;
bool value = false;
for(; nedge < edges.size();)
size_t elen = edges.size();
for(; nedge < elen;)
{
//The current bit starts half a baud period after the start bit edge
bcenter = edges[nedge] + ps/2;
@@ -175,7 +176,7 @@ void UartClockRecoveryDecoder::Refresh()
//We have ten start/ data/stop bits after this
for(int i=0; i<10; i++)
{
if(nedge >= edges.size())
if(nedge >= elen)
break;

//If the next edge is around the time of this bit, re-sync to it
@@ -186,7 +187,9 @@ void UartClockRecoveryDecoder::Refresh()
}

//Emit a sample for this data bit
cap->m_samples.push_back(DigitalSample(bcenter, ps, value));
cap->m_offsets.push_back(bcenter);
cap->m_durations.push_back(ps);
cap->m_samples.push_back(value);
value = !value;

//Next bit starts one baud period later
2 changes: 1 addition & 1 deletion scopeprotocols/scopeprotocols.cpp
Original file line number Diff line number Diff line change
@@ -72,11 +72,11 @@ void ScopeProtocolStaticInit()
AddDecoderClass(SincInterpolationDecoder);
AddDecoderClass(SPIDecoder);
AddDecoderClass(ThresholdDecoder);
/*
AddDecoderClass(TMDSDecoder);
AddDecoderClass(TopMeasurementDecoder);
AddDecoderClass(UARTDecoder);
AddDecoderClass(UartClockRecoveryDecoder);
/*
AddDecoderClass(USB2ActivityDecoder);
AddDecoderClass(USB2PacketDecoder);
AddDecoderClass(USB2PCSDecoder);
2 changes: 1 addition & 1 deletion scopeprotocols/scopeprotocols.h
Original file line number Diff line number Diff line change
@@ -73,11 +73,11 @@
#include "SincInterpolationDecoder.h"
#include "SPIDecoder.h"
#include "ThresholdDecoder.h"
/*
#include "TMDSDecoder.h"
#include "TopMeasurementDecoder.h"
#include "UARTDecoder.h"
#include "UartClockRecoveryDecoder.h"
/*
#include "USB2ActivityDecoder.h"
#include "USB2PacketDecoder.h"
#include "USB2PCSDecoder.h"