Error handling with exceptions in slsDetector and multiSlsDetector (#14)

* less error mask

* removing error mask from slsDetector

* removed ErrorMask

* setonline, setreceiveornline bug fix
This commit is contained in:
Erik Fröjdh 2019-03-20 16:23:41 +01:00 committed by Dhanya Thattil
parent 9d489dc962
commit 03402d0e9e
9 changed files with 521 additions and 1407 deletions

View File

@ -16,16 +16,36 @@
using sls::RuntimeError;
using sls::SharedMemoryError;
using sls::SocketError;
using sls::DetectorError;
int main() {
// const std::string hostname = "beb083";
// auto type = slsDetector::getTypeFromDetector(hostname);
// slsDetector d(type);
// d.setHostname(hostname);
// d.setReceiverHostname("mpc2408");
const std::string hostname = "beb083";
auto type = slsDetector::getTypeFromDetector(hostname);
slsDetector d(type);
d.setHostname(hostname);
d.setOnline(true);
std::cout << "hostname: " << d.getHostname() << '\n';
d.setThresholdTemperature(50);
// try{
// d.setThresholdTemperature(50);
// }catch(const DetectorError &e){
// std::cout << "Caught: " << e.what() << '\n';
// }
// std::cout << "hostname: " << d.getHostname() << '\n';
// std::cout << "exptime: " << d.setDAC(-1, slsDetectorDefs::E_Vrf, 0) << '\n';
// slsDetector d2(type);
// std::cout << "Online: " << d2.getOnlineFlag() << '\n';
// d2.setHostname("beb55555");
// d2.setOnline(true);
// std::cout << "Online: " << d2.getOnlineFlag() << '\n';
// std::cout << "hostname: " << d2.getHostname() << '\n';
// std::cout << "port: " << d.getControlPort() << '\n';
// d.setOnline(true);
// d.setReceiverOnline(true);

View File

@ -16,6 +16,7 @@ auto type_enum = slsDetectorDefs::detectorType::EIGER;
const std::string hostname = "beb083";
const std::string type_string = "Eiger";
const std::string my_ip = "129.129.205.242";
TEST_CASE("single EIGER detector no receiver basic set and get") {
//TODO! this test should take command line arguments for config
@ -195,13 +196,4 @@ TEST_CASE("Excersise all possible set timer functions") {
CHECK(d.setTimer(slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME) == subtime);
}
// TEST_CASE("ACQ") {
// auto type = slsDetector::getTypeFromDetector(hostname);
// auto d = slsDetector(type);
// d.setHostname(hostname);
// d.setOnline(true);
// d.prepareAcquisition();
// d.startAcquisition();
// d.stopAcquisition();
// }
// TEST_CASE()

View File

@ -26,6 +26,8 @@
#include <future>
#include <vector>
using sls::NotImplementedError;
using sls::RuntimeError;
using sls::SharedMemory;
using sls::SharedMemoryError;
@ -177,7 +179,7 @@ int64_t multiSlsDetector::getId(idMode mode, int detPos) {
}
int64_t multiSlsDetector::getReceiverSoftwareVersion(int detPos) const {
if (detPos >= 0) {
if (detPos >= 0) {
return detectors[detPos]->getReceiverSoftwareVersion();
}
@ -397,14 +399,6 @@ void multiSlsDetector::addSlsDetector(const std::string &hostname) {
// get type by connecting
detectorType type = slsDetector::getTypeFromDetector(hostname.c_str(), DEFAULT_PORTNO);
if (type == GENERIC) {
FILE_LOG(logERROR) << "Could not connect to Detector " << hostname
<< " to determine the type!";
setErrorMask(getErrorMask() | MULTI_DETECTORS_NOT_ADDED);
appendNotAddedList(hostname.c_str());
return;
}
int pos = (int)detectors.size();
detectors.push_back(sls::make_unique<slsDetector>(type, multiId, pos, false));
multi_shm()->numberOfDetectors = detectors.size();
@ -759,19 +753,21 @@ int multiSlsDetector::readConfigurationFile(const std::string &fname) {
}
int multiSlsDetector::writeConfigurationFile(const std::string &fname) {
//TODO! make exception safe!
const std::vector<std::string> names = {"detsizechan", "hostname", "outdir",
"threaded"};
char *args[100];
for (auto &arg : args) {
arg = new char[1000];
}
int ret = OK, ret1 = OK;
std::ofstream outfile;
size_t iline = 0;
outfile.open(fname.c_str(), std::ios_base::out);
if (outfile.is_open()) {
char *args[100];
for (auto &arg : args) {
arg = new char[1000];
}
auto cmd = slsDetectorCommand(this);
// complete size of detector
@ -792,9 +788,6 @@ int multiSlsDetector::writeConfigurationFile(const std::string &fname) {
for (size_t idet = 0; idet < detectors.size(); ++idet) {
outfile << std::endl;
ret1 = detectors[idet]->writeConfigurationFile(outfile, this);
if (detectors[idet]->getErrorMask()) {
setErrorMask(getErrorMask() | (1 << idet));
}
if (ret1 == FAIL) {
ret = FAIL;
}
@ -811,30 +804,15 @@ int multiSlsDetector::writeConfigurationFile(const std::string &fname) {
}
outfile.close();
FILE_LOG(logDEBUG1) << "wrote " << iline << " lines to configuration file ";
for (auto &arg : args) {
delete[] arg;
}
} else {
FILE_LOG(logERROR) << "Could not open configuration file " << fname << " for writing";
setErrorMask(getErrorMask() | MULTI_CONFIG_FILE_ERROR);
ret = FAIL;
throw RuntimeError("Could not open configuration file " + fname + " for writing");
}
for (auto &arg : args) {
delete[] arg;
}
return ret;
}
std::string multiSlsDetector::getSettingsFile(int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->getSettingsFile();
}
// multi
auto r = serialCall(&slsDetector::getSettingsFile);
return sls::concatenateIfDifferent(r);
}
slsDetectorDefs::detectorSettings multiSlsDetector::getSettings(int detPos) {
// single
if (detPos >= 0) {
@ -858,7 +836,7 @@ multiSlsDetector::setSettings(detectorSettings isettings, int detPos) {
return (detectorSettings)sls::minusOneIfDifferent(r);
}
int multiSlsDetector::getThresholdEnergy(int detPos){
int multiSlsDetector::getThresholdEnergy(int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->getThresholdEnergy();
@ -1072,7 +1050,6 @@ int multiSlsDetector::configureMAC(int detPos) {
int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t, int detPos) {
// single
if (detPos >= 0) {
// error for setting values individually
// FIXME: what else? and error code
if (t != -1) {
@ -1081,16 +1058,11 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t, int detPos) {
case CYCLES_NUMBER:
case STORAGE_CELL_NUMBER:
case MEASUREMENTS_NUMBER:
FILE_LOG(logERROR)
<< "Cannot set number of frames, cycles, "
"storage cells or measurements individually.";
setErrorMask(getErrorMask() | MUST_BE_MULTI_CMD);
return multi_shm()->timerValue[index];
throw RuntimeError("Cannot set number of frames, cycles,storage cells or measurements individually.");
default:
break;
}
}
return detectors[detPos]->setTimer(index, t);
}
@ -1274,9 +1246,7 @@ int multiSlsDetector::setSpeed(speedVariable index, int value, int detPos) {
int multiSlsDetector::setDynamicRange(int dr, int detPos) {
// single
if (detPos >= 0) {
FILE_LOG(logERROR) << "Dynamic Range cannot be set individually";
setErrorMask(getErrorMask() | MUST_BE_MULTI_CMD);
return -1;
throw RuntimeError("Dynamic Range cannot be set individually");
}
// multi
@ -1421,12 +1391,11 @@ uint32_t multiSlsDetector::writeRegister(uint32_t addr, uint32_t val,
}
// can't have different values
FILE_LOG(logERROR) << "Error: Different Values for function writeRegister "
"(write 0x"
<< std::hex << val << " to addr 0x" << std::hex << addr
<< std::dec << ")";
setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES);
return -1;
std::ostringstream ss;
ss << "Error: Different Values for function writeRegister (write 0x"
<< std::hex << val << " to addr 0x" << std::hex << addr
<< std::dec << ")";
throw RuntimeError(ss.str());
}
uint32_t multiSlsDetector::readRegister(uint32_t addr, int detPos) {
@ -1442,11 +1411,10 @@ uint32_t multiSlsDetector::readRegister(uint32_t addr, int detPos) {
}
// can't have different values
FILE_LOG(logERROR) << "Error: Different Values for function readRegister "
"(read from 0x"
<< std::hex << addr << std::dec << ")";
setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES);
return -1;
std::ostringstream ss;
ss << "Error: Different Values for function readRegister (read from 0x"
<< std::hex << addr << std::dec << ")";
throw RuntimeError(ss.str());
}
uint32_t multiSlsDetector::setBit(uint32_t addr, int n, int detPos) {
@ -1462,12 +1430,12 @@ uint32_t multiSlsDetector::setBit(uint32_t addr, int n, int detPos) {
}
// can't have different values
FILE_LOG(logERROR) << "Error: Different Values for function setBit "
"(set bit "
<< n << " to addr 0x" << std::hex << addr << std::dec
<< ")";
setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES);
return -1;
std::ostringstream ss;
ss << "Error: Different Values for function setBit "
"(set bit "
<< n << " to addr 0x" << std::hex << addr << std::dec
<< ")";
throw RuntimeError(ss.str());
}
uint32_t multiSlsDetector::clearBit(uint32_t addr, int n, int detPos) {
@ -1483,12 +1451,10 @@ uint32_t multiSlsDetector::clearBit(uint32_t addr, int n, int detPos) {
}
// can't have different values
FILE_LOG(logERROR) << "Error: Different Values for function clearBit "
"(clear bit "
<< n << " to addr 0x" << std::hex << addr << std::dec
<< ")";
setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES);
return -1;
std::ostringstream ss;
ss << "Error: Different Values for function clearBit (clear bit "
<< n << " to addr 0x" << std::hex << addr << std::dec << ")";
throw RuntimeError(ss.str());
}
std::string multiSlsDetector::setDetectorMAC(const std::string &detectorMAC, int detPos) {
@ -1955,10 +1921,7 @@ int multiSlsDetector::loadImageToDetector(imageType index,
int nch = multi_shm()->numberOfChannels;
short int imageVals[nch];
if (readDataFile(fname, imageVals, nch) < nch * (int)sizeof(short int)) {
FILE_LOG(logERROR) << "Could not open file or not enough data in file "
"to load image to detector.";
setErrorMask(getErrorMask() | MULTI_OTHER_ERROR);
return -1;
throw RuntimeError("Could not open file or not enough data in file to load image to detector.");
}
// send image to all
@ -1994,11 +1957,8 @@ int multiSlsDetector::writeCounterBlockFile(const std::string &fname,
if (sls::allEqualTo(r, static_cast<int>(OK))) {
if (writeDataFile(fname, nch, imageVals) <
nch * (int)sizeof(short int)) {
FILE_LOG(logERROR) << "Could not open file to write or did not "
"write enough data in file "
"to wrte counter block file from detector.";
setErrorMask(getErrorMask() | MULTI_OTHER_ERROR);
return -1;
throw RuntimeError("Could not open file to write or did not write enough data"
" in file to write counter block file from detector.");
}
return OK;
}
@ -2400,9 +2360,7 @@ int multiSlsDetector::setAllTrimbits(int val, int detPos) {
int multiSlsDetector::enableGapPixels(int val, int detPos) {
if (getDetectorTypeAsEnum() != EIGER) {
if (val >= 0) {
FILE_LOG(logERROR) << "Function (enableGapPixels) not implemented "
"for this detector";
setErrorMask(getErrorMask() | MULTI_OTHER_ERROR);
throw NotImplementedError("Function (enableGapPixels) not implemented for this detector");
}
return 0;
}
@ -2410,10 +2368,7 @@ int multiSlsDetector::enableGapPixels(int val, int detPos) {
// single
if (detPos >= 0) {
if (val >= 0) {
FILE_LOG(logERROR) << "Function (enableGapPixels) must be called "
"from a multi detector level.";
setErrorMask(getErrorMask() | MUST_BE_MULTI_CMD);
return -1;
throw RuntimeError("Function (enableGapPixels) must be called from a multi detector level.");
}
return detectors[detPos]->enableGapPixels(val);
}
@ -2952,10 +2907,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) {
portnum += (iSocket % numSocketsPerDetector);
try {
zmqSocket.push_back(sls::make_unique<ZmqSocket>(
detectors[iSocket / numSocketsPerDetector]
->getClientStreamingIP()
.c_str(),
portnum));
detectors[iSocket / numSocketsPerDetector]->getClientStreamingIP().c_str(), portnum));
FILE_LOG(logINFO) << "Zmq Client[" << iSocket << "] at " << zmqSocket.back()->GetZmqServerAddress();
} catch (...) {
FILE_LOG(logERROR) << "Could not create Zmq socket on port " << portnum;
@ -3352,12 +3304,7 @@ int multiSlsDetector::enableDataStreamingToClient(int enable) {
// create data threads
} else {
if (createReceivingDataSockets() == FAIL) {
FILE_LOG(logERROR)
<< "Could not create data threads in client.";
detectors[0]->setErrorMask((detectors[0]->getErrorMask()) |
(DATA_STREAMING));
// only for the first det as theres no general one
setErrorMask(getErrorMask() | (1 << 0));
throw RuntimeError("Could not create data threads in client.");
}
}
}
@ -3414,25 +3361,19 @@ int multiSlsDetector::setPattern(const std::string &fname, int detPos) {
if (detPos >= 0) {
return detectors[detPos]->setPattern(fname);
}
// multi
int addr = 0;
FILE *fd = fopen(fname.c_str(), "r");
if (fd == nullptr) {
FILE_LOG(logERROR) << "Could not open file";
setErrorMask(getErrorMask() | MULTI_OTHER_ERROR);
return -1;
throw RuntimeError("multiSlsDetector::setPattern: Could not open file");
} else {
int addr{0};
uint64_t word{0};
while (fread(&word, sizeof(word), 1, fd)) {
serialCall(&slsDetector::setPatternWord, addr, word);
++addr;
}
fclose(fd);
return addr;
}
uint64_t word;
while (fread(&word, sizeof(word), 1, fd)) {
serialCall(&slsDetector::setPatternWord, addr, word);
++addr;
}
fclose(fd);
return addr;
}
uint64_t multiSlsDetector::setPatternWord(int addr, uint64_t word, int detPos) {
@ -3505,40 +3446,30 @@ uint64_t multiSlsDetector::getPatternMask(int detPos) {
if (sls::allEqual(r)) {
return r.front();
}
// should not have different values
throw RuntimeError("multiSlsDetector::getPatternMask: Error: Different Values returned)");
// can't have different values
FILE_LOG(logERROR) << "Error: Different Values returned)";
setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES);
return -1;
}
int multiSlsDetector::setPatternBitMask(uint64_t mask, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setPatternBitMask(mask);
}
// multi
auto r = parallelCall(&slsDetector::setPatternBitMask, mask);
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
}
uint64_t multiSlsDetector::getPatternBitMask(int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->getPatternBitMask();
}
// multi
auto r = parallelCall(&slsDetector::getPatternBitMask);
if (sls::allEqual(r)) {
return r.front();
}
// can't have different values
FILE_LOG(logERROR) << "Error: Different Values returned)";
setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES);
return -1;
// should not have different values
throw RuntimeError("multiSlsDetector::getPatternBitMask Different Values returned)");
}
int multiSlsDetector::setLEDEnable(int enable, int detPos) {
@ -3612,7 +3543,6 @@ int multiSlsDetector::retrieveDetectorSetup(const std::string &fname1,
// }
skip = 0;
}
if (level != 2) {
if (std::string(args[0]) == std::string("trimbits")) {
skip = 1;
@ -3627,24 +3557,15 @@ int multiSlsDetector::retrieveDetectorSetup(const std::string &fname1,
infile.close();
} else {
FILE_LOG(logERROR) << "Error opening " << fname << " for reading";
return FAIL;
throw RuntimeError("Error opening " + fname + " for reading");
}
FILE_LOG(logDEBUG1) << "Read " << iline << " lines";
if (getErrorMask()) {
return FAIL;
}
return OK;
}
int multiSlsDetector::dumpDetectorSetup(const std::string &fname, int level) {
detectorType type = getDetectorTypeAsEnum();
// std::string names[100];
std::vector<std::string> names;
// int nvar = 0;
// common config
names.emplace_back("fname");
names.emplace_back("index");
@ -4026,16 +3947,3 @@ int multiSlsDetector::kbhit() {
select(STDIN_FILENO + 1, &fds, nullptr, nullptr, &tv);
return FD_ISSET(STDIN_FILENO, &fds);
}
bool multiSlsDetector::isDetectorIndexOutOfBounds(int detPos) {
// position exceeds multi list size
if (detPos >= static_cast<int>(detectors.size())) {
FILE_LOG(logERROR) << "Position " << detPos
<< " is out of bounds with "
"a detector list of "
<< detectors.size();
setErrorMask(getErrorMask() | MULTI_POS_EXCEEDS_LIST);
return true;
}
return false;
}

View File

@ -108,11 +108,7 @@ struct sharedMultiSlsDetector {
bool receiver_upstream;
};
class multiSlsDetector : public virtual slsDetectorDefs,
public virtual errorDefs {
// private:
class multiSlsDetector : public virtual slsDetectorDefs {
public:
/**
* Constructor
@ -480,13 +476,6 @@ class multiSlsDetector : public virtual slsDetectorDefs,
*/
int writeConfigurationFile(const std::string &fname);
/**
* Returns the trimfile or settings file name (Useless??)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the trimfile or settings file name
*/
std::string getSettingsFile(int detPos = -1);
/**
* Get detector settings
* @param detPos -1 for all detectors in list or specific detector position
@ -1841,11 +1830,6 @@ class multiSlsDetector : public virtual slsDetectorDefs,
*/
int acquire();
/**
* Returns true if detector position is out of bounds
*/
bool isDetectorIndexOutOfBounds(int detPos);
/**
* Combines data from all readouts and gives it to the gui
* or just gives progress of acquisition by polling receivers

File diff suppressed because it is too large Load Diff

View File

@ -122,9 +122,6 @@ struct sharedSlsDetector {
/** readout flags */
slsDetectorDefs::readOutFlags roFlags;
/** name root of the output files */
char settingsFile[MAX_STR_LENGTH];
/** detector settings (standard, fast, etc.) */
slsDetectorDefs::detectorSettings currentSettings;
@ -245,7 +242,7 @@ struct sharedSlsDetector {
bool receiver_overWriteEnable;
};
class slsDetector : public virtual slsDetectorDefs, public virtual errorDefs {
class slsDetector : public virtual slsDetectorDefs{
public:
/**
* Constructor called when creating new shared memory
@ -328,11 +325,6 @@ class slsDetector : public virtual slsDetectorDefs, public virtual errorDefs {
*/
std::string getHostname() const;
/**
* Could not connect to receiver, log error
*/
void connectDataError();
/**
* Get detector type by connecting to the detector
* @returns detector tpe or GENERIC if failed
@ -343,13 +335,13 @@ class slsDetector : public virtual slsDetectorDefs, public virtual errorDefs {
* Get Detector type from shared memory variable
* @returns detector type from shared memory variable
*/
detectorType getDetectorTypeAsEnum();
detectorType getDetectorTypeAsEnum() const;
/**
* Gets string version of detector type from shared memory variable
* @returns string version of detector type from shared memory variable
*/
std::string getDetectorTypeAsString();
std::string getDetectorTypeAsString() const;
/**
* Gets detector type from detector and set it in receiver
@ -362,7 +354,7 @@ class slsDetector : public virtual slsDetectorDefs, public virtual errorDefs {
* Returns the total number of channels from shared memory
* @returns the total number of channels
*/
int getTotalNumberOfChannels();
int getTotalNumberOfChannels() const;
/**
* Update total number of channels (chiptestboard or moench)
@ -375,7 +367,7 @@ class slsDetector : public virtual slsDetectorDefs, public virtual errorDefs {
* @param d dimension d
* @returns the total number of channels in dimension d
*/
int getTotalNumberOfChannels(dimension d);
int getTotalNumberOfChannels(dimension d) const;
/**
* Returns the total number of channels of in dimension d including gap pixels
@ -384,40 +376,40 @@ class slsDetector : public virtual slsDetectorDefs, public virtual errorDefs {
* @returns the total number of channels including gap pixels in dimension d
* including gap pixels
*/
int getTotalNumberOfChannelsInclGapPixels(dimension d);
int getTotalNumberOfChannelsInclGapPixels(dimension d) const;
/**
* returns the number of channels per chip from shared memory (Mythen)
* @returns number of channels per chip
*/
int getNChans();
int getNChans() const;
/**
* returns the number of channels per chip in dimension d from shared memory (Mythen)
* @param d dimension d
* @returns number of channels per chip in dimension d
*/
int getNChans(dimension d);
int getNChans(dimension d) const;
/**
* returns the number of chips per module from shared memory (Mythen)
* @returns number of chips per module
*/
int getNChips();
int getNChips() const;
/**
* returns the number of chips per module in dimension d from shared memory (Mythen)
* @param d dimension d
* @returns number of chips per module in dimension d
*/
int getNChips(dimension d);
int getNChips(dimension d) const;
/**
* Get Detector offset from shared memory in dimension d
* @param d dimension d
* @returns offset in dimension d
*/
int getDetectorOffset(dimension d);
int getDetectorOffset(dimension d) const;
/**
* Set Detector offset in shared memory in dimension d
@ -536,12 +528,6 @@ class slsDetector : public virtual slsDetectorDefs, public virtual errorDefs {
*/
int writeConfigurationFile(std::ofstream &outfile, multiSlsDetector *m);
/**
* Returns the trimfile or settings file name (Useless??)
* @returns the trimfile or settings file name
*/
std::string getSettingsFile();
/**
* Get detector settings
* @returns current settings
@ -1106,7 +1092,7 @@ class slsDetector : public virtual slsDetectorDefs, public virtual errorDefs {
* @param d axis across which data is flipped
* @returns 1 for flipped, else 0
*/
int getFlippedData(dimension d = X);
int getFlippedData(dimension d = X) const;
/**
* Sets the enable which determines if

View File

@ -3418,7 +3418,7 @@ std::string slsDetectorCommand::cmdSettings(int narg, char *args[], int action,
else
return std::string("failed");
}
return myDet->getSettingsFile(detPos);
return std::string("Specify file name for geting settings file");
} else if (cmd == "trimval") {
if (action == PUT_ACTION) {
if (sscanf(args[1], "%d", &val))

View File

@ -7,6 +7,8 @@
*@short exceptions defined
*/
#include "logger.h"
#include <iostream>
#include <stdexcept>
@ -14,8 +16,15 @@ namespace sls{
struct RuntimeError : public std::runtime_error {
public:
RuntimeError(): runtime_error("SLS Detector Package Failed") {}
RuntimeError(std::string msg): runtime_error(msg) {}
RuntimeError(): runtime_error("SLS Detector Package Failed") {
FILE_LOG(logERROR) << "SLS Detector Package Failed";
}
RuntimeError(std::string msg): runtime_error(msg) {
FILE_LOG(logERROR) << msg;
}
RuntimeError(const char* msg): runtime_error(msg) {
FILE_LOG(logERROR) << msg;
}
};
struct SharedMemoryError : public RuntimeError {

View File

@ -19,7 +19,7 @@ ClientSocket::ClientSocket(const bool isRx, const std::string &host, uint16_t po
hints.ai_flags |= AI_CANONNAME;
if (getaddrinfo(host.c_str(), NULL, &hints, &result) != 0) {
std::string msg = "ClientSocket ERROR: decode host:" + host + " on port " + std::to_string(port) + "\n";
std::string msg = "ClientSocket cannot decode host:" + host + " on port " + std::to_string(port) + "\n";
throw SocketError(msg);
}
@ -32,7 +32,7 @@ ClientSocket::ClientSocket(const bool isRx, const std::string &host, uint16_t po
if (::connect(getSocketId(), (struct sockaddr *)&serverAddr, sizeof(serverAddr)) != 0) {
freeaddrinfo(result);
std::string msg = "ClientSocket ERROR: cannot connect to host:" + host + " on port " + std::to_string(port) + "\n";
std::string msg = "ClientSocket: cannot connect to host:" + host + " on port " + std::to_string(port) + "\n";
FILE_LOG(logERROR) << msg;
throw SocketError(msg);
}
@ -57,6 +57,7 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
receiveData(mess, sizeof(mess));
// cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
cprintf(RED, "%s returned error: %s", (isReceiver ? "Receiver" : "Detector"), mess);
std::cout << "\n"; //needed to reset the color.
// unrecognized function, do not ask for retval
if (strstr(mess, "Unrecognized Function") != nullptr)