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

Commits on Sep 7, 2020

  1. Implemented initial background color support in PacketDecoder. Right …

    …now only actually used for SPIFlashDecoder.
    azonenberg committed Sep 7, 2020
    Copy the full SHA
    6b8456f View commit details
Showing with 81 additions and 1 deletion.
  1. +1 −1 scopehal/Filter.h
  2. +22 −0 scopehal/PacketDecoder.cpp
  3. +24 −0 scopehal/PacketDecoder.h
  4. +34 −0 scopeprotocols/SPIFlashDecoder.cpp
2 changes: 1 addition & 1 deletion scopehal/Filter.h
Original file line number Diff line number Diff line change
@@ -231,7 +231,7 @@ class Filter : public OscilloscopeChannel
virtual void LoadInputs(const YAML::Node& node, IDTable& table);

/**
@brief Standard colors for protocol decoder decode overlays.
@brief Standard colors for protocol decode overlays.
Do not change ordering, add new items to the end only.
*/
22 changes: 22 additions & 0 deletions scopehal/PacketDecoder.cpp
Original file line number Diff line number Diff line change
@@ -30,6 +30,28 @@
#include "scopehal.h"
#include "PacketDecoder.h"

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Color schemes

Gdk::Color PacketDecoder::m_backgroundColors[STANDARD_COLOR_COUNT] =
{
Gdk::Color("#101010"), //COLOR_DEFAULT
Gdk::Color("#800000"), //COLOR_ERROR
Gdk::Color("#000080"), //COLOR_STATUS
Gdk::Color("#808000"), //COLOR_CONTROL
Gdk::Color("#336699"), //COLOR_DATA_READ
Gdk::Color("#339966"), //COLOR_DATA_WRITE
Gdk::Color("#600050"), //COLOR_COMMAND
};

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Packet

Packet::Packet()
: m_displayBackgroundColor(PacketDecoder::m_backgroundColors[PacketDecoder::COLOR_DEFAULT])
{
}

Packet::~Packet()
{
}
24 changes: 24 additions & 0 deletions scopehal/PacketDecoder.h
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@
class Packet
{
public:
Packet();
virtual ~Packet();

///Offset of the packet from the start of the capture (picoseconds)
@@ -52,6 +53,9 @@ class Packet

//Packet bytes
std::vector<uint8_t> m_data;

//Background color of the packet
Gdk::Color m_displayBackgroundColor;
};

/**
@@ -75,6 +79,26 @@ class PacketDecoder : public Filter
virtual Packet* CreateMergedHeader(Packet* pack);
virtual bool CanMerge(Packet* a, Packet* b);

/**
@brief Standard colors for protocol analyzer lines.
Do not change ordering, add new items to the end only.
*/
enum
{
COLOR_DEFAULT, //Default color if not otherwise specified
COLOR_ERROR, //Malformed packets, or packets indicating an error condition
COLOR_STATUS, //Reading or writing status registers
COLOR_CONTROL, //Reading or writing control registers
COLOR_DATA_READ, //Reading unspecified data
COLOR_DATA_WRITE, //Writing unspecified data
COLOR_COMMAND, //Executing commands of some sort

STANDARD_COLOR_COUNT
} standard_color;

static Gdk::Color m_backgroundColors[STANDARD_COLOR_COUNT];

protected:
void ClearPackets();

34 changes: 34 additions & 0 deletions scopeprotocols/SPIFlashDecoder.cpp
Original file line number Diff line number Diff line change
@@ -178,6 +178,7 @@ void SPIFlashDecoder::Refresh()
state = STATE_IDLE;
else
{
//Create the packet
pack = new Packet;
pack->m_offset = din->m_offsets[iin] * din->m_timescale;
pack->m_len = 0;
@@ -198,6 +199,8 @@ void SPIFlashDecoder::Refresh()
address_bytes_left = 1;
addr = 0;
addr_start = din->m_offsets[iin+1];

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_CONTROL];
break;

//x1 program
@@ -207,6 +210,8 @@ void SPIFlashDecoder::Refresh()
address_bytes_left = 2; //TODO: this is device specific, current value is for W25N
addr = 0;
addr_start = din->m_offsets[iin+1];

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_COMMAND];
break;

//Slow read (no dummy clocks)
@@ -216,18 +221,24 @@ void SPIFlashDecoder::Refresh()
address_bytes_left = 2; //TODO: this is device specific, current value is for W25N
addr = 0;
addr_start = din->m_offsets[iin+1];

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_DATA_READ];
break;

//Clear write enable flag
case 0x04:
current_cmd = SPIFlashSymbol::CMD_WRITE_DISABLE;
state = STATE_IDLE;

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_CONTROL];
break;

//Set write enable flag
case 0x06:
current_cmd = SPIFlashSymbol::CMD_WRITE_ENABLE;
state = STATE_IDLE;

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_CONTROL];
break;

//Fast read (with dummy clocks)
@@ -237,6 +248,8 @@ void SPIFlashDecoder::Refresh()
address_bytes_left = 2; //TODO: this is device specific, current value is for W25N
addr = 0;
addr_start = din->m_offsets[iin+1];

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_DATA_READ];
break;

//Read the status register
@@ -249,6 +262,8 @@ void SPIFlashDecoder::Refresh()
address_bytes_left = 1;
addr = 0;
addr_start = din->m_offsets[iin+1];

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_STATUS];
break;

//Quad input page program
@@ -258,6 +273,8 @@ void SPIFlashDecoder::Refresh()
address_bytes_left = 2; //TODO: this is device specific, current value is for W25N
addr = 0;
addr_start = din->m_offsets[iin+1];

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_DATA_WRITE];
break;

//0x3b 1-1-2 fast read
@@ -269,13 +286,17 @@ void SPIFlashDecoder::Refresh()
address_bytes_left = 2; //TODO: this is device specific, current value is for W25N
addr = 0;
addr_start = din->m_offsets[iin+1];

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_DATA_READ];
break;

//Read the IDCODE
case 0x9f:
current_cmd = SPIFlashSymbol::CMD_READ_JEDEC_ID;
state = STATE_DUMMY_BEFORE_DATA;
data_type = SPIFlashSymbol::TYPE_VENDOR_ID;

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_STATUS];
break;

//0xbb 1-2-2 fast read
@@ -288,6 +309,8 @@ void SPIFlashDecoder::Refresh()
address_bytes_left = 2; //TODO: this is device specific, current value is for W25N
addr = 0;
addr_start = din->m_offsets[iin+1];

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_COMMAND];
break;

//1-4-4 fast read
@@ -297,12 +320,16 @@ void SPIFlashDecoder::Refresh()
address_bytes_left = 2; //TODO: this is device specific, current value is for W25N
addr = 0;
addr_start = din->m_offsets[iin+1];

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_DATA_READ];
break;

//Reset should occur by itself, ignore any data after that
case 0xff:
current_cmd = SPIFlashSymbol::CMD_RESET;
state = STATE_IDLE;

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_COMMAND];
break;

////////////////////////////////////////////////////////////////////////////////////////////////
@@ -314,6 +341,8 @@ void SPIFlashDecoder::Refresh()
state = STATE_DUMMY_BEFORE_ADDRESS;
address_bytes_left = 2;
addr = 0;

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_COMMAND];
break;

//Read a page of NAND
@@ -322,6 +351,8 @@ void SPIFlashDecoder::Refresh()
state = STATE_DUMMY_BEFORE_ADDRESS;
address_bytes_left = 2;
addr = 0;

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_COMMAND];
break;

//0x0c fast read with 4 byte address
@@ -339,6 +370,8 @@ void SPIFlashDecoder::Refresh()
default:
current_cmd = SPIFlashSymbol::CMD_UNKNOWN;
state = STATE_IDLE;

pack->m_displayBackgroundColor = m_backgroundColors[COLOR_ERROR];
break;
}

@@ -968,6 +1001,7 @@ Packet* SPIFlashDecoder::CreateMergedHeader(Packet* pack)
ret->m_offset = pack->m_offset;
ret->m_len = pack->m_len; //TODO: extend?
ret->m_headers["Op"] = "Poll Status";
ret->m_displayBackgroundColor = m_backgroundColors[COLOR_STATUS];

//TODO: add other fields?
return ret;