Skip to content
Snippets Groups Projects
Commit ccbc8173 authored by Elisabetta Pianori's avatar Elisabetta Pianori
Browse files

Merge branch 'kk_scpimpsafe' into 'devel'

Make SCIPPs multi-process safe.

See merge request berkeleylab/labRemote!195
parents 0b470e80 d4d7d949
No related branches found
No related tags found
No related merge requests found
......@@ -109,11 +109,13 @@ double SCPIPs::measureVoltage(unsigned channel)
void SCPIPs::send(const std::string& cmd)
{
m_com->lock();
m_com->send(cmd);
std::string opcreply=m_com->sendreceive("*OPC?");
utils::rtrim(opcreply);
if(opcreply!="1")
throw std::runtime_error("SCPI command not completed");
m_com->unlock();
}
void SCPIPs::send(const std::string& cmd, unsigned channel)
......@@ -124,10 +126,12 @@ void SCPIPs::send(const std::string& cmd, unsigned channel)
throw std::runtime_error("Invalid channel: "+std::to_string(channel));
}
m_com->lock();
if(m_maxChannels!=1)
m_com->send("INST:NSEL "+std::to_string(channel));
send(cmd);
m_com->unlock();
}
std::string SCPIPs::sendreceive(const std::string& cmd)
......@@ -143,8 +147,11 @@ std::string SCPIPs::sendreceive(const std::string& cmd, unsigned channel)
throw std::runtime_error("Invalid channel: "+std::to_string(channel));
}
m_com->lock();
if(m_maxChannels!=1)
m_com->send("INST:NSEL "+std::to_string(channel));
return sendreceive(cmd);
std::string ret=sendreceive(cmd);
m_com->unlock();
return ret;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment