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

Commits on Mar 22, 2020

  1. Refactored protocol decoder config loading into two separate function…

    …s to address problems related to non-topological serialization order and protocol decoders with variable bus width
    azonenberg committed Mar 22, 2020
    Copy the full SHA
    23cd086 View commit details
Showing with 26 additions and 11 deletions.
  1. +10 −6 scopehal/ProtocolDecoder.cpp
  2. +2 −1 scopehal/ProtocolDecoder.h
  3. +13 −3 scopeprotocols/ParallelBusDecoder.cpp
  4. +1 −1 scopeprotocols/ParallelBusDecoder.h
16 changes: 10 additions & 6 deletions scopehal/ProtocolDecoder.cpp
Original file line number Diff line number Diff line change
@@ -249,6 +249,7 @@ void ProtocolDecoder::SetInput(size_t i, OscilloscopeChannel* channel)
if(!ValidateChannel(i, channel))
{
LogError("Invalid channel format\n");
//return;
}

if(m_channels[i] != NULL)
@@ -333,7 +334,7 @@ ProtocolDecoder* ProtocolDecoder::CreateDecoder(string protocol, string color)
if(m_createprocs.find(protocol) != m_createprocs.end())
return m_createprocs[protocol](color);

LogError("Invalid decoder name\n");
LogError("Invalid decoder name: %s\n", protocol.c_str());
return NULL;
}

@@ -552,21 +553,24 @@ void ProtocolDecoder::FindZeroCrossings(AnalogCapture* data, float threshold, st
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Serialization

void ProtocolDecoder::LoadConfiguration(const YAML::Node& node, IDTable& table)
void ProtocolDecoder::LoadParameters(const YAML::Node& node, IDTable& /*table*/)
{
//id, protocol, color are already loaded
m_displayname = node["nick"].as<string>();
m_hwname = node["name"].as<string>();

auto inputs = node["inputs"];
for(auto it : inputs)
SetInput(it.first.as<string>(), static_cast<OscilloscopeChannel*>(table[it.second.as<int>()]) );

auto parameters = node["parameters"];
for(auto it : parameters)
GetParameter(it.first.as<string>()).ParseString(it.second.as<string>());
}

void ProtocolDecoder::LoadInputs(const YAML::Node& node, IDTable& table)
{
auto inputs = node["inputs"];
for(auto it : inputs)
SetInput(it.first.as<string>(), static_cast<OscilloscopeChannel*>(table[it.second.as<int>()]) );
}

string ProtocolDecoder::SerializeConfiguration(IDTable& table)
{
//Save basic decode info
3 changes: 2 additions & 1 deletion scopehal/ProtocolDecoder.h
Original file line number Diff line number Diff line change
@@ -155,7 +155,8 @@ class ProtocolDecoder : public OscilloscopeChannel
/**
@brief Load configuration from a save file
*/
virtual void LoadConfiguration(const YAML::Node& node, IDTable& table);
virtual void LoadParameters(const YAML::Node& node, IDTable& table);
virtual void LoadInputs(const YAML::Node& node, IDTable& table);

protected:

16 changes: 13 additions & 3 deletions scopeprotocols/ParallelBusDecoder.cpp
Original file line number Diff line number Diff line change
@@ -98,10 +98,9 @@ bool ParallelBusDecoder::IsOverlay()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Serialization

void ParallelBusDecoder::LoadConfiguration(const YAML::Node& node, IDTable& table)
void ParallelBusDecoder::LoadParameters(const YAML::Node& node, IDTable& table)
{
ProtocolDecoder::LoadConfiguration(node, table);

ProtocolDecoder::LoadParameters(node, table);
m_width = m_parameters[m_widthname].GetIntVal();
}

@@ -172,4 +171,15 @@ void ParallelBusDecoder::Refresh()
cap->m_timescale = inputs[0]->m_timescale;
cap->m_startTimestamp = inputs[0]->m_startTimestamp;
cap->m_startPicoseconds = inputs[0]->m_startPicoseconds;

//Set all unused channels to NULL
for(size_t i=m_width; i < 16; i++)
{
if(m_channels[i] != NULL)
{
if(m_channels[i] != NULL)
m_channels[i]->Release();
m_channels[i] = NULL;
}
}
}
2 changes: 1 addition & 1 deletion scopeprotocols/ParallelBusDecoder.h
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ class ParallelBusDecoder : public ProtocolDecoder

virtual bool ValidateChannel(size_t i, OscilloscopeChannel* channel);

virtual void LoadConfiguration(const YAML::Node& node, IDTable& table);
virtual void LoadParameters(const YAML::Node& node, IDTable& table);

PROTOCOL_DECODER_INITPROC(ParallelBusDecoder)