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

Commits on Mar 6, 2020

  1. LeCroyOscilloscope: DetectAnalogChannels now gives correct results fo…

    …r scopes with -MS model suffix
    azonenberg committed Mar 6, 2020
    Copy the full SHA
    ccd3db1 View commit details
  2. Copy the full SHA
    5f98ea3 View commit details
  3. LeCroyOscilloscope: Cleaned up a bunch of variable shadowing, signedn…

    …ess errors, and other warnings
    azonenberg committed Mar 6, 2020
    Copy the full SHA
    ca74b58 View commit details
  4. Began work on un-bitrotting LeCroy logic analyzer support. Now detect…

    …s LA channels and doesn't crash, but can't actually acquire waveforms. See #17.
    azonenberg committed Mar 6, 2020
    Copy the full SHA
    00b3bbd View commit details
Showing with 98 additions and 42 deletions.
  1. +97 −42 scopehal/LeCroyOscilloscope.cpp
  2. +1 −0 scopehal/LeCroyOscilloscope.h
139 changes: 97 additions & 42 deletions scopehal/LeCroyOscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -151,31 +151,11 @@ void LeCroyOscilloscope::DetectOptions()
LogDebug("* None\n");
for(auto o : options)
{
//If we have the LA module installed, add the digital channels
if(o == "MSXX")
//If we have an LA module installed, add the digital channels
if( (o == "MSXX") && !m_hasLA)
{
m_hasLA = true;
LogDebug("* MSXX (logic analyzer)\n");
LogIndenter li;

//TODO: send command to enable all digital channels if we use any?

m_digitalChannelCount = 16;

char chn[8];
for(int i=0; i<16; i++)
{
snprintf(chn, sizeof(chn), "D%d", i);
auto chan = new OscilloscopeChannel(
this,
chn,
OscilloscopeChannel::CHANNEL_TYPE_DIGITAL,
GetDefaultChannelColor(m_channels.size()),
1,
m_channels.size());
m_channels.push_back(chan);
m_digitalChannels.push_back(chan);
}
AddDigitalChannels(16);
}

//If we have the voltmeter installed, make a note of that
@@ -200,23 +180,88 @@ void LeCroyOscilloscope::DetectOptions()
LogDebug("* %s (protocol decode, ignoring)\n", o.c_str());
}

//Ignore UI options
else if(o == "XWEB")
{
LogDebug("* %s (UI option, ignoring)\n", o.c_str());
}

//No idea what it is
else
LogDebug("* %s (not yet implemented)\n", o.c_str());
}
}

//If we don't have a code for the LA software option, but are a -MS scope, add the LA
if(!m_hasLA && (m_model.find("-MS") != string::npos))
AddDigitalChannels(16);
}

/**
@brief Creates digital channels for the oscilloscope
*/
void LeCroyOscilloscope::AddDigitalChannels(unsigned int count)
{
m_hasLA = true;
LogIndenter li;

//TODO: send command to enable all digital channels if we use any?

m_digitalChannelCount = count;

char chn[8];
for(unsigned int i=0; i<count; i++)
{
snprintf(chn, sizeof(chn), "D%d", i);
auto chan = new OscilloscopeChannel(
this,
chn,
OscilloscopeChannel::CHANNEL_TYPE_DIGITAL,
GetDefaultChannelColor(m_channels.size()),
1,
m_channels.size());
m_channels.push_back(chan);
m_digitalChannels.push_back(chan);
}
}

/**
@brief Figures out how many analog channels we have, and add them to the device
If you're lucky, the last digit of the model number will be the number of channels (HDO9204)
But, since we can't have nice things, theres are plenty of exceptions. Known formats so far:
* WAVERUNNER8104-MS has 4 channels (plus 16 digital)
* DDA5005 / DDA5005A have 4 channels
*/
void LeCroyOscilloscope::DetectAnalogChannels()
{
//Last digit of the model number is normally the number of channels
int nchans = m_model[m_model.length() - 1] - '0';
//General model format is family, number, suffix. Not all are always present.
//Trim off alphabetic characters from the start of the model number
size_t pos;
for(pos=0; pos < m_model.length(); pos++)
{
if(isalpha(m_model[pos]))
continue;
else if(isdigit(m_model[pos]))
break;
else
{
LogError("Unrecognized character (not alphanumeric) in model number %s\n", m_model.c_str());
return;
}
}

//Now we should be able to read the model number
int modelNum = atoi(m_model.c_str() + pos);

//Last digit of the model number is normally the number of channels (WAVESURFER3022, HDO8108)
int nchans = modelNum % 10;

//DDA5005 and similar have 4 channels despite a model number ending in 5
if(m_modelid == MODEL_DDA_5K)
nchans = 4;


for(int i=0; i<nchans; i++)
{
//Hardware name of the channel
@@ -1009,7 +1054,7 @@ bool LeCroyOscilloscope::AcquireData(bool toQueue)
}

//Parse the wavedesc headers
unsigned char* pdesc = (unsigned char*)(&wavedescs[i][0]);
pdesc = (unsigned char*)(&wavedescs[i][0]);
//uint32_t wavedesc_len = *reinterpret_cast<uint32_t*>(pdesc + 36);
//uint32_t usertext_len = *reinterpret_cast<uint32_t*>(pdesc + 40);
float v_gain = *reinterpret_cast<float*>(pdesc + 156);
@@ -1102,12 +1147,12 @@ bool LeCroyOscilloscope::AcquireData(bool toQueue)

//Decode the samples
cap->m_samples.resize(num_per_segment);
for(unsigned int i=0; i<num_per_segment; i++)
for(unsigned int k=0; k<num_per_segment; k++)
{
if(m_highDefinition)
cap->m_samples[i] = AnalogSample(i, 1, wdata[i + j*num_per_segment] * v_gain - v_off);
cap->m_samples[k] = AnalogSample(k, 1, wdata[i + j*num_per_segment] * v_gain - v_off);
else
cap->m_samples[i] = AnalogSample(i, 1, bdata[i + j*num_per_segment] * v_gain - v_off);
cap->m_samples[k] = AnalogSample(k, 1, bdata[i + j*num_per_segment] * v_gain - v_off);
}

//Done, update the data
@@ -1158,21 +1203,20 @@ bool LeCroyOscilloscope::AcquireData(bool toQueue)
m_mutex.lock();

//If no digital channels are enabled, skip this step
bool enabled = false;
bool denabled = false;
for(size_t i=0; i<m_digitalChannels.size(); i++)
{
if(m_digitalChannels[i]->IsEnabled())
{
enabled = true;
denabled = true;
break;
}
}

if(enabled)
if(denabled)
{
//Ask for the waveform. This is a weird XML-y format but I can't find any other way to get it :(
string cmd = "Digital1:WF?";
SendCommand(cmd);
SendCommand("Digital1:WF?");
string data;
if(!ReadWaveformBlock(data))
return false;
@@ -1295,10 +1339,21 @@ size_t LeCroyOscilloscope::GetTriggerChannelIndex()
char source[32] = "";
sscanf(reply.c_str(), "%31[^,],%31[^,],%31[^,],\n", ignored1, ignored2, source);

//TODO: support digital channels

//Update cache
if(isdigit(source[1]))
if(source[0] == 'D') //Digital channel numbers are 0 based
{
int digitalChannelNum = atoi(source+1);
if((unsigned)digitalChannelNum >= m_digitalChannelCount)
{
m_triggerChannel = 0;
LogWarning("Trigger is configured for digital channel %s, but we only have %u digital channels\n",
source, m_digitalChannelCount);
}

else
m_triggerChannel = m_digitalChannels[digitalChannelNum]->GetIndex();
}
else if(isdigit(source[1])) //but analog are 1 based, yay!
m_triggerChannel = source[1] - '1';
else if(strstr(source, "EX") == source) //EX or EX10 for /1 or /10
m_triggerChannel = m_extTrigChannel->GetIndex();
@@ -1414,8 +1469,8 @@ void LeCroyOscilloscope::SetTriggerForChannel(

double LeCroyOscilloscope::GetChannelOffset(size_t i)
{
//not meaningful for trigger channels
if(i == m_extTrigChannel->GetIndex())
//not meaningful for trigger or digital channels
if(i > m_analogChannelCount)
return 0;

{
@@ -1446,8 +1501,8 @@ void LeCroyOscilloscope::SetChannelOffset(size_t /*i*/, double /*offset*/)

double LeCroyOscilloscope::GetChannelVoltageRange(size_t i)
{
//not meaningful for trigger channels
if(i == m_extTrigChannel->GetIndex())
//not meaningful for trigger or digital channels
if(i > m_analogChannelCount)
return 1;

{
1 change: 1 addition & 0 deletions scopehal/LeCroyOscilloscope.h
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ class LeCroyOscilloscope
void IdentifyHardware();
void SharedCtorInit();
virtual void DetectAnalogChannels();
void AddDigitalChannels(unsigned int count);
void DetectOptions();

public: