client: must print detector or receiver returning error

This commit is contained in:
2019-02-25 09:16:20 +01:00
parent eecfcae312
commit 15fc55f914
3 changed files with 124 additions and 123 deletions

View File

@ -9,12 +9,13 @@ namespace sls {
class ClientSocket : public DataSocket {
public:
ClientSocket(const std::string &hostname, uint16_t port_number);
ClientSocket(const bool isRx, const std::string &hostname, uint16_t port_number);
int sendCommandThenRead(int fnum, void *args, size_t args_size, void *retval, size_t retval_size);
private:
void readReply(int &ret, void *retval, size_t retval_size);
struct sockaddr_in serverAddr {};
bool isReceiver;
};
}; //namespace sls
}; //namespace sls

View File

@ -8,7 +8,7 @@
#include "sls_detector_defs.h"
namespace sls {
ClientSocket::ClientSocket(const std::string &host, uint16_t port) : DataSocket(socket(AF_INET, SOCK_STREAM, 0)) {
ClientSocket::ClientSocket(const bool isRx, const std::string &host, uint16_t port) : DataSocket(socket(AF_INET, SOCK_STREAM, 0)), isReceiver(isRx) {
struct addrinfo hints, *result;
memset(&hints, 0, sizeof(hints));
@ -51,7 +51,7 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
//get error message
receiveData(mess, sizeof(mess));
// cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
cprintf(RED, "returned error: %s", mess);
cprintf(RED, "%s returned error: %s", (isReceiver ? "Receiver" : "Detector"), mess);
// unrecognized function, do not ask for retval
if (strstr(mess, "Unrecognized Function") != nullptr)