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

Commits on Mar 11, 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
    669432c View commit details
Showing with 15 additions and 18 deletions.
  1. +11 −7 scopehal/LeCroyOscilloscope.cpp
  2. +1 −11 scopehal/LeCroyVICPOscilloscope.cpp
  3. +3 −0 scopehal/VICPSocketTransport.cpp
18 changes: 11 additions & 7 deletions scopehal/LeCroyOscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ void LeCroyOscilloscope::IdentifyHardware()
void LeCroyOscilloscope::DetectOptions()
{
SendCommand("*OPT?", true);
string reply = ReadSingleBlockString(true);
string reply = ReadSingleBlockString();
if(reply.length() > 3)
{
//Read options until we hit a null
@@ -139,6 +139,10 @@ void LeCroyOscilloscope::DetectOptions()
opt = "";
}

//skip newlines
else if(reply[i] == '\n')
continue;

else
opt += reply[i];
}
@@ -396,8 +400,8 @@ bool LeCroyOscilloscope::IsChannelEnabled(size_t i)
//See if the channel is enabled, hide it if not
string cmd = m_channels[i]->GetHwname() + ":TRACE?";
SendCommand(cmd);
string reply = ReadSingleBlockString(true);
if(reply == "OFF")
string reply = ReadSingleBlockString();
if(reply.find("OFF") == 0) //may have a trailing newline, ignore that
m_channelsEnabled[i] = false;
else
m_channelsEnabled[i] = true;
@@ -510,7 +514,7 @@ OscilloscopeChannel::CouplingType LeCroyOscilloscope::GetChannelCoupling(size_t
lock_guard<recursive_mutex> lock(m_mutex);

SendCommand(m_channels[i]->GetHwname() + ":COUPLING?");
string reply = ReadSingleBlockString(true);
string reply = ReadSingleBlockString().substr(0,3); //trim off trailing newline, all coupling codes are 3 chars

if(reply == "A1M")
return OscilloscopeChannel::COUPLE_AC_1M;
@@ -543,7 +547,7 @@ double LeCroyOscilloscope::GetChannelAttenuation(size_t i)
lock_guard<recursive_mutex> lock(m_mutex);

SendCommand(m_channels[i]->GetHwname() + ":ATTENUATION?");
string reply = ReadSingleBlockString(true);
string reply = ReadSingleBlockString();

double d;
sscanf(reply.c_str(), "%lf", &d);
@@ -564,14 +568,14 @@ int LeCroyOscilloscope::GetChannelBandwidthLimit(size_t i)

string cmd = "BANDWIDTH_LIMIT?";
SendCommand(cmd);
string reply = ReadSingleBlockString(true);
string reply = ReadSingleBlockString();

size_t index = reply.find(m_channels[i]->GetHwname());
if(index == string::npos)
return 0;

char chbw[16];
sscanf(reply.c_str() + index + 3, "%15[^,]", chbw); //offset 3 for "Cn,"
sscanf(reply.c_str() + index + 3, "%15[^,\n]", chbw); //offset 3 for "Cn,"
string sbw(chbw);

if(sbw == "OFF")
12 changes: 1 addition & 11 deletions scopehal/LeCroyVICPOscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -67,15 +67,5 @@ bool LeCroyVICPOscilloscope::SendCommand(string cmd, bool eoi)

string LeCroyVICPOscilloscope::ReadSingleBlockString(bool trimNewline)
{
string payload = m_transport->ReadReply();

if(trimNewline && (payload.length() > 0) )
{
int iend = payload.length() - 1;
if(trimNewline && (payload[iend] == '\n'))
payload.resize(iend);
}

payload += "\0";
return payload;
return m_transport->ReadReply();
}
3 changes: 3 additions & 0 deletions scopehal/VICPSocketTransport.cpp
Original file line number Diff line number Diff line change
@@ -154,6 +154,9 @@ string VICPSocketTransport::ReadReply()
break;
}

//make sure there's a null terminator
payload += "\0";

return payload;
}