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

Commits on Dec 12, 2019

  1. Verified

    This commit was signed with the committer’s verified signature.
    headius Charles Oliver Nutter
    Copy the full SHA
    cf00dcb View commit details
12 changes: 12 additions & 0 deletions scopehal/ChannelRenderer.cpp
Original file line number Diff line number Diff line change
@@ -39,6 +39,18 @@

using namespace std;

Gdk::Color ChannelRenderer::m_standardColors[STANDARD_COLOR_COUNT] =
{
Gdk::Color("#336699"), //COLOR_DATA
Gdk::Color("#c000a0"), //COLOR_CONTROL
Gdk::Color("#ffff00"), //COLOR_ADDRESS
Gdk::Color("#808080"), //COLOR_PREAMBLE
Gdk::Color("#00ff00"), //COLOR_CHECKSUM_OK
Gdk::Color("#ff0000"), //COLOR_CHECKSUM_BAD
Gdk::Color("#ff0000"), //COLOR_ERROR
Gdk::Color("#404040") //COLOR_IDLE
};

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction

22 changes: 22 additions & 0 deletions scopehal/ChannelRenderer.h
Original file line number Diff line number Diff line change
@@ -107,6 +107,28 @@ class ChannelRenderer
//Maximum width, in pixels, of one sample
float m_maxsamplewidth;

protected:
/**
@brief Standard colors for protocol decoder decode overlays.
Do not change ordering, add new items to the end only.
*/
enum
{
COLOR_DATA, //protocol data
COLOR_CONTROL, //generic control sequences
COLOR_ADDRESS, //addresses or device IDs
COLOR_PREAMBLE, //preambles, start bits, and other constant framing
COLOR_CHECKSUM_OK, //valid CRC/checksum
COLOR_CHECKSUM_BAD, //invalid CRC/checksum
COLOR_ERROR, //malformed traffic
COLOR_IDLE, //downtime between frames

STANDARD_COLOR_COUNT
} standard_color;

static Gdk::Color m_standardColors[STANDARD_COLOR_COUNT];

protected:
OscilloscopeChannel* m_channel;
};
33 changes: 14 additions & 19 deletions scopeprotocols/EthernetRenderer.cpp
Original file line number Diff line number Diff line change
@@ -56,45 +56,40 @@ Gdk::Color EthernetRenderer::GetColor(int i)
{
EthernetCapture* data = dynamic_cast<EthernetCapture*>(m_channel->GetData());
if(data == NULL)
return Gdk::Color("#000000");
return m_standardColors[COLOR_ERROR];
if(i >= (int)data->m_samples.size())
return Gdk::Color("#000000");

//TODO: have a set of standard colors we use everywhere?
return m_standardColors[COLOR_ERROR];

auto sample = data->m_samples[i];
switch(sample.m_sample.m_type)
{
//Preamble: gray (not interesting)
//Preamble/SFD: gray (not interesting)
case EthernetFrameSegment::TYPE_PREAMBLE:
return Gdk::Color("#808080");

//SFD: yellow
return m_standardColors[COLOR_PREAMBLE];
case EthernetFrameSegment::TYPE_SFD:
return Gdk::Color("#ffff80");
return m_standardColors[COLOR_PREAMBLE];

//MAC addresses (src or dest): cyan
//MAC addresses (src or dest)
case EthernetFrameSegment::TYPE_DST_MAC:
case EthernetFrameSegment::TYPE_SRC_MAC:
return Gdk::Color("#80ffff");
return m_standardColors[COLOR_ADDRESS];

//Ethertype: Pink
//Control codes
case EthernetFrameSegment::TYPE_ETHERTYPE:
case EthernetFrameSegment::TYPE_VLAN_TAG:
return Gdk::Color("#ffcccc");
return m_standardColors[COLOR_CONTROL];

//Checksum: Green or red depending on if it's correct or not
//For now, always green b/c we don't implement the FCS :D
//TODO: verify checksum
case EthernetFrameSegment::TYPE_FCS:
return Gdk::Color("#00ff00");
return m_standardColors[COLOR_CHECKSUM_OK];

//Signal has entirely disappeared
case EthernetFrameSegment::TYPE_NO_CARRIER:
return Gdk::Color("#FF0000");
return m_standardColors[COLOR_ERROR];

//Payload: dark blue
//Payload
default:
return Gdk::Color("#336699");
return m_standardColors[COLOR_DATA];
}
}

28 changes: 12 additions & 16 deletions scopeprotocols/I2CRenderer.cpp
Original file line number Diff line number Diff line change
@@ -59,25 +59,21 @@ Gdk::Color I2CRenderer::GetColor(int i)
{
const I2CSymbol& s = capture->m_samples[i].m_sample;

//errors are red
if(s.m_stype == I2CSymbol::TYPE_ERROR)
return Gdk::Color("#ff0000");

//addresses are yellow
else if(s.m_stype == I2CSymbol::TYPE_ADDRESS)
return Gdk::Color("#ffff00");

//control characters are purple
else if(s.m_stype != I2CSymbol::TYPE_DATA)
return Gdk::Color("#c000a0");

//Data characters are green
else
return Gdk::Color("#008000");
switch(s.m_stype)
{
case I2CSymbol::TYPE_ERROR:
return m_standardColors[COLOR_ERROR];
case I2CSymbol::TYPE_ADDRESS:
return m_standardColors[COLOR_ADDRESS];
case I2CSymbol::TYPE_DATA:
return m_standardColors[COLOR_DATA];
default:
return m_standardColors[COLOR_CONTROL];
}
}

//error
return Gdk::Color("red");
return m_standardColors[COLOR_ERROR];
}

string I2CRenderer::GetText(int i)
13 changes: 4 additions & 9 deletions scopeprotocols/IBM8b10bRenderer.cpp
Original file line number Diff line number Diff line change
@@ -59,21 +59,16 @@ Gdk::Color IBM8b10bRenderer::GetColor(int i)
{
const IBM8b10bSymbol& s = capture->m_samples[i].m_sample;

//errors are red
if(s.m_error)
return Gdk::Color("#ff0000");

//control characters are purple
return m_standardColors[COLOR_ERROR];
else if(s.m_control)
return Gdk::Color("#c000a0");

//Data characters are green
return m_standardColors[COLOR_CONTROL];
else
return Gdk::Color("#008000");
return m_standardColors[COLOR_DATA];
}

//error
return Gdk::Color("red");
return m_standardColors[COLOR_ERROR];
}

string IBM8b10bRenderer::GetText(int i)
14 changes: 7 additions & 7 deletions scopeprotocols/JtagRenderer.cpp
Original file line number Diff line number Diff line change
@@ -61,27 +61,27 @@ Gdk::Color JtagRenderer::GetColor(int i)

switch(s.m_state)
{
//Unknown states are red
//Unknown states
case JtagSymbol::UNKNOWN_0:
case JtagSymbol::UNKNOWN_1:
case JtagSymbol::UNKNOWN_2:
case JtagSymbol::UNKNOWN_3:
case JtagSymbol::UNKNOWN_4:
return Gdk::Color("#ff0000");
return m_standardColors[COLOR_ERROR];

//Data characters are green
//Data characters
case JtagSymbol::SHIFT_IR:
case JtagSymbol::SHIFT_DR:
return Gdk::Color("#008000");
return m_standardColors[COLOR_DATA];

//intermediate states are purple
//intermediate states
default:
return Gdk::Color("#c000a0");
return m_standardColors[COLOR_CONTROL];
}
}

//error
return Gdk::Color("red");
return m_standardColors[COLOR_ERROR];
}

string JtagRenderer::GetText(int i)
16 changes: 8 additions & 8 deletions scopeprotocols/USB2PCSRenderer.cpp
Original file line number Diff line number Diff line change
@@ -57,30 +57,30 @@ Gdk::Color USB2PCSRenderer::GetColor(int i)
{
USB2PCSCapture* data = dynamic_cast<USB2PCSCapture*>(m_channel->GetData());
if(data == NULL)
return Gdk::Color("#000000");
return m_standardColors[COLOR_ERROR];
if(i >= (int)data->m_samples.size())
return Gdk::Color("#000000");
return m_standardColors[COLOR_ERROR];

//TODO: have a set of standard colors we use everywhere?

auto sample = data->m_samples[i];
switch(sample.m_sample.m_type)
{
case USB2PCSSymbol::TYPE_IDLE:
return Gdk::Color("#404040");
return m_standardColors[COLOR_IDLE];
case USB2PCSSymbol::TYPE_SYNC:
return Gdk::Color("#808080");
return m_standardColors[COLOR_PREAMBLE];
case USB2PCSSymbol::TYPE_EOP:
return Gdk::Color("#808080");
return m_standardColors[COLOR_PREAMBLE];
case USB2PCSSymbol::TYPE_RESET:
return Gdk::Color("#ffa000");
return m_standardColors[COLOR_CONTROL];
case USB2PCSSymbol::TYPE_DATA:
return Gdk::Color("#336699");
return m_standardColors[COLOR_DATA];

//invalid state, should never happen
case USB2PCSSymbol::TYPE_ERROR:
default:
return Gdk::Color("#ff0000");
return m_standardColors[COLOR_ERROR];
}
}

10 changes: 5 additions & 5 deletions scopeprotocols/USB2PMARenderer.cpp
Original file line number Diff line number Diff line change
@@ -56,9 +56,9 @@ Gdk::Color USB2PMARenderer::GetColor(int i)
{
USB2PMACapture* data = dynamic_cast<USB2PMACapture*>(m_channel->GetData());
if(data == NULL)
return Gdk::Color("#000000");
return m_standardColors[COLOR_ERROR];
if(i >= (int)data->m_samples.size())
return Gdk::Color("#000000");
return m_standardColors[COLOR_ERROR];

//TODO: have a set of standard colors we use everywhere?

@@ -67,15 +67,15 @@ Gdk::Color USB2PMARenderer::GetColor(int i)
{
case USB2PMASymbol::TYPE_J:
case USB2PMASymbol::TYPE_K:
return Gdk::Color("#008000");
return m_standardColors[COLOR_DATA];

case USB2PMASymbol::TYPE_SE0:
return Gdk::Color("#808080");
return m_standardColors[COLOR_PREAMBLE];

//invalid state, should never happen
case USB2PMASymbol::TYPE_SE1:
default:
return Gdk::Color("#ff0000");
return m_standardColors[COLOR_ERROR];
}
}

22 changes: 10 additions & 12 deletions scopeprotocols/USB2PacketRenderer.cpp
Original file line number Diff line number Diff line change
@@ -57,42 +57,40 @@ Gdk::Color USB2PacketRenderer::GetColor(int i)
{
USB2PacketCapture* data = dynamic_cast<USB2PacketCapture*>(m_channel->GetData());
if(data == NULL)
return Gdk::Color("#000000");
return m_standardColors[COLOR_ERROR];
if(i >= (int)data->m_samples.size())
return Gdk::Color("#000000");

//TODO: have a set of standard colors we use everywhere?
return m_standardColors[COLOR_ERROR];

auto sample = data->m_samples[i];
switch(sample.m_sample.m_type)
{
case USB2PacketSymbol::TYPE_PID:
if( (sample.m_sample.m_data == USB2PacketSymbol::PID_RESERVED) ||
(sample.m_sample.m_data == USB2PacketSymbol::PID_STALL) )
return Gdk::Color("#ff0000");
return m_standardColors[COLOR_ERROR];
else
return Gdk::Color("#808080");
return m_standardColors[COLOR_PREAMBLE];

case USB2PacketSymbol::TYPE_ADDR:
return Gdk::Color("#ff0080");
return m_standardColors[COLOR_ADDRESS];

case USB2PacketSymbol::TYPE_ENDP:
return Gdk::Color("#ffff00");
return m_standardColors[COLOR_ADDRESS];

case USB2PacketSymbol::TYPE_NFRAME:
return Gdk::Color("#336699");
return m_standardColors[COLOR_DATA];

case USB2PacketSymbol::TYPE_CRC5:
case USB2PacketSymbol::TYPE_CRC16:
return Gdk::Color("#008000"); //TODO: color code good/bad
return m_standardColors[COLOR_CHECKSUM_OK]; //TODO: verify checksum

case USB2PacketSymbol::TYPE_DATA:
return Gdk::Color("#336699");
return m_standardColors[COLOR_DATA];

//invalid state, should never happen
case USB2PacketSymbol::TYPE_ERROR:
default:
return Gdk::Color("#ff0000");
return m_standardColors[COLOR_ERROR];
}
}