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: f54e37797a00
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 04fa6b329260
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Dec 4, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7a91017 View commit details
  2. Copy the full SHA
    a639676 View commit details
  3. Copy the full SHA
    04fa6b3 View commit details
Showing with 84 additions and 31 deletions.
  1. +70 −29 scopeprotocols/USB2PCSDecoder.cpp
  2. +3 −1 scopeprotocols/USB2PCSDecoder.h
  3. +11 −1 scopeprotocols/USB2PacketDecoder.cpp
99 changes: 70 additions & 29 deletions scopeprotocols/USB2PCSDecoder.cpp
Original file line number Diff line number Diff line change
@@ -119,6 +119,7 @@ void USB2PCSDecoder::Refresh()
//Decode stuff
size_t count = 0;
uint8_t data = 0;
bool first = true;
for(size_t i=0; i<len; i++)
{
switch(state)
@@ -128,7 +129,7 @@ void USB2PCSDecoder::Refresh()
break;

case STATE_SYNC:
RefreshIterationSync(i, state, ui_width, cap, din, count, offset, data);
RefreshIterationSync(i, state, ui_width, cap, din, count, offset, data, first);
break;

case STATE_DATA:
@@ -224,7 +225,8 @@ void USB2PCSDecoder::RefreshIterationSync(
USB2PMAWaveform* din,
size_t& count,
int64_t& offset,
uint8_t& data)
uint8_t& data,
bool& first)
{
size_t sample_fs = din->m_durations[nin] * din->m_timescale;
float sample_width_ui = sample_fs * 1.0f / ui_width;
@@ -240,15 +242,26 @@ void USB2PCSDecoder::RefreshIterationSync(
if( (sample_width_ui > 1.5) || (sample_width_ui < 0.5) ||
(sin.m_type != USB2PMASymbol::TYPE_J))
{
//Sync until the error happened
cap->m_offsets.push_back(offset);
cap->m_durations.push_back(din->m_offsets[nin] - offset);
cap->m_samples.push_back(USB2PCSSymbol(USB2PCSSymbol::TYPE_SYNC, 0));

//Then error symbol for this K
cap->m_offsets.push_back(din->m_offsets[nin]);
cap->m_durations.push_back(din->m_durations[nin]);
cap->m_samples.push_back(USB2PCSSymbol(USB2PCSSymbol::TYPE_ERROR, 0));
//First packet? Don't print an error. We're probably just halfway into a previous packet.
//Clear out any half-baked garbage.
if(first)
{
cap->m_offsets.clear();
cap->m_durations.clear();
cap->m_samples.clear();
}
else
{
//Sync until the error happened
cap->m_offsets.push_back(offset);
cap->m_durations.push_back(din->m_offsets[nin] - offset);
cap->m_samples.push_back(USB2PCSSymbol(USB2PCSSymbol::TYPE_SYNC, 0));

//Then error symbol for this K
cap->m_offsets.push_back(din->m_offsets[nin]);
cap->m_durations.push_back(din->m_durations[nin]);
cap->m_samples.push_back(USB2PCSSymbol(USB2PCSSymbol::TYPE_ERROR, 0));
}

//Go back
state = STATE_IDLE;
@@ -263,15 +276,26 @@ void USB2PCSDecoder::RefreshIterationSync(
if( (sample_width_ui > 1.5) || (sample_width_ui < 0.5) ||
(sin.m_type != USB2PMASymbol::TYPE_K) )
{
//Sync until the error happened
cap->m_offsets.push_back(offset);
cap->m_durations.push_back(din->m_offsets[nin] - offset);
cap->m_samples.push_back(USB2PCSSymbol(USB2PCSSymbol::TYPE_SYNC, 0));

//Then error symbol for this J
cap->m_offsets.push_back(din->m_offsets[nin]);
cap->m_durations.push_back(din->m_durations[nin]);
cap->m_samples.push_back(USB2PCSSymbol(USB2PCSSymbol::TYPE_ERROR, 0));
//First packet? Don't print an error. We're probably just halfway into a previous packet.
//Clear out any half-baked garbage.
if(first)
{
cap->m_offsets.clear();
cap->m_durations.clear();
cap->m_samples.clear();
}
else
{
//Sync until the error happened
cap->m_offsets.push_back(offset);
cap->m_durations.push_back(din->m_offsets[nin] - offset);
cap->m_samples.push_back(USB2PCSSymbol(USB2PCSSymbol::TYPE_SYNC, 0));

//Then error symbol for this J
cap->m_offsets.push_back(din->m_offsets[nin]);
cap->m_durations.push_back(din->m_durations[nin]);
cap->m_samples.push_back(USB2PCSSymbol(USB2PCSSymbol::TYPE_ERROR, 0));
}

//Go back
state = STATE_IDLE;
@@ -285,15 +309,26 @@ void USB2PCSDecoder::RefreshIterationSync(
//Should be a K and at least two UIs long
if( (sample_width_ui < 1.5) || (sin.m_type != USB2PMASymbol::TYPE_K) )
{
//Sync until the error happened
cap->m_offsets.push_back(offset);
cap->m_durations.push_back(din->m_offsets[nin] - offset);
cap->m_samples.push_back(USB2PCSSymbol(USB2PCSSymbol::TYPE_SYNC, 0));

//Then error symbol for this J
cap->m_offsets.push_back(din->m_offsets[nin]);
cap->m_durations.push_back(din->m_durations[nin]);
cap->m_samples.push_back(USB2PCSSymbol(USB2PCSSymbol::TYPE_ERROR, 0));
//First packet? Don't print an error. We're probably just halfway into a previous packet.
//Clear out any half-baked garbage.
if(first)
{
cap->m_offsets.clear();
cap->m_durations.clear();
cap->m_samples.clear();
}
else
{
//Sync until the error happened
cap->m_offsets.push_back(offset);
cap->m_durations.push_back(din->m_offsets[nin] - offset);
cap->m_samples.push_back(USB2PCSSymbol(USB2PCSSymbol::TYPE_SYNC, 0));

//Then error symbol for this J
cap->m_offsets.push_back(din->m_offsets[nin]);
cap->m_durations.push_back(din->m_durations[nin]);
cap->m_samples.push_back(USB2PCSSymbol(USB2PCSSymbol::TYPE_ERROR, 0));
}

state = STATE_IDLE;
return;
@@ -303,6 +338,9 @@ void USB2PCSDecoder::RefreshIterationSync(
//We end right at the boundary.
if(round(sample_width_ui) == 2)
{
//Got a valid sync. Not the first packet anymore
first = false;

//Save the sync symbol
cap->m_offsets.push_back(offset);
cap->m_durations.push_back(din->m_offsets[nin] + din->m_durations[nin] - offset);
@@ -339,6 +377,9 @@ void USB2PCSDecoder::RefreshIterationSync(
}
else
{
//Got a valid sync. Not the first packet anymore
first = false;

data = 0;

//Add the ones, LSB to MSB
4 changes: 3 additions & 1 deletion scopeprotocols/USB2PCSDecoder.h
Original file line number Diff line number Diff line change
@@ -128,7 +128,9 @@ class USB2PCSDecoder : public Filter
USB2PMAWaveform* din,
size_t& count,
int64_t& offset,
uint8_t& data);
uint8_t& data,
bool& first
);

void RefreshIterationData(
size_t nin,
12 changes: 11 additions & 1 deletion scopeprotocols/USB2PacketDecoder.cpp
Original file line number Diff line number Diff line change
@@ -773,7 +773,16 @@ void USB2PacketDecoder::DecodeData(USB2PacketWaveform* cap, size_t istart, size_

//Next should be a CRC16
else if(s.m_type == USB2PacketSymbol::TYPE_CRC16_GOOD)
{
i++;
break;
}
else if(s.m_type == USB2PacketSymbol::TYPE_CRC16_BAD)
{
i++;
pack->m_displayBackgroundColor = m_backgroundColors[PROTO_COLOR_ERROR];
break;
}

i++;
}
@@ -785,7 +794,7 @@ void USB2PacketDecoder::DecodeData(USB2PacketWaveform* cap, size_t istart, size_
return;
}
string ack = "";
auto sack = cap->m_samples[i++];
auto sack = cap->m_samples[i];
if(sack.m_type == USB2PacketSymbol::TYPE_PID)
{
if( (sack.m_data & 0xf) == USB2PacketSymbol::PID_ACK)
@@ -804,6 +813,7 @@ void USB2PacketDecoder::DecodeData(USB2PacketWaveform* cap, size_t istart, size_
}

pack->m_len = ((cap->m_offsets[i] + cap->m_durations[i]) * cap->m_timescale) - pack->m_offset;
i++;

//Format the data
string details = "";