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

Commits on Sep 27, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7c985aa View commit details
  2. Copy the full SHA
    cf7df27 View commit details
Showing with 127 additions and 5 deletions.
  1. +108 −1 scopehal/TektronixOscilloscope.cpp
  2. +15 −0 scopehal/TektronixOscilloscope.h
  3. +4 −4 scopehal/Unit.cpp
109 changes: 108 additions & 1 deletion scopehal/TektronixOscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -190,6 +190,7 @@ TektronixOscilloscope::TektronixOscilloscope(SCPITransport* transport)
true);

m_flexChannelParents[chan] = i;
m_flexChannelLanes[chan] = j;
m_channels.push_back(chan);
}
}
@@ -1412,6 +1413,10 @@ void TektronixOscilloscope::SetDeskewForChannel(size_t channel, int64_t skew)
m_channelDeskew.erase(it);
}

//Cannot deskew digital/trigger channels
if(channel >= m_analogChannelCount)
return;

lock_guard<recursive_mutex> lock(m_mutex);

switch(m_family)
@@ -1430,7 +1435,6 @@ void TektronixOscilloscope::SetDeskewForChannel(size_t channel, int64_t skew)
int64_t TektronixOscilloscope::GetDeskewForChannel(size_t channel)
{
//Cannot deskew digital/trigger channels
//TODO: are flex digital channels deskewable?
if(channel >= m_analogChannelCount)
return 0;

@@ -1661,3 +1665,106 @@ void TektronixOscilloscope::PushEdgeTrigger(EdgeTrigger* trig)
break;
}
}

vector<Oscilloscope::DigitalBank> TektronixOscilloscope::GetDigitalBanks()
{
vector<DigitalBank> ret;

switch(m_family)
{
case FAMILY_MSO5:
case FAMILY_MSO6:
for(auto it : m_flexChannelParents)
{
DigitalBank bank;
bank.push_back(it.first);
ret.push_back(bank);
}
break;

default:
break;
}

return ret;
}

Oscilloscope::DigitalBank TektronixOscilloscope::GetDigitalBank(size_t channel)
{
DigitalBank ret;

switch(m_family)
{
case FAMILY_MSO5:
case FAMILY_MSO6:
ret.push_back(m_channels[channel]);
break;

default:
break;
}

return ret;
}

bool TektronixOscilloscope::IsDigitalHysteresisConfigurable()
{
return false;
}

bool TektronixOscilloscope::IsDigitalThresholdConfigurable()
{
return true;
}

float TektronixOscilloscope::GetDigitalHysteresis(size_t /*channel*/)
{
return 0;
}

float TektronixOscilloscope::GetDigitalThreshold(size_t channel)
{
//TODO: caching?

lock_guard<recursive_mutex> lock(m_mutex);

auto chan = m_channels[channel];

switch(m_family)
{
case FAMILY_MSO5:
case FAMILY_MSO6:
//note, group IDs are one based but lane IDs are zero based!
m_transport->SendCommand(string("DIGGRP") + to_string(m_flexChannelParents[chan]+1) +
":D" + to_string(m_flexChannelLanes[chan]) + ":THR?");
return stof(m_transport->ReadReply());

default:
break;
}
return -1;
}

void TektronixOscilloscope::SetDigitalHysteresis(size_t /*channel*/, float /*level*/)
{
//not configurable
}

void TektronixOscilloscope::SetDigitalThreshold(size_t channel, float level)
{
lock_guard<recursive_mutex> lock(m_mutex);
auto chan = m_channels[channel];

switch(m_family)
{
case FAMILY_MSO5:
case FAMILY_MSO6:
//note, group IDs are one based but lane IDs are zero based!
m_transport->SendCommand(string("DIGGRP") + to_string(m_flexChannelParents[chan]+1) +
":D" + to_string(m_flexChannelLanes[chan]) + ":THR " + to_string(level));
break;

default:
break;
}
}
15 changes: 15 additions & 0 deletions scopehal/TektronixOscilloscope.h
Original file line number Diff line number Diff line change
@@ -108,6 +108,18 @@ class TektronixOscilloscope : public SCPIOscilloscope
virtual void SetDeskewForChannel(size_t channel, int64_t skew);
virtual int64_t GetDeskewForChannel(size_t channel);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Logic analyzer configuration

virtual std::vector<DigitalBank> GetDigitalBanks();
virtual DigitalBank GetDigitalBank(size_t channel);
virtual bool IsDigitalHysteresisConfigurable();
virtual bool IsDigitalThresholdConfigurable();
virtual float GetDigitalHysteresis(size_t channel);
virtual float GetDigitalThreshold(size_t channel);
virtual void SetDigitalHysteresis(size_t channel, float level);
virtual void SetDigitalThreshold(size_t channel, float level);

protected:
OscilloscopeChannel* m_extTrigChannel;

@@ -149,6 +161,9 @@ class TektronixOscilloscope : public SCPIOscilloscope
///The analog channel for each flex channel
std::map<OscilloscopeChannel*, size_t> m_flexChannelParents;

//The lane number for each flex channel
std::map<OscilloscopeChannel*, size_t> m_flexChannelLanes;

bool m_triggerArmed;
bool m_triggerOneShot;

8 changes: 4 additions & 4 deletions scopehal/Unit.cpp
Original file line number Diff line number Diff line change
@@ -198,13 +198,13 @@ string Unit::PrettyPrint(double value)
{
//If not a round number, add more digits (up to 4)
//TODO: allow user to specify how many sigfigs they want
if( fabs(round(value_rescaled) - value_rescaled) < 0.1 )
if( fabs(round(value_rescaled) - value_rescaled) < 0.001 )
snprintf(tmp, sizeof(tmp), "%.0f %s%s", value_rescaled, scale, unit);
else if(fabs(round(value_rescaled*10) - value_rescaled*10) < 0.1)
else if(fabs(round(value_rescaled*10) - value_rescaled*10) < 0.001)
snprintf(tmp, sizeof(tmp), "%.1f %s%s", value_rescaled, scale, unit);
else if(fabs(round(value_rescaled*100) - value_rescaled*100) < 0.1 )
else if(fabs(round(value_rescaled*100) - value_rescaled*100) < 0.001 )
snprintf(tmp, sizeof(tmp), "%.2f %s%s", value_rescaled, scale, unit);
else if(fabs(round(value_rescaled*1000) - value_rescaled*1000) < 0.1 )
else if(fabs(round(value_rescaled*1000) - value_rescaled*1000) < 0.001 )
snprintf(tmp, sizeof(tmp), "%.3f %s%s", value_rescaled, scale, unit);
else
snprintf(tmp, sizeof(tmp), "%.4f %s%s", value_rescaled, scale, unit);