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

Commits on Dec 4, 2020

  1. Copy the full SHA
    e78ae38 View commit details
  2. Copy the full SHA
    da7431e View commit details
Showing with 30 additions and 6 deletions.
  1. +9 −6 scopeprotocols/USB2PMADecoder.cpp
  2. +7 −0 scopeprotocols/USB2PMADecoder.h
  3. +14 −0 scopeprotocols/USB2PacketDecoder.cpp
15 changes: 9 additions & 6 deletions scopeprotocols/USB2PMADecoder.cpp
Original file line number Diff line number Diff line change
@@ -44,10 +44,13 @@ USB2PMADecoder::USB2PMADecoder(const string& color)
CreateInput("D+");
CreateInput("D-");

//TODO: make this an enum/bool
m_speedname = "Full Speed";
m_parameters[m_speedname] = FilterParameter(FilterParameter::TYPE_INT, Unit(Unit::UNIT_COUNTS));
m_parameters[m_speedname].SetIntVal(1);
m_speedname = "Speed";

m_parameters[m_speedname] = FilterParameter(FilterParameter::TYPE_ENUM, Unit(Unit::UNIT_COUNTS));
m_parameters[m_speedname].AddEnumValue("Low (1.5 Mbps)", SPEED_LOW);
m_parameters[m_speedname].AddEnumValue("Full (12 Mbps)", SPEED_FULL);
m_parameters[m_speedname].AddEnumValue("High (480 Mbps)", SPEED_HIGH);
m_parameters[m_speedname].SetIntVal(SPEED_FULL);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -115,7 +118,7 @@ void USB2PMADecoder::Refresh()
size_t len = min(din_p->m_samples.size(), din_n->m_samples.size());

//Figure out our speed so we know what's going on
int speed = m_parameters[m_speedname].GetIntVal();
auto speed = static_cast<Speed>(m_parameters[m_speedname].GetIntVal());

//Figure out the line state for each input (no clock recovery yet)
auto cap = new USB2PMAWaveform;
@@ -128,7 +131,7 @@ void USB2PMADecoder::Refresh()
USB2PMASymbol::SegmentType type = USB2PMASymbol::TYPE_SE1;
if(fabs(vdiff) > 0.4)
{
if(speed == 1)
if( (speed == SPEED_FULL) || (speed == SPEED_HIGH) )
{
if(vdiff > 0)
type = USB2PMASymbol::TYPE_J;
7 changes: 7 additions & 0 deletions scopeprotocols/USB2PMADecoder.h
Original file line number Diff line number Diff line change
@@ -85,6 +85,13 @@ class USB2PMADecoder : public Filter
virtual std::string GetText(int i);
virtual Gdk::Color GetColor(int i);

enum Speed
{
SPEED_LOW,
SPEED_FULL,
SPEED_HIGH
};

PROTOCOL_DECODER_INITPROC(USB2PMADecoder)

protected:
14 changes: 14 additions & 0 deletions scopeprotocols/USB2PacketDecoder.cpp
Original file line number Diff line number Diff line change
@@ -577,6 +577,7 @@ void USB2PacketDecoder::DecodeSetup(USB2PacketWaveform* cap, size_t istart, size
Packet* pack = new Packet;
pack->m_offset = cap->m_offsets[istart] * cap->m_timescale;
pack->m_headers["Type"] = "SETUP";
pack->m_displayBackgroundColor = m_backgroundColors[PROTO_COLOR_CONTROL];
char tmp[256];
snprintf(tmp, sizeof(tmp), "%d", saddr.m_data);
pack->m_headers["Device"] = tmp;
@@ -707,9 +708,15 @@ void USB2PacketDecoder::DecodeData(USB2PacketWaveform* cap, size_t istart, size_
Packet* pack = new Packet;
pack->m_offset = cap->m_offsets[istart] * cap->m_timescale;
if( (cap->m_samples[istart].m_data & 0xf) == USB2PacketSymbol::PID_IN)
{
pack->m_headers["Type"] = "IN";
pack->m_displayBackgroundColor = m_backgroundColors[PROTO_COLOR_DATA_READ];
}
else
{
pack->m_headers["Type"] = "OUT";
pack->m_displayBackgroundColor = m_backgroundColors[PROTO_COLOR_DATA_WRITE];
}
snprintf(tmp, sizeof(tmp), "%d", saddr.m_data);
pack->m_headers["Device"] = tmp;
snprintf(tmp, sizeof(tmp), "%d", sendp.m_data);
@@ -732,6 +739,7 @@ void USB2PacketDecoder::DecodeData(USB2PacketWaveform* cap, size_t istart, size_
Packet* pack = new Packet;
pack->m_offset = cap->m_offsets[istart] * cap->m_timescale;
pack->m_headers["Details"] = "ERROR";
pack->m_displayBackgroundColor = m_backgroundColors[PROTO_COLOR_ERROR];
m_packets.push_back(pack);
return;
}
@@ -740,9 +748,15 @@ void USB2PacketDecoder::DecodeData(USB2PacketWaveform* cap, size_t istart, size_
Packet* pack = new Packet;
pack->m_offset = cap->m_offsets[istart] * cap->m_timescale;
if( (cap->m_samples[istart].m_data & 0xf) == USB2PacketSymbol::PID_IN)
{
pack->m_headers["Type"] = "IN";
pack->m_displayBackgroundColor = m_backgroundColors[PROTO_COLOR_DATA_READ];
}
else
{
pack->m_headers["Type"] = "OUT";
pack->m_displayBackgroundColor = m_backgroundColors[PROTO_COLOR_DATA_WRITE];
}
snprintf(tmp, sizeof(tmp), "%d", saddr.m_data);
pack->m_headers["Device"] = tmp;
snprintf(tmp, sizeof(tmp), "%d", sendp.m_data);