mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
readnlines->partialread, better debugging for TCP socket interface bug
This commit is contained in:
@ -25,6 +25,8 @@ class DataSocket {
|
||||
DataSocket(const DataSocket &) = delete;
|
||||
DataSocket &operator=(DataSocket const &) = delete;
|
||||
int getSocketId() const { return sockfd_; }
|
||||
int getFnum() const { return fnum_; }
|
||||
int setFnum(const int fnum);
|
||||
|
||||
int Send(const void *buffer, size_t size);
|
||||
|
||||
@ -82,6 +84,7 @@ class DataSocket {
|
||||
|
||||
private:
|
||||
int sockfd_ = -1;
|
||||
int fnum_ {0};
|
||||
};
|
||||
|
||||
}; // namespace sls
|
||||
|
@ -518,7 +518,7 @@ typedef struct {
|
||||
int dataStreamLeft{0};
|
||||
int dataStreamRight{0};
|
||||
int quad{0};
|
||||
int numLinesReadout{0};
|
||||
int partialReadout{0};
|
||||
int thresholdEnergyeV[3]{0, 0, 0};
|
||||
int dynamicRange{16};
|
||||
timingMode timMode{AUTO_TIMING};
|
||||
|
@ -124,8 +124,8 @@ enum detFuncs {
|
||||
F_GET_QUAD,
|
||||
F_SET_INTERRUPT_SUBFRAME,
|
||||
F_GET_INTERRUPT_SUBFRAME,
|
||||
F_SET_READ_N_LINES,
|
||||
F_GET_READ_N_LINES,
|
||||
F_SET_PARTIAL_READOUT,
|
||||
F_GET_PARTIAL_READOUT,
|
||||
F_SET_POSITION,
|
||||
F_SET_SOURCE_UDP_MAC,
|
||||
F_GET_SOURCE_UDP_MAC,
|
||||
@ -326,7 +326,7 @@ enum detFuncs {
|
||||
F_SET_RECEIVER_DBIT_OFFSET,
|
||||
F_GET_RECEIVER_DBIT_OFFSET,
|
||||
F_SET_RECEIVER_QUAD,
|
||||
F_SET_RECEIVER_READ_N_LINES,
|
||||
F_SET_RECEIVER_PARTIAL_READOUT,
|
||||
F_SET_RECEIVER_UDP_IP,
|
||||
F_SET_RECEIVER_UDP_IP2,
|
||||
F_SET_RECEIVER_UDP_PORT,
|
||||
@ -477,8 +477,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_GET_QUAD: return "F_GET_QUAD";
|
||||
case F_SET_INTERRUPT_SUBFRAME: return "F_SET_INTERRUPT_SUBFRAME";
|
||||
case F_GET_INTERRUPT_SUBFRAME: return "F_GET_INTERRUPT_SUBFRAME";
|
||||
case F_SET_READ_N_LINES: return "F_SET_READ_N_LINES";
|
||||
case F_GET_READ_N_LINES: return "F_GET_READ_N_LINES";
|
||||
case F_SET_PARTIAL_READOUT: return "F_SET_PARTIAL_READOUT";
|
||||
case F_GET_PARTIAL_READOUT: return "F_GET_PARTIAL_READOUT";
|
||||
case F_SET_POSITION: return "F_SET_POSITION";
|
||||
case F_SET_SOURCE_UDP_MAC: return "F_SET_SOURCE_UDP_MAC";
|
||||
case F_GET_SOURCE_UDP_MAC: return "F_GET_SOURCE_UDP_MAC";
|
||||
@ -677,7 +677,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_SET_RECEIVER_DBIT_OFFSET: return "F_SET_RECEIVER_DBIT_OFFSET";
|
||||
case F_GET_RECEIVER_DBIT_OFFSET: return "F_GET_RECEIVER_DBIT_OFFSET";
|
||||
case F_SET_RECEIVER_QUAD: return "F_SET_RECEIVER_QUAD";
|
||||
case F_SET_RECEIVER_READ_N_LINES: return "F_SET_RECEIVER_READ_N_LINES";
|
||||
case F_SET_RECEIVER_PARTIAL_READOUT: return "F_SET_RECEIVER_PARTIAL_READOUT";
|
||||
case F_SET_RECEIVER_UDP_IP: return "F_SET_RECEIVER_UDP_IP";
|
||||
case F_SET_RECEIVER_UDP_IP2: return "F_SET_RECEIVER_UDP_IP2";
|
||||
case F_SET_RECEIVER_UDP_PORT: return "F_SET_RECEIVER_UDP_PORT";
|
||||
|
@ -4,10 +4,10 @@
|
||||
#define APIRECEIVER 0x210225
|
||||
#define APIGUI 0x210225
|
||||
|
||||
#define APICTB 0x210812
|
||||
#define APIGOTTHARD 0x210812
|
||||
#define APIGOTTHARD2 0x210812
|
||||
#define APIJUNGFRAU 0x210812
|
||||
#define APIMYTHEN3 0x210812
|
||||
#define APIMOENCH 0x210812
|
||||
#define APIEIGER 0x210812
|
||||
#define APICTB 0x210813
|
||||
#define APIGOTTHARD 0x210813
|
||||
#define APIGOTTHARD2 0x210813
|
||||
#define APIJUNGFRAU 0x210813
|
||||
#define APIMYTHEN3 0x210813
|
||||
#define APIMOENCH 0x210813
|
||||
#define APIEIGER 0x210813
|
||||
|
@ -63,6 +63,7 @@ int ClientSocket::sendCommandThenRead(int fnum, const void *args,
|
||||
size_t retval_size) {
|
||||
int ret = slsDetectorDefs::FAIL;
|
||||
Send(&fnum, sizeof(fnum));
|
||||
setFnum(fnum);
|
||||
Send(args, args_size);
|
||||
readReply(ret, retval, retval_size);
|
||||
return ret;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "sls/DataSocket.h"
|
||||
#include "sls/logger.h"
|
||||
#include "sls/sls_detector_funcs.h"
|
||||
#include "sls/sls_detector_exceptions.h"
|
||||
#include <algorithm>
|
||||
#include <arpa/inet.h>
|
||||
@ -41,6 +42,10 @@ DataSocket &DataSocket::operator=(DataSocket &&move) noexcept {
|
||||
return *this;
|
||||
}
|
||||
|
||||
int DataSocket::setFnum(const int fnum) {
|
||||
fnum_ = fnum;
|
||||
}
|
||||
|
||||
int DataSocket::Receive(void *buffer, size_t size) {
|
||||
// TODO!(Erik) Add sleep? how many reties?
|
||||
int bytes_expected = static_cast<int>(size); // signed size
|
||||
@ -58,7 +63,7 @@ int DataSocket::Receive(void *buffer, size_t size) {
|
||||
} else {
|
||||
std::ostringstream ss;
|
||||
ss << "TCP socket read " << bytes_read << " bytes instead of "
|
||||
<< bytes_expected << " bytes";
|
||||
<< bytes_expected << " bytes (" << getFunctionNameFromEnum(static_cast<detFuncs>(fnum_)) << ')';
|
||||
throw sls::SocketError(ss.str());
|
||||
}
|
||||
}
|
||||
@ -83,7 +88,7 @@ int DataSocket::Send(const void *buffer, size_t size) {
|
||||
if (bytes_sent != data_size) {
|
||||
std::ostringstream ss;
|
||||
ss << "TCP socket sent " << bytes_sent << " bytes instead of "
|
||||
<< data_size << " bytes";
|
||||
<< data_size << " bytes (" << getFunctionNameFromEnum(static_cast<detFuncs>(fnum_)) << ')';
|
||||
throw sls::SocketError(ss.str());
|
||||
}
|
||||
return bytes_sent;
|
||||
|
@ -55,7 +55,7 @@ std::string ToString(const slsDetectorDefs::rxParameters &r) {
|
||||
<< "leftDataStream:" << r.dataStreamLeft << std::endl
|
||||
<< "rightDataStream:" << r.dataStreamRight << std::endl
|
||||
<< "quad:" << r.quad << std::endl
|
||||
<< "numLinesReadout:" << r.numLinesReadout << std::endl
|
||||
<< "partialReadout:" << r.partialReadout << std::endl
|
||||
<< "thresholdEnergyeV:" << ToString(r.thresholdEnergyeV) << std::endl
|
||||
<< "dynamicRange:" << r.dynamicRange << std::endl
|
||||
<< "timMode:" << r.timMode << std::endl
|
||||
|
Reference in New Issue
Block a user