Skip to content
Snippets Groups Projects
Commit f632b8ab authored by Taurean Zhang's avatar Taurean Zhang
Browse files

6/23/23 Added critical flag functionality with working test compilation (only RMP4040 PS tested)

parent 636c2e9e
No related branches found
No related tags found
2 merge requests!311Draft: Delete: compilation of changes that are in other merge requests,!303[WIP] Interlock update
Pipeline #5786939 failed
......@@ -33,7 +33,7 @@ void CharDeviceCom::init() {
m_good = true;
}
void CharDeviceCom::send(const std::string &buf, bool critical = false) {
void CharDeviceCom::send(const std::string &buf, bool critical) {
ScopeLock lock(this);
int n_write = ::write(m_dev, buf.c_str(), buf.size());
......@@ -42,7 +42,7 @@ void CharDeviceCom::send(const std::string &buf, bool critical = false) {
std::strerror(errno));
}
void CharDeviceCom::send(char *buf, size_t length, bool critical = false) {
void CharDeviceCom::send(char *buf, size_t length, bool critical) {
ScopeLock lock(this);
int n_write = ::write(m_dev, buf, length);
......@@ -73,20 +73,20 @@ uint32_t CharDeviceCom::receive(char *buf, size_t length) {
return n_read;
}
std::string CharDeviceCom::sendreceive(const std::string &cmd, bool critical = false) {
std::string CharDeviceCom::sendreceive(const std::string &cmd, bool critical) {
ScopeLock lock(this);
send(cmd);
send(cmd, critical);
std::string ret = receive();
return ret;
}
void CharDeviceCom::sendreceive(char *wbuf, size_t wlength, char *rbuf,
size_t rlength, bool critical = false) {
size_t rlength, bool critical) {
ScopeLock lock(this);
send(wbuf, wlength);
send(wbuf, wlength, critical);
receive(rbuf, rlength);
}
......
......@@ -59,7 +59,7 @@ class GPIBNICom : public ICom {
* \param buf Data to be sent
* \param length Number of characters in `buf` that should be sent
*/
void send(char *buf, size_t length, bool critical = false);
void send(char *buf, size_t length, bool critical);
/** Send data to device
*
......@@ -67,7 +67,7 @@ class GPIBNICom : public ICom {
*
* \param buf Data to be sent
*/
void send(const std::string &buf, bool critical = false);
void send(const std::string &buf, bool critical);
/** Read data from device
*
......@@ -96,7 +96,7 @@ class GPIBNICom : public ICom {
*
* \return Returned data
*/
std::string sendreceive(const std::string &cmd, bool critical = false);
std::string sendreceive(const std::string &cmd, bool critical);
/** Send data to device and receive reply
*
......@@ -109,7 +109,7 @@ class GPIBNICom : public ICom {
*
* \return Number of characters received
*/
void sendreceive(char *wbuf, size_t wlength, char *rbuf, size_t rlength, bool critical = false);
void sendreceive(char *wbuf, size_t wlength, char *rbuf, size_t rlength, bool critical);
protected:
/** Request exlusive access to device.
......
......@@ -44,15 +44,15 @@ void GPIBSerialCom::setConfiguration(const nlohmann::json& config) {
TextSerialCom::setConfiguration(config);
}
void GPIBSerialCom::send(const std::string& buf, bool critical = false) {
void GPIBSerialCom::send(const std::string& buf, bool critical) {
ScopeLock lock(this);
TextSerialCom::send("++addr " + std::to_string(m_gpib_addr));
TextSerialCom::send(buf);
TextSerialCom::send("++addr " + std::to_string(m_gpib_addr), critical);
TextSerialCom::send(buf, critical);
}
void GPIBSerialCom::send(char* buf, size_t length, bool critical = false) {
send(std::string(buf, length));
void GPIBSerialCom::send(char* buf, size_t length, bool critical) {
send(std::string(buf, length), critical);
}
std::string GPIBSerialCom::receive() {
......
......@@ -159,7 +159,7 @@ void LXICom::send(const std::string &buf, bool critical = false) {
tcp_send(buf.c_str());
}
void LXICom::send(char *buf, size_t length, bool critical = false) { send(std::string(buf, length)); }
void LXICom::send(char *buf, size_t length, bool critical = false) { send(std::string(buf, length), critical); }
std::string LXICom::receive() {
tcp_recv(m_receive_buf);
......@@ -181,7 +181,7 @@ uint32_t LXICom::receive(char *buf, size_t length) {
}
std::string LXICom::sendreceive(const std::string &cmd, bool critical = false) {
send(cmd);
send(cmd, critical);
std::string ret = receive();
return ret;
......@@ -189,7 +189,7 @@ std::string LXICom::sendreceive(const std::string &cmd, bool critical = false) {
void LXICom::sendreceive(char *wbuf, size_t wlength, char *rbuf,
size_t rlength, bool critical = false) {
send(wbuf, wlength);
send(wbuf, wlength, critical);
receive(rbuf, rlength);
}
......
......@@ -56,7 +56,7 @@ class LXICom : public ICom {
* \param buf Data to be sent
* \param length Number of characters in `buf` that should be sent
*/
virtual void send(char* buf, size_t length, bool critical = false);
virtual void send(char* buf, size_t length, bool critical);
/** Send data to device
*
......@@ -64,7 +64,7 @@ class LXICom : public ICom {
*
* \param buf Data to be sent
*/
virtual void send(const std::string& buf, bool critical = false);
virtual void send(const std::string& buf, bool critical);
/** Read data from device
*
......@@ -93,7 +93,7 @@ class LXICom : public ICom {
*
* \return Returned data
*/
virtual std::string sendreceive(const std::string& cmd, bool critical = false);
virtual std::string sendreceive(const std::string& cmd, bool critical);
/** Write data to device and receive reply
*
......@@ -107,7 +107,7 @@ class LXICom : public ICom {
* \return Number of characters received
*/
virtual void sendreceive(char* wbuf, size_t wlength, char* rbuf,
size_t rlength, bool critical = false);
size_t rlength, bool critical);
/** Locking is not supported!
*
......
......@@ -188,7 +188,7 @@ void SerialCom::setDTR(bool on) {
": " + std::strerror(errno));
}
void SerialCom::send(const std::string &buf, bool critical = false) {
void SerialCom::send(const std::string &buf, bool critical) {
ScopeLock lock(this);
int n_write = ::write(m_dev, buf.c_str(), buf.size());
......@@ -197,7 +197,7 @@ void SerialCom::send(const std::string &buf, bool critical = false) {
std::strerror(errno));
}
void SerialCom::send(char *buf, size_t length, bool critical = false) {
void SerialCom::send(char *buf, size_t length, bool critical) {
ScopeLock lock(this);
int n_write = ::write(m_dev, buf, length);
......@@ -228,20 +228,20 @@ uint32_t SerialCom::receive(char *buf, size_t length) {
return n_read;
}
std::string SerialCom::sendreceive(const std::string &cmd, bool critical = false) {
std::string SerialCom::sendreceive(const std::string &cmd, bool critical) {
ScopeLock lock(this);
send(cmd);
send(cmd, critical);
std::string ret = receive();
return ret;
}
void SerialCom::sendreceive(char *wbuf, size_t wlength, char *rbuf,
size_t rlength, bool critical = false) {
size_t rlength, bool critical) {
ScopeLock lock(this);
send(wbuf, wlength);
send(wbuf, wlength, critical);
receive(rbuf, rlength);
}
......
......@@ -57,13 +57,13 @@ void TextSerialCom::setConfiguration(const nlohmann::json& config) {
}
}
void TextSerialCom::send(const std::string& buf, bool critical = false) {
void TextSerialCom::send(const std::string& buf, bool critical) {
logger(logDEBUG2) << __PRETTY_FUNCTION__ << " -> Sending: " << buf;
SerialCom::send(buf + m_termination);
SerialCom::send(buf + m_termination, critical);
}
void TextSerialCom::send(char* buf, size_t length, bool critical = false) {
send(std::string(buf, length));
void TextSerialCom::send(char* buf, size_t length, bool critical) {
send(std::string(buf, length, critical));
}
std::string TextSerialCom::receive() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment