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

Commits on Mar 5, 2020

  1. Copy the full SHA
    8ed7dc9 View commit details
  2. Copy the full SHA
    c6cd6da View commit details
  3. Copy the full SHA
    f66b35c View commit details
Showing with 168 additions and 2 deletions.
  1. +3 −1 scopehal/Measurement.cpp
  2. +111 −0 scopehal/Oscilloscope.cpp
  3. +16 −1 scopehal/Oscilloscope.h
  4. +33 −0 scopehal/ProtocolDecoder.cpp
  5. +5 −0 scopehal/ProtocolDecoder.h
4 changes: 3 additions & 1 deletion scopehal/Measurement.cpp
Original file line number Diff line number Diff line change
@@ -378,6 +378,8 @@ float Measurement::GetRiseTime(AnalogCapture* cap, float low, float high)
case STATE_UNKNOWN:
if(v > end)
state = STATE_FALLING;
if(v < start)
state = STATE_LOW;
break;

//Waiting for falling edge
@@ -524,7 +526,7 @@ string FloatMeasurement::GetValueAsString()
else
snprintf(tmp, sizeof(tmp), "%.2f mV", m_value * 1000);
break;

case TYPE_TIME:
if(fabs(m_value) < 1e-9)
snprintf(tmp, sizeof(tmp), "%.3f ps", m_value * 1e12);
111 changes: 111 additions & 0 deletions scopehal/Oscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -147,3 +147,114 @@ bool Oscilloscope::AcquireDataFifo()
}
return false;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Serialization

string Oscilloscope::SerializeConfiguration(map<void*, int>& idmap, int& nextID)
{
//Name ourself
int id = nextID ++;
idmap[this] = id;

//Save basic scope info
char tmp[1024];
snprintf(tmp, sizeof(tmp), " : %%\n");
string config = tmp;
snprintf(tmp, sizeof(tmp), " id: %d\n", id);
config += tmp;
snprintf(tmp, sizeof(tmp), " nick: \"%s\"\n", m_nickname.c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " name: \"%s\"\n", GetName().c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " vendor: \"%s\"\n", GetVendor().c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " serial: \"%s\"\n", GetSerial().c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " path: \"%s\"\n", "connection_string_not_yet_implemented");
config += tmp;

//Save channels
config += " channels: @\n";
for(size_t i=0; i<GetChannelCount(); i++)
{
auto chan = GetChannel(i);
if(!chan->IsPhysicalChannel())
continue; //skip any kind of math functions etc

id = nextID ++;
idmap[chan] = id;

//Basic channel info
snprintf(tmp, sizeof(tmp), " : %%\n");
config += tmp;
snprintf(tmp, sizeof(tmp), " id: %d\n", id);
config += tmp;
snprintf(tmp, sizeof(tmp), " index: %zu\n", i);
config += tmp;
snprintf(tmp, sizeof(tmp), " color: \"%s\"\n", chan->m_displaycolor.c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " nick: \"%s\"\n", chan->m_displayname.c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " name: \"%s\"\n", chan->GetHwname().c_str());
config += tmp;
switch(chan->GetType())
{
case OscilloscopeChannel::CHANNEL_TYPE_ANALOG:
config += " type: analog\n";
break;
case OscilloscopeChannel::CHANNEL_TYPE_DIGITAL:
config += " type: digital\n";
snprintf(tmp, sizeof(tmp), " width: %d\n", chan->GetWidth());
config += tmp;
break;
case OscilloscopeChannel::CHANNEL_TYPE_TRIGGER:
config += " type: trigger\n";
break;

//should never get complex channels on a scope
default:
break;
}

//Current channel configuration
if(chan->IsEnabled())
config += " enabled: 1\n";
else
config += " enabled: 0\n";
switch(chan->GetCoupling())
{
case OscilloscopeChannel::COUPLE_DC_1M:
config += " coupling: dc_1M\n";
break;
case OscilloscopeChannel::COUPLE_AC_1M:
config += " coupling: ac_1M\n";
break;
case OscilloscopeChannel::COUPLE_DC_50:
config += " coupling: dc_50\n";
break;
case OscilloscopeChannel::COUPLE_GND:
config += " coupling: gnd\n";
break;

//should never get synthetic coupling on a scope channel
default:
break;
}

if(chan->GetType() == OscilloscopeChannel::CHANNEL_TYPE_ANALOG)
{
snprintf(tmp, sizeof(tmp), " attenuation: %f\n", chan->GetAttenuation());
config += tmp;
snprintf(tmp, sizeof(tmp), " bwlimit: %d\n", chan->GetBandwidthLimit());
config += tmp;
snprintf(tmp, sizeof(tmp), " vrange: %f\n", chan->GetVoltageRange());
config += tmp;
snprintf(tmp, sizeof(tmp), " offset: %f\n", chan->GetOffset());
config += tmp;
}
}

return config;
}
17 changes: 16 additions & 1 deletion scopehal/Oscilloscope.h
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -382,6 +382,21 @@ class Oscilloscope : public virtual Instrument
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sequenced triggering

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Configuration storage

/**
@brief Serializes this oscilloscope's configuration to a YAML string.
Both idmap and nextID are expected to be modified by this function.
@param idmap Map of pointers to integer IDs
@param nextID The next ID value to use
@return YAML block with this oscilloscope's configuration
*/
virtual std::string SerializeConfiguration(std::map<void*, int>& idmap, int& nextID);

public:
bool HasPendingWaveforms();
size_t GetPendingWaveformCount();
33 changes: 33 additions & 0 deletions scopehal/ProtocolDecoder.cpp
Original file line number Diff line number Diff line change
@@ -549,3 +549,36 @@ void ProtocolDecoder::FindZeroCrossings(AnalogCapture* data, float threshold, st
last = value;
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Serialization

string ProtocolDecoder::SerializeConfiguration(std::map<void*, int>& idmap, int& nextID)
{
//Name ourself
int id = nextID ++;
idmap[this] = id;

//Save basic decode info
char tmp[1024];
snprintf(tmp, sizeof(tmp), " : %%\n");
string config = tmp;
snprintf(tmp, sizeof(tmp), " id: %d\n", id);
config += tmp;

//Channel info
//snprintf(tmp, sizeof(tmp), " protocol: \"%s\"\n", GetProtocolName().c_str());
//config += tmp;
snprintf(tmp, sizeof(tmp), " color: \"%s\"\n", m_displaycolor.c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " nick: \"%s\"\n", m_displayname.c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " name: \"%s\"\n", GetHwname().c_str());
config += tmp;

//Inputs

//Parameters

return config;
}
5 changes: 5 additions & 0 deletions scopehal/ProtocolDecoder.h
Original file line number Diff line number Diff line change
@@ -142,6 +142,11 @@ class ProtocolDecoder : public OscilloscopeChannel
void SetDirty()
{ m_dirty = true; }

/**
@brief Serialize this decoder's configuration to a string
*/
virtual std::string SerializeConfiguration(std::map<void*, int>& idmap, int& nextID);

protected:

///Names of signals we take as input