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

Commits on Feb 13, 2020

  1. LeCroyOscilloscope: Added more verification to prevent crashing if a …

    …truncated wavedesc is received. Updated ReadWaveformBlock() to correctly handle stray newlines. Fixes #45.
    azonenberg committed Feb 13, 2020
    Copy the full SHA
    1cafdb7 View commit details
  2. Removed some dead code

    azonenberg committed Feb 13, 2020
    Copy the full SHA
    d6df853 View commit details
Showing with 24 additions and 8 deletions.
  1. +24 −8 scopehal/LeCroyOscilloscope.cpp
32 changes: 24 additions & 8 deletions scopehal/LeCroyOscilloscope.cpp
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 *
@@ -819,13 +819,16 @@ Oscilloscope::TriggerMode LeCroyOscilloscope::PollTrigger()

bool LeCroyOscilloscope::ReadWaveformBlock(string& data)
{
//First packet is just a header "DAT1,\n". Throw it away.
ReadData();
//First packet is just a header "DAT1,\n" or "DESC,\n". Throw it away.
//In some rare circumstances, such as when the user touches front panel controls,
//it appears we can get a blank line before this. Ignore that.
string header = ReadData();
while(header == "\n")
header = ReadData();

//Second blocks is a header including the message length. Parse that.
//Second block is a header including the message length. Parse that.
string lhdr = ReadSingleBlockString();
unsigned int num_bytes = atoi(lhdr.c_str() + 2);
//LogDebug("lhdr: %s\n", lhdr.c_str());
if(num_bytes == 0)
{
ReadData();
@@ -840,8 +843,6 @@ bool LeCroyOscilloscope::ReadWaveformBlock(string& data)
data += payload;
if(data.size() >= num_bytes)
break;
//float local_progress = data.size() * 1.0f / num_bytes;
//progress_callback(base_progress + local_progress / m_analogChannelCount);
}

//Throw away the newline at the end
@@ -911,7 +912,22 @@ bool LeCroyOscilloscope::AcquireData(bool toQueue)
for(unsigned int i=0; i<m_analogChannelCount; i++)
{
if(enabled[i])
ReadWaveformBlock(wavedescs[i]);
{
if(!ReadWaveformBlock(wavedescs[i]))
LogError("ReadWaveformBlock for wavedesc %u failed\n", i);
}
}

//Check length, complain if a wavedesc comes back too short
size_t expected_wavedesc_size = 346;
for(auto& w : wavedescs)
{
if(w.size() < expected_wavedesc_size)
{
LogError("Got wavedesc of %zu bytes (expected %zu)\n", w.size(), expected_wavedesc_size);
m_mutex.unlock();
return false;
}
}

//Figure out how many sequences we have