merge conflict and binaries in

This commit is contained in:
2021-09-09 11:22:09 +02:00
35 changed files with 237 additions and 289 deletions

View File

@ -41,7 +41,7 @@ def list_to_bitmask(values):
return mask return mask
def make_bitmask(args): def make_bitmask(args):
if isinstance(args, list): if isinstance(args, (list,tuple)):
return list_to_bitmask(args) return list_to_bitmask(args)
elif isinstance(args, dict): elif isinstance(args, dict):
return {key: list_to_bitmask(value) for key, value in args.items()} return {key: list_to_bitmask(value) for key, value in args.items()}

View File

@ -73,9 +73,6 @@ void init_det(py::module &m) {
(Result<int>(Detector::*)(sls::Positions) const) & (Result<int>(Detector::*)(sls::Positions) const) &
Detector::getModuleId, Detector::getModuleId,
py::arg() = Positions{}) py::arg() = Positions{})
.def("setModuleId",
(void (Detector::*)(int, sls::Positions)) & Detector::setModuleId,
py::arg(), py::arg() = Positions{})
.def("getReceiverVersion", .def("getReceiverVersion",
(Result<int64_t>(Detector::*)(sls::Positions) const) & (Result<int64_t>(Detector::*)(sls::Positions) const) &
Detector::getReceiverVersion, Detector::getReceiverVersion,

View File

@ -392,7 +392,7 @@ uint32_t getDetectorIP() {
#ifdef VIRTUAL #ifdef VIRTUAL
return 0; return 0;
#endif #endif
char temp[50] = ""; char temp[INET_ADDRSTRLEN] = "";
uint32_t res = 0; uint32_t res = 0;
// execute and get address // execute and get address
char output[255]; char output[255];
@ -1525,10 +1525,10 @@ int configureMAC() {
int dstport = udpDetails[0].dstport; int dstport = udpDetails[0].dstport;
LOG(logINFOBLUE, ("Configuring MAC\n")); LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_ip[INET_ADDRSTRLEN]; dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac); getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, 50, dstmac); getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip); getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip); getIpAddressinString(dst_ip, dstip);

View File

@ -263,7 +263,7 @@ u_int64_t getDetectorMAC() {
} }
u_int32_t getDetectorIP() { u_int32_t getDetectorIP() {
char temp[50] = ""; char temp[INET_ADDRSTRLEN] = "";
u_int32_t res = 0; u_int32_t res = 0;
// execute and get address // execute and get address
char output[255]; char output[255];
@ -303,7 +303,7 @@ void initControlServer() {
LOG(logINFOBLUE, ("Configuring Control server\n")); LOG(logINFOBLUE, ("Configuring Control server\n"));
if (!updateFlag && initError == OK) { if (!updateFlag && initError == OK) {
#ifndef VIRTUAL #ifndef VIRTUAL
int detid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE); int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
#else #else
getModuleIdInFile(&initError, initErrorMessage, ID_FILE); getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
#endif #endif
@ -342,7 +342,7 @@ void initControlServer() {
LOG(logDEBUG1, ("Control server: FEB Initialization done\n")); LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
Beb_SetTopVariable(top); Beb_SetTopVariable(top);
Beb_Beb(); Beb_Beb();
Beb_SetModuleId(detid); Beb_SetModuleId(modid);
LOG(logDEBUG1, ("Control server: BEB Initialization done\n")); LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
#endif #endif
// also reads config file and deactivates // also reads config file and deactivates
@ -1531,10 +1531,10 @@ int configureMAC() {
int dstport = udpDetails[iRxEntry].dstport; int dstport = udpDetails[iRxEntry].dstport;
int dstport2 = udpDetails[iRxEntry].dstport2; int dstport2 = udpDetails[iRxEntry].dstport2;
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_ip[INET_ADDRSTRLEN]; dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac); getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, 50, dstmac); getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip); getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip); getIpAddressinString(dst_ip, dstip);

View File

@ -288,16 +288,13 @@ u_int32_t getDetectorNumber() {
} }
int getModuleId(int *ret, char *mess) { int getModuleId(int *ret, char *mess) {
return getModuleIdInFile(ret, mess, ID_FILE); return ((bus_r(MOD_ID_REG) & ~MOD_ID_MSK) >> MOD_ID_OFST);
} }
void setModuleId(int *ret, char *mess, int arg) { void setModuleId(int modid) {
*ret = setModuleIdInFile(mess, arg, ID_FILE); LOG(logINFOBLUE, ("Setting module id in fpga: %d\n", modid))
if (*ret == FAIL) {
return;
}
bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) & ~MOD_ID_MSK); bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) & ~MOD_ID_MSK);
bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) | ((arg << MOD_ID_OFST) & MOD_ID_MSK)); bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) | ((modid << MOD_ID_OFST) & MOD_ID_MSK));
} }
u_int64_t getDetectorMAC() { u_int64_t getDetectorMAC() {
@ -326,7 +323,7 @@ u_int32_t getDetectorIP() {
#ifdef VIRTUAL #ifdef VIRTUAL
return 0; return 0;
#endif #endif
char temp[50] = ""; char temp[INET_ADDRSTRLEN] = "";
u_int32_t res = 0; u_int32_t res = 0;
// execute and get address // execute and get address
char output[255]; char output[255];
@ -422,10 +419,6 @@ void setupDetector() {
sharedMemory_setStatus(IDLE); sharedMemory_setStatus(IDLE);
setupUDPCommParameters(); setupUDPCommParameters();
#endif #endif
getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
if (initError == FAIL) {
return;
}
// pll defines // pll defines
ALTERA_PLL_C10_SetDefines(REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL, ALTERA_PLL_C10_SetDefines(REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL,
PLL_RESET_REG, PLL_RESET_READOUT_MSK, PLL_RESET_REG, PLL_RESET_READOUT_MSK,
@ -483,6 +476,14 @@ void setupDetector() {
if (readConfigFile() == FAIL) { if (readConfigFile() == FAIL) {
return; return;
} }
// set module id in register
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
if (initError == FAIL) {
return;
}
setModuleId(modid);
setBurstMode(DEFAULT_BURST_MODE); setBurstMode(DEFAULT_BURST_MODE);
setFilterResistor(DEFAULT_FILTER_RESISTOR); setFilterResistor(DEFAULT_FILTER_RESISTOR);
setCDSGain(DEFAILT_CDS_GAIN); setCDSGain(DEFAILT_CDS_GAIN);
@ -1749,16 +1750,16 @@ int configureMAC() {
int dstport2 = udpDetails[0].dstport2; int dstport2 = udpDetails[0].dstport2;
LOG(logINFOBLUE, ("Configuring MAC\n")); LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_ip[INET_ADDRSTRLEN]; dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac); getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, 50, dstmac); getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip); getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip); getIpAddressinString(dst_ip, dstip);
char src_mac2[50], src_ip2[INET_ADDRSTRLEN], dst_mac2[50], char src_mac2[MAC_ADDRESS_SIZE], src_ip2[INET_ADDRSTRLEN],
dst_ip2[INET_ADDRSTRLEN]; dst_mac2[MAC_ADDRESS_SIZE], dst_ip2[INET_ADDRSTRLEN];
getMacAddressinString(src_mac2, 50, srcmac2); getMacAddressinString(src_mac2, MAC_ADDRESS_SIZE, srcmac2);
getMacAddressinString(dst_mac2, 50, dstmac2); getMacAddressinString(dst_mac2, MAC_ADDRESS_SIZE, dstmac2);
getIpAddressinString(src_ip2, srcip2); getIpAddressinString(src_ip2, srcip2);
getIpAddressinString(dst_ip2, dstip2); getIpAddressinString(dst_ip2, dstip2);

View File

@ -315,7 +315,7 @@ u_int32_t getDetectorIP() {
#ifdef VIRTUAL #ifdef VIRTUAL
return 0; return 0;
#endif #endif
char temp[50] = ""; char temp[INET_ADDRSTRLEN] = "";
u_int32_t res = 0; u_int32_t res = 0;
// execute and get address // execute and get address
char output[255]; char output[255];
@ -1340,10 +1340,10 @@ int configureMAC() {
int dstport = udpDetails[0].dstport; int dstport = udpDetails[0].dstport;
LOG(logINFOBLUE, ("Configuring MAC\n")); LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_ip[INET_ADDRSTRLEN]; dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac); getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, 50, dstmac); getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip); getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip); getIpAddressinString(dst_ip, dstip);

View File

@ -52,9 +52,6 @@ int detPos[4] = {};
int chipVersion = 10; // (1.0) int chipVersion = 10; // (1.0)
int chipConfigured = 0; int chipConfigured = 0;
// until firmware is done
int temp_readNRows = 512;
int isInitCheckDone() { return initCheckDone; } int isInitCheckDone() { return initCheckDone; }
int getInitResult(char **mess) { int getInitResult(char **mess) {
@ -337,7 +334,7 @@ u_int32_t getDetectorIP() {
#ifdef VIRTUAL #ifdef VIRTUAL
return 0; return 0;
#endif #endif
char temp[50] = ""; char temp[INET_ADDRSTRLEN] = "";
u_int32_t res = 0; u_int32_t res = 0;
// execute and get address // execute and get address
char output[255]; char output[255];
@ -1480,16 +1477,16 @@ int configureMAC() {
int dstport = udpDetails[iRxEntry].dstport; int dstport = udpDetails[iRxEntry].dstport;
int dstport2 = udpDetails[iRxEntry].dstport2; int dstport2 = udpDetails[iRxEntry].dstport2;
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_ip[INET_ADDRSTRLEN]; dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac); getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, 50, dstmac); getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip); getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip); getIpAddressinString(dst_ip, dstip);
char src_mac2[50], src_ip2[INET_ADDRSTRLEN], dst_mac2[50], char src_mac2[MAC_ADDRESS_SIZE], src_ip2[INET_ADDRSTRLEN],
dst_ip2[INET_ADDRSTRLEN]; dst_mac2[MAC_ADDRESS_SIZE], dst_ip2[INET_ADDRSTRLEN];
getMacAddressinString(src_mac2, 50, srcmac2); getMacAddressinString(src_mac2, MAC_ADDRESS_SIZE, srcmac2);
getMacAddressinString(dst_mac2, 50, dstmac2); getMacAddressinString(dst_mac2, MAC_ADDRESS_SIZE, dstmac2);
getIpAddressinString(src_ip2, srcip2); getIpAddressinString(src_ip2, srcip2);
getIpAddressinString(dst_ip2, dstip2); getIpAddressinString(dst_ip2, dstip2);
@ -1642,11 +1639,6 @@ int setReadNRows(int value) {
return FAIL; return FAIL;
} }
// will be replaced when firmware is fixed
LOG(logWARNING, ("Setting number of rows: %d (Not implemented in firmware yet)\n", value));
temp_readNRows = value;
return OK;
// regval is numpackets - 1 // regval is numpackets - 1
int regval = (value / READ_N_ROWS_MULTIPLE) - 1; int regval = (value / READ_N_ROWS_MULTIPLE) - 1;
uint32_t addr = READ_N_ROWS_REG; uint32_t addr = READ_N_ROWS_REG;
@ -1665,10 +1657,6 @@ int setReadNRows(int value) {
} }
int getReadNRows() { int getReadNRows() {
// will be replaced when firmware is fixed
return temp_readNRows;
int enable = (bus_r(READ_N_ROWS_REG) & READ_N_ROWS_ENBL_MSK); int enable = (bus_r(READ_N_ROWS_REG) & READ_N_ROWS_ENBL_MSK);
int regval = ((bus_r(READ_N_ROWS_REG) & READ_N_ROWS_NUM_ROWS_MSK) >> READ_N_ROWS_NUM_ROWS_OFST); int regval = ((bus_r(READ_N_ROWS_REG) & READ_N_ROWS_NUM_ROWS_MSK) >> READ_N_ROWS_NUM_ROWS_OFST);

View File

@ -389,7 +389,7 @@ uint32_t getDetectorIP() {
#ifdef VIRTUAL #ifdef VIRTUAL
return 0; return 0;
#endif #endif
char temp[50] = ""; char temp[INET_ADDRSTRLEN] = "";
uint32_t res = 0; uint32_t res = 0;
// execute and get address // execute and get address
char output[255]; char output[255];
@ -1190,10 +1190,10 @@ int configureMAC() {
int dstport = udpDetails[0].dstport; int dstport = udpDetails[0].dstport;
LOG(logINFOBLUE, ("Configuring MAC\n")); LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_ip[INET_ADDRSTRLEN]; dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac); getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, 50, dstmac); getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip); getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip); getIpAddressinString(dst_ip, dstip);

View File

@ -312,7 +312,7 @@ u_int32_t getDetectorIP() {
#ifdef VIRTUAL #ifdef VIRTUAL
return 0; return 0;
#endif #endif
char temp[50] = ""; char temp[INET_ADDRSTRLEN] = "";
u_int32_t res = 0; u_int32_t res = 0;
// execute and get address // execute and get address
char output[255]; char output[255];
@ -444,6 +444,14 @@ void setupDetector() {
setASICDefaults(); setASICDefaults();
setADIFDefaults(); setADIFDefaults();
// set module id in register
getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
if (initError == FAIL) {
return;
}
// until firmware is done
// setModuleId(modid);
// set trigger flow for m3 (for all timing modes) // set trigger flow for m3 (for all timing modes)
bus_w(FLOW_TRIGGER_REG, bus_r(FLOW_TRIGGER_REG) | FLOW_TRIGGER_MSK); bus_w(FLOW_TRIGGER_REG, bus_r(FLOW_TRIGGER_REG) | FLOW_TRIGGER_MSK);
@ -1720,10 +1728,10 @@ int configureMAC() {
int dstport = udpDetails[0].dstport; int dstport = udpDetails[0].dstport;
LOG(logINFOBLUE, ("Configuring MAC\n")); LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[50], src_ip[INET_ADDRSTRLEN], dst_mac[50], char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_ip[INET_ADDRSTRLEN]; dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, 50, srcmac); getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, 50, dstmac); getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip); getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip); getIpAddressinString(dst_ip, dstip);

View File

@ -52,6 +52,7 @@ typedef struct udpStruct_s {
uint32_t dstip; uint32_t dstip;
uint32_t dstip2; uint32_t dstip2;
} udpStruct; } udpStruct;
#define MAC_ADDRESS_SIZE 18
// basic tests // basic tests
int isInitCheckDone(); int isInitCheckDone();
@ -96,7 +97,7 @@ u_int32_t getDetectorNumber();
int getModuleId(int *ret, char *mess); int getModuleId(int *ret, char *mess);
#endif #endif
#ifdef GOTTHARD2D #ifdef GOTTHARD2D
void setModuleId(int *ret, char *mess, int arg); void setModuleId(int modid);
#endif #endif
u_int64_t getDetectorMAC(); u_int64_t getDetectorMAC();
u_int32_t getDetectorIP(); u_int32_t getDetectorIP();

View File

@ -268,7 +268,6 @@ int get_adc_pipeline(int);
int set_dbit_pipeline(int); int set_dbit_pipeline(int);
int get_dbit_pipeline(int); int get_dbit_pipeline(int);
int get_module_id(int); int get_module_id(int);
int set_module_id(int);
int get_dest_udp_list(int); int get_dest_udp_list(int);
int set_dest_udp_list(int); int set_dest_udp_list(int);
int get_num_dest_list(int); int get_num_dest_list(int);

View File

@ -404,7 +404,6 @@ void function_table() {
flist[F_SET_DBIT_PIPELINE] = &set_dbit_pipeline; flist[F_SET_DBIT_PIPELINE] = &set_dbit_pipeline;
flist[F_GET_DBIT_PIPELINE] = &get_dbit_pipeline; flist[F_GET_DBIT_PIPELINE] = &get_dbit_pipeline;
flist[F_GET_MODULE_ID] = &get_module_id; flist[F_GET_MODULE_ID] = &get_module_id;
flist[F_SET_MODULE_ID] = &set_module_id;
flist[F_GET_DEST_UDP_LIST] = &get_dest_udp_list; flist[F_GET_DEST_UDP_LIST] = &get_dest_udp_list;
flist[F_SET_DEST_UDP_LIST] = &set_dest_udp_list; flist[F_SET_DEST_UDP_LIST] = &set_dest_udp_list;
flist[F_GET_NUM_DEST_UDP] = &get_num_dest_list; flist[F_GET_NUM_DEST_UDP] = &get_num_dest_list;
@ -1760,8 +1759,8 @@ int acquire(int blocking, int file_des) {
if (udpDetails[0].srcmac != getDetectorMAC()) { if (udpDetails[0].srcmac != getDetectorMAC()) {
ret = FAIL; ret = FAIL;
uint64_t sourcemac = getDetectorMAC(); uint64_t sourcemac = getDetectorMAC();
char src_mac[50]; char src_mac[MAC_ADDRESS_SIZE];
getMacAddressinString(src_mac, 50, sourcemac); getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
sprintf(mess, sprintf(mess,
"Invalid udp source mac address for this detector. Must be " "Invalid udp source mac address for this detector. Must be "
"same as hardware detector mac address %s\n", "same as hardware detector mac address %s\n",
@ -4875,8 +4874,8 @@ void calculate_and_set_position() {
else { else {
// create detector mac from x and y // create detector mac from x and y
if (udpDetails[0].srcmac == 0) { if (udpDetails[0].srcmac == 0) {
char dmac[50]; char dmac[MAC_ADDRESS_SIZE];
memset(dmac, 0, 50); memset(dmac, 0, MAC_ADDRESS_SIZE);
sprintf(dmac, "aa:bb:cc:dd:%02x:%02x", pos[0] & 0xFF, sprintf(dmac, "aa:bb:cc:dd:%02x:%02x", pos[0] & 0xFF,
pos[1] & 0xFF); pos[1] & 0xFF);
LOG(logINFO, ("Udp source mac address created: %s\n", dmac)); LOG(logINFO, ("Udp source mac address created: %s\n", dmac));
@ -4895,8 +4894,8 @@ void calculate_and_set_position() {
#if defined(JUNGFRAUD) || defined(GOTTHARD2D) #if defined(JUNGFRAUD) || defined(GOTTHARD2D)
if (getNumberofUDPInterfaces() > 1) { if (getNumberofUDPInterfaces() > 1) {
if (udpDetails[0].srcmac2 == 0) { if (udpDetails[0].srcmac2 == 0) {
char dmac2[50]; char dmac2[MAC_ADDRESS_SIZE];
memset(dmac2, 0, 50); memset(dmac2, 0, MAC_ADDRESS_SIZE);
sprintf(dmac2, "aa:bb:cc:dd:%02x:%02x", (pos[0] + 1) & 0xFF, sprintf(dmac2, "aa:bb:cc:dd:%02x:%02x", (pos[0] + 1) & 0xFF,
pos[1] & 0xFF); pos[1] & 0xFF);
LOG(logINFO, ("Udp source mac address2 created: %s\n", dmac2)); LOG(logINFO, ("Udp source mac address2 created: %s\n", dmac2));
@ -9034,34 +9033,6 @@ int get_module_id(int file_des) {
return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
} }
int set_module_id(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = -1;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logDEBUG1, ("Setting module id to 0x%x\n", arg));
#ifndef GOTTHARD2D
functionNotImplemented();
#else
if (arg > 0xFFFF) {
ret = FAIL;
sprintf(mess, "Could not set module id. Max value: 0x%x\n", 0xFFFF);
LOG(logERROR, (mess));
} else {
setModuleId(&ret, mess, arg);
if (ret != FAIL) {
int retval = getModuleId(&ret, mess);
LOG(logDEBUG1, ("retval module id: %d\n", retval));
validate(&ret, mess, arg, retval, "set module id", DEC);
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_dest_udp_list(int file_des) { int get_dest_udp_list(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
@ -9100,9 +9071,9 @@ int get_dest_udp_list(int file_des) {
char ip[INET_ADDRSTRLEN], ip2[INET_ADDRSTRLEN]; char ip[INET_ADDRSTRLEN], ip2[INET_ADDRSTRLEN];
getIpAddressinString(ip, retvals[3]); getIpAddressinString(ip, retvals[3]);
getIpAddressinString(ip2, retvals[4]); getIpAddressinString(ip2, retvals[4]);
char mac[50], mac2[50]; char mac[MAC_ADDRESS_SIZE], mac2[MAC_ADDRESS_SIZE];
getMacAddressinString(mac, 50, retvals64[0]); getMacAddressinString(mac, MAC_ADDRESS_SIZE, retvals64[0]);
getMacAddressinString(mac2, 50, retvals64[1]); getMacAddressinString(mac2, MAC_ADDRESS_SIZE, retvals64[1]);
LOG(logDEBUG1, LOG(logDEBUG1,
("Udp Dest. retval [%d]: [port %d, port2 %d, ip %s, ip2 %s, " ("Udp Dest. retval [%d]: [port %d, port2 %d, ip %s, ip2 %s, "
"mac %s, mac2 %s]\n", "mac %s, mac2 %s]\n",
@ -9136,9 +9107,9 @@ int set_dest_udp_list(int file_des) {
char ip[INET_ADDRSTRLEN], ip2[INET_ADDRSTRLEN]; char ip[INET_ADDRSTRLEN], ip2[INET_ADDRSTRLEN];
getIpAddressinString(ip, args[3]); getIpAddressinString(ip, args[3]);
getIpAddressinString(ip2, args[4]); getIpAddressinString(ip2, args[4]);
char mac[50], mac2[50]; char mac[MAC_ADDRESS_SIZE], mac2[MAC_ADDRESS_SIZE];
getMacAddressinString(mac, 50, args64[0]); getMacAddressinString(mac, MAC_ADDRESS_SIZE, args64[0]);
getMacAddressinString(mac2, 50, args64[1]); getMacAddressinString(mac2, MAC_ADDRESS_SIZE, args64[1]);
#if !defined(EIGERD) && !defined(JUNGFRAUD) #if !defined(EIGERD) && !defined(JUNGFRAUD)
functionNotImplemented(); functionNotImplemented();

View File

@ -81,13 +81,9 @@ class Detector {
/* [Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench] */ /* [Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench] */
Result<int64_t> getSerialNumber(Positions pos = {}) const; Result<int64_t> getSerialNumber(Positions pos = {}) const;
/** [Eiger][Gotthard2][Mythen3] */ /** [Eiger][Gotthard2][Mythen3] 6 bit value (ideally unique) that is streamed out in the UDP header of the detector.*/
Result<int> getModuleId(Positions pos = {}) const; Result<int> getModuleId(Positions pos = {}) const;
/** [Gotthard2] 6 bit value (ideally unique) that is "
"streamed out1 in the UDP header of the detector. */
void setModuleId(const int value, Positions pos = {});
Result<int64_t> getReceiverVersion(Positions pos = {}) const; Result<int64_t> getReceiverVersion(Positions pos = {}) const;
/** Options: EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2, /** Options: EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2,
@ -667,10 +663,10 @@ class Detector {
/** [Jungfrau] bottom half [Gotthard2] veto debugging */ /** [Jungfrau] bottom half [Gotthard2] veto debugging */
void setSourceUDPMAC2(const MacAddr mac, Positions pos = {}); void setSourceUDPMAC2(const MacAddr mac, Positions pos = {});
Result<defs::udpDestination> Result<UdpDestination> getDestinationUDPList(const uint32_t entry,
getDestinationUDPList(const uint32_t entry, Positions pos = {}) const; Positions pos = {}) const;
void setDestinationUDPList(const defs::udpDestination, const int module_id); void setDestinationUDPList(const UdpDestination, const int module_id);
/** [Jungfrau][Eiger] */ /** [Jungfrau][Eiger] */
Result<int> getNumberofUDPDestinations(Positions pos = {}) const; Result<int> getNumberofUDPDestinations(Positions pos = {}) const;

View File

@ -1379,15 +1379,8 @@ IpAddr CmdProxy::getIpFromAuto() {
return val; return val;
} }
defs::udpDestination CmdProxy::getUdpList() { UdpDestination CmdProxy::getUdpEntry() {
uint32_t entry{}; UdpDestination udpDestination{};
uint32_t port{};
uint32_t port2{};
uint32_t ip{};
uint32_t ip2{};
uint64_t mac{};
uint64_t mac2{};
bool hasEntry = false; bool hasEntry = false;
for (auto it : args) { for (auto it : args) {
@ -1395,40 +1388,40 @@ defs::udpDestination CmdProxy::getUdpList() {
std::string key = it.substr(0, pos); std::string key = it.substr(0, pos);
std::string value = it.substr(pos + 1); std::string value = it.substr(pos + 1);
if (key == "entry") { if (key == "entry") {
entry = StringTo<int>(value); udpDestination.entry = StringTo<int>(value);
hasEntry = true; hasEntry = true;
} else if (key == "ip") { } else if (key == "ip") {
if (value == "auto") { if (value == "auto") {
auto val = getIpFromAuto(); auto val = getIpFromAuto();
LOG(logINFO) << "Setting udp_dstip of detector " << det_id LOG(logINFO) << "Setting udp_dstip of detector " << det_id
<< " to " << val; << " to " << val;
ip = val.uint32(); udpDestination.ip = val;
} else { } else {
ip = IpAddr(value).uint32(); udpDestination.ip = IpAddr(value);
} }
} else if (key == "ip2") { } else if (key == "ip2") {
if (value == "auto") { if (value == "auto") {
auto val = getIpFromAuto(); auto val = getIpFromAuto();
LOG(logINFO) << "Setting udp_dstip2 of detector " << det_id LOG(logINFO) << "Setting udp_dstip2 of detector " << det_id
<< " to " << val; << " to " << val;
ip2 = val.uint32(); udpDestination.ip2 = val;
} else { } else {
ip2 = IpAddr(value).uint32(); udpDestination.ip2 = IpAddr(value);
} }
} else if (key == "mac") { } else if (key == "mac") {
mac = MacAddr(value).uint64(); udpDestination.mac = MacAddr(value);
} else if (key == "mac2") { } else if (key == "mac2") {
mac2 = MacAddr(value).uint64(); udpDestination.mac2 = MacAddr(value);
} else if (key == "port") { } else if (key == "port") {
port = StringTo<uint32_t>(value); udpDestination.port = StringTo<uint32_t>(value);
} else if (key == "port2") { } else if (key == "port2") {
port2 = StringTo<uint32_t>(value); udpDestination.port2 = StringTo<uint32_t>(value);
} }
} }
if (!hasEntry) { if (!hasEntry) {
throw sls::RuntimeError("Found no entry argument."); throw sls::RuntimeError("Found no entry argument.");
} }
return defs::udpDestination(entry, port, ip, mac, port2, ip2, mac2); return udpDestination;
} }
std::string CmdProxy::UDPDestinationList(int action) { std::string CmdProxy::UDPDestinationList(int action) {
@ -1454,7 +1447,7 @@ std::string CmdProxy::UDPDestinationList(int action) {
if (args.empty()) { if (args.empty()) {
WrongNumberOfParameters(1); WrongNumberOfParameters(1);
} }
auto t = getUdpList(); auto t = getUdpEntry();
det->setDestinationUDPList(t, det_id); det->setDestinationUDPList(t, det_id);
os << ToString(args) << std::endl; os << ToString(args) << std::endl;
} else { } else {

View File

@ -1117,7 +1117,7 @@ class CmdProxy {
std::string Trigger(int action); std::string Trigger(int action);
/* Network Configuration (Detector<->Receiver) */ /* Network Configuration (Detector<->Receiver) */
IpAddr getIpFromAuto(); IpAddr getIpFromAuto();
slsDetectorDefs::udpDestination getUdpList(); UdpDestination getUdpEntry();
std::string UDPDestinationList(int action); std::string UDPDestinationList(int action);
std::string UDPDestinationIP(int action); std::string UDPDestinationIP(int action);
std::string UDPDestinationIP2(int action); std::string UDPDestinationIP2(int action);
@ -1203,11 +1203,10 @@ class CmdProxy {
"\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench]" "\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench]"
"Serial number of detector."); "Serial number of detector.");
INTEGER_COMMAND_HEX( GET_COMMAND_HEX(
moduleid, getModuleId, setModuleId, StringTo<int>, moduleid, getModuleId,
"[value]\n\t[Gotthard2][Eiger][Mythen3] 16 bit value (ideally unique) " "\n\t[Gotthard2][Eiger][Mythen3] 16 bit value (ideally unique) "
"that is streamed out in the UDP header of the detector. " "that is streamed out in the UDP header of the detector. Picked up from a file on the module.");
"\n\t[Gotthard2] Can set it too.");
GET_COMMAND(type, getDetectorType, GET_COMMAND(type, getDetectorType,
"\n\tReturns detector type. Can be Eiger, Jungfrau, Gotthard, " "\n\tReturns detector type. Can be Eiger, Jungfrau, Gotthard, "

View File

@ -123,10 +123,6 @@ Result<int> Detector::getModuleId(Positions pos) const {
return pimpl->Parallel(&Module::getModuleId, pos); return pimpl->Parallel(&Module::getModuleId, pos);
} }
void Detector::setModuleId(const int value, Positions pos) {
pimpl->Parallel(&Module::setModuleId, pos, value);
}
Result<int64_t> Detector::getReceiverVersion(Positions pos) const { Result<int64_t> Detector::getReceiverVersion(Positions pos) const {
return pimpl->Parallel(&Module::getReceiverSoftwareVersion, pos); return pimpl->Parallel(&Module::getReceiverSoftwareVersion, pos);
} }
@ -908,12 +904,12 @@ void Detector::setSourceUDPMAC2(const MacAddr mac, Positions pos) {
pimpl->Parallel(&Module::setSourceUDPMAC2, pos, mac); pimpl->Parallel(&Module::setSourceUDPMAC2, pos, mac);
} }
Result<defs::udpDestination> Result<UdpDestination> Detector::getDestinationUDPList(const uint32_t entry,
Detector::getDestinationUDPList(const uint32_t entry, Positions pos) const { Positions pos) const {
return pimpl->Parallel(&Module::getDestinationUDPList, pos, entry); return pimpl->Parallel(&Module::getDestinationUDPList, pos, entry);
} }
void Detector::setDestinationUDPList(const defs::udpDestination dest, void Detector::setDestinationUDPList(const UdpDestination dest,
const int module_id) { const int module_id) {
if (module_id == -1 && size() > 1) { if (module_id == -1 && size() > 1) {
throw sls::RuntimeError("Cannot set this parameter at detector level."); throw sls::RuntimeError("Cannot set this parameter at detector level.");

View File

@ -27,8 +27,8 @@
namespace sls { namespace sls {
// creating new shm // creating new shm
Module::Module(detectorType type, int det_id, int module_id, bool verify) Module::Module(detectorType type, int det_id, int module_index, bool verify)
: moduleId(module_id), shm(det_id, module_id) { : moduleIndex(module_index), shm(det_id, module_index) {
// ensure shared memory was not created before // ensure shared memory was not created before
if (shm.IsExisting()) { if (shm.IsExisting()) {
@ -42,8 +42,8 @@ Module::Module(detectorType type, int det_id, int module_id, bool verify)
} }
// opening existing shm // opening existing shm
Module::Module(int det_id, int module_id, bool verify) Module::Module(int det_id, int module_index, bool verify)
: moduleId(module_id), shm(det_id, module_id) { : moduleIndex(module_index), shm(det_id, module_index) {
// getDetectorType From shm will check if existing // getDetectorType From shm will check if existing
detectorType type = getDetectorTypeFromShm(det_id, verify); detectorType type = getDetectorTypeFromShm(det_id, verify);
@ -98,10 +98,6 @@ int64_t Module::getSerialNumber() const {
int Module::getModuleId() const { return sendToDetector<int>(F_GET_MODULE_ID); } int Module::getModuleId() const { return sendToDetector<int>(F_GET_MODULE_ID); }
void Module::setModuleId(const int value) {
return sendToDetector(F_SET_MODULE_ID, value, nullptr);
}
int64_t Module::getReceiverSoftwareVersion() const { int64_t Module::getReceiverSoftwareVersion() const {
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
return sendToReceiver<int64_t>(F_GET_RECEIVER_VERSION); return sendToReceiver<int64_t>(F_GET_RECEIVER_VERSION);
@ -144,7 +140,7 @@ slsDetectorDefs::xy Module::getNumberOfChannels() const {
void Module::updateNumberOfDetector(slsDetectorDefs::xy det) { void Module::updateNumberOfDetector(slsDetectorDefs::xy det) {
shm()->numberOfDetector = det; shm()->numberOfDetector = det;
int args[2] = {shm()->numberOfDetector.y, moduleId}; int args[2] = {shm()->numberOfDetector.y, moduleIndex};
sendToDetector(F_SET_POSITION, args, nullptr); sendToDetector(F_SET_POSITION, args, nullptr);
} }
@ -825,13 +821,13 @@ std::vector<uint64_t> Module::getNumMissingPackets() const {
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort); auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
client.Send(F_GET_NUM_MISSING_PACKETS); client.Send(F_GET_NUM_MISSING_PACKETS);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleId) + throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} else { } else {
auto nports = client.Receive<int>(); auto nports = client.Receive<int>();
std::vector<uint64_t> retval(nports); std::vector<uint64_t> retval(nports);
client.Receive(retval); client.Receive(retval);
LOG(logDEBUG1) << "Missing packets of Receiver" << moduleId << ": " LOG(logDEBUG1) << "Missing packets of Receiver" << moduleIndex << ": "
<< sls::ToString(retval); << sls::ToString(retval);
return retval; return retval;
} }
@ -941,31 +937,30 @@ void Module::setSourceUDPMAC2(const sls::MacAddr mac) {
sendToDetector(F_SET_SOURCE_UDP_MAC2, mac, nullptr); sendToDetector(F_SET_SOURCE_UDP_MAC2, mac, nullptr);
} }
slsDetectorDefs::udpDestination sls::UdpDestination Module::getDestinationUDPList(const uint32_t entry) const {
Module::getDestinationUDPList(const uint32_t entry) const { return sendToDetector<sls::UdpDestination>(F_GET_DEST_UDP_LIST, entry);
return sendToDetector<udpDestination>(F_GET_DEST_UDP_LIST, entry);
} }
void Module::setDestinationUDPList(const slsDetectorDefs::udpDestination dest) { void Module::setDestinationUDPList(const sls::UdpDestination dest) {
// set them in the default way so the receivers are also set up // set them in the default way so the receivers are also set up
if (dest.entry_ == 0) { if (dest.entry == 0) {
if (dest.port_ != 0) { if (dest.port != 0) {
setDestinationUDPPort(dest.port_); setDestinationUDPPort(dest.port);
} }
if (dest.ip_ != 0) { if (dest.ip != 0) {
setDestinationUDPIP(IpAddr(dest.ip_)); setDestinationUDPIP(dest.ip);
} }
if (dest.mac_ != 0) { if (dest.mac != 0) {
setDestinationUDPMAC(MacAddr(dest.mac_)); setDestinationUDPMAC(dest.mac);
} }
if (dest.port2_ != 0) { if (dest.port2 != 0) {
setDestinationUDPPort2(dest.port2_); setDestinationUDPPort2(dest.port2);
} }
if (dest.ip2_ != 0) { if (dest.ip2 != 0) {
setDestinationUDPIP2(IpAddr(dest.ip2_)); setDestinationUDPIP2(dest.ip2);
} }
if (dest.mac2_ != 0) { if (dest.mac2 != 0) {
setDestinationUDPMAC2(MacAddr(dest.mac2_)); setDestinationUDPMAC2(dest.mac2);
} }
} else { } else {
sendToDetector(F_SET_DEST_UDP_LIST, dest, nullptr); sendToDetector(F_SET_DEST_UDP_LIST, dest, nullptr);
@ -1000,7 +995,7 @@ void Module::setDestinationUDPIP(const IpAddr ip) {
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU); sls::MacAddr retval(0LU);
sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval); sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval);
LOG(logINFO) << "Setting destination udp mac of detector " << moduleId LOG(logINFO) << "Setting destination udp mac of detector " << moduleIndex
<< " to " << retval; << " to " << retval;
sendToDetector(F_SET_DEST_UDP_MAC, retval, nullptr); sendToDetector(F_SET_DEST_UDP_MAC, retval, nullptr);
} }
@ -1020,7 +1015,7 @@ void Module::setDestinationUDPIP2(const IpAddr ip) {
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU); sls::MacAddr retval(0LU);
sendToReceiver(F_SET_RECEIVER_UDP_IP2, ip, retval); sendToReceiver(F_SET_RECEIVER_UDP_IP2, ip, retval);
LOG(logINFO) << "Setting destination udp mac2 of detector " << moduleId LOG(logINFO) << "Setting destination udp mac2 of detector " << moduleIndex
<< " to " << retval; << " to " << retval;
sendToDetector(F_SET_DEST_UDP_MAC2, retval, nullptr); sendToDetector(F_SET_DEST_UDP_MAC2, retval, nullptr);
} }
@ -1078,7 +1073,7 @@ void Module::validateUDPConfiguration() {
std::string Module::printReceiverConfiguration() { std::string Module::printReceiverConfiguration() {
std::ostringstream os; std::ostringstream os;
os << "\n\nDetector " << moduleId << "\nReceiver Hostname:\t" os << "\n\nDetector " << moduleIndex << "\nReceiver Hostname:\t"
<< getReceiverHostname(); << getReceiverHostname();
if (shm()->myDetectorType == JUNGFRAU) { if (shm()->myDetectorType == JUNGFRAU) {
@ -1192,7 +1187,7 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
retval.detType = shm()->myDetectorType; retval.detType = shm()->myDetectorType;
retval.numberOfDetector.x = shm()->numberOfDetector.x; retval.numberOfDetector.x = shm()->numberOfDetector.x;
retval.numberOfDetector.y = shm()->numberOfDetector.y; retval.numberOfDetector.y = shm()->numberOfDetector.y;
retval.moduleId = moduleId; retval.moduleIndex = moduleIndex;
memset(retval.hostname, 0, sizeof(retval.hostname)); memset(retval.hostname, 0, sizeof(retval.hostname));
strcpy_safe(retval.hostname, shm()->hostname); strcpy_safe(retval.hostname, shm()->hostname);
@ -1202,13 +1197,13 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
if (retval.udp_dstmac == 0 && retvals[0] != 0) { if (retval.udp_dstmac == 0 && retvals[0] != 0) {
LOG(logINFO) << "Setting destination udp mac of " LOG(logINFO) << "Setting destination udp mac of "
"detector " "detector "
<< moduleId << " to " << retvals[0]; << moduleIndex << " to " << retvals[0];
sendToDetector(F_SET_DEST_UDP_MAC, retvals[0], nullptr); sendToDetector(F_SET_DEST_UDP_MAC, retvals[0], nullptr);
} }
if (retval.udp_dstmac2 == 0 && retvals[1] != 0) { if (retval.udp_dstmac2 == 0 && retvals[1] != 0) {
LOG(logINFO) << "Setting destination udp mac2 of " LOG(logINFO) << "Setting destination udp mac2 of "
"detector " "detector "
<< moduleId << " to " << retvals[1]; << moduleIndex << " to " << retvals[1];
sendToDetector(F_SET_DEST_UDP_MAC2, retvals[1], nullptr); sendToDetector(F_SET_DEST_UDP_MAC2, retvals[1], nullptr);
} }
@ -1524,7 +1519,7 @@ void Module::sendReceiverRateCorrections(const std::vector<int64_t> &t) {
receiver.Send(static_cast<int>(t.size())); receiver.Send(static_cast<int>(t.size()));
receiver.Send(t); receiver.Send(t);
if (receiver.Receive<int>() == FAIL) { if (receiver.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleId) + throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + receiver.readErrorMessage()); " returned error: " + receiver.readErrorMessage());
} }
} }
@ -1789,7 +1784,7 @@ void Module::sendVetoPhoton(const int chipIndex,
client.Send(gainIndices); client.Send(gainIndices);
client.Send(values); client.Send(values);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) + throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} }
} }
@ -1801,7 +1796,7 @@ void Module::getVetoPhoton(const int chipIndex,
client.Send(F_GET_VETO_PHOTON); client.Send(F_GET_VETO_PHOTON);
client.Send(chipIndex); client.Send(chipIndex);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) + throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} }
@ -2036,7 +2031,7 @@ void Module::getBadChannels(const std::string &fname) const {
auto client = DetectorSocket(shm()->hostname, shm()->controlPort); auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_GET_BAD_CHANNELS); client.Send(F_GET_BAD_CHANNELS);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) + throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} }
// receive badchannels // receive badchannels
@ -2093,7 +2088,7 @@ void Module::setBadChannels(const std::string &fname) {
client.Send(badchannels); client.Send(badchannels);
} }
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) + throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} }
} }
@ -2407,7 +2402,7 @@ std::map<std::string, std::string> Module::getAdditionalJsonHeader() const {
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort); auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
client.Send(F_GET_ADDITIONAL_JSON_HEADER); client.Send(F_GET_ADDITIONAL_JSON_HEADER);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleId) + throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} else { } else {
auto size = client.Receive<int>(); auto size = client.Receive<int>();
@ -2456,7 +2451,7 @@ void Module::setAdditionalJsonHeader(
client.Send(&buff[0], buff.size()); client.Send(&buff[0], buff.size());
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleId) + throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} }
} }
@ -3010,7 +3005,7 @@ slsDetectorDefs::detectorType Module::getDetectorTypeFromShm(int det_id,
shm.OpenSharedMemory(); shm.OpenSharedMemory();
if (verify && shm()->shmversion != SLS_SHMVERSION) { if (verify && shm()->shmversion != SLS_SHMVERSION) {
std::ostringstream ss; std::ostringstream ss;
ss << "Single shared memory (" << det_id << "-" << moduleId ss << "Single shared memory (" << det_id << "-" << moduleIndex
<< ":)version mismatch (expected 0x" << std::hex << SLS_SHMVERSION << ":)version mismatch (expected 0x" << std::hex << SLS_SHMVERSION
<< " but got 0x" << shm()->shmversion << ")" << std::dec << " but got 0x" << shm()->shmversion << ")" << std::dec
<< ". Clear Shared memory to continue."; << ". Clear Shared memory to continue.";
@ -3021,7 +3016,7 @@ slsDetectorDefs::detectorType Module::getDetectorTypeFromShm(int det_id,
} }
void Module::initSharedMemory(detectorType type, int det_id, bool verify) { void Module::initSharedMemory(detectorType type, int det_id, bool verify) {
shm = SharedMemory<sharedSlsDetector>(det_id, moduleId); shm = SharedMemory<sharedSlsDetector>(det_id, moduleIndex);
if (!shm.IsExisting()) { if (!shm.IsExisting()) {
shm.CreateSharedMemory(); shm.CreateSharedMemory();
initializeDetectorStructure(type); initializeDetectorStructure(type);
@ -3029,7 +3024,7 @@ void Module::initSharedMemory(detectorType type, int det_id, bool verify) {
shm.OpenSharedMemory(); shm.OpenSharedMemory();
if (verify && shm()->shmversion != SLS_SHMVERSION) { if (verify && shm()->shmversion != SLS_SHMVERSION) {
std::ostringstream ss; std::ostringstream ss;
ss << "Single shared memory (" << det_id << "-" << moduleId ss << "Single shared memory (" << det_id << "-" << moduleIndex
<< ":) version mismatch (expected 0x" << std::hex << ":) version mismatch (expected 0x" << std::hex
<< SLS_SHMVERSION << " but got 0x" << shm()->shmversion << ")" << SLS_SHMVERSION << " but got 0x" << shm()->shmversion << ")"
<< std::dec << ". Clear Shared memory to continue."; << std::dec << ". Clear Shared memory to continue.";
@ -3051,7 +3046,7 @@ void Module::initializeDetectorStructure(detectorType type) {
shm()->rxTCPPort = DEFAULT_PORTNO + 2; shm()->rxTCPPort = DEFAULT_PORTNO + 2;
shm()->useReceiverFlag = false; shm()->useReceiverFlag = false;
shm()->zmqport = DEFAULT_ZMQ_CL_PORTNO + shm()->zmqport = DEFAULT_ZMQ_CL_PORTNO +
(moduleId * ((shm()->myDetectorType == EIGER) ? 2 : 1)); (moduleIndex * ((shm()->myDetectorType == EIGER) ? 2 : 1));
shm()->zmqip = IpAddr{}; shm()->zmqip = IpAddr{};
shm()->numUDPInterfaces = 1; shm()->numUDPInterfaces = 1;
shm()->stoppedFlag = false; shm()->stoppedFlag = false;
@ -3164,7 +3159,7 @@ void Module::setModule(sls_detector_module &module, bool trimbits) {
client.Send(F_SET_MODULE); client.Send(F_SET_MODULE);
sendModule(&module, client); sendModule(&module, client);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) + throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} }
} }
@ -3177,7 +3172,7 @@ void Module::updateReceiverStreamingIP() {
if (ip == 0) { if (ip == 0) {
ip = HostnameToIp(shm()->rxHostname); ip = HostnameToIp(shm()->rxHostname);
} }
LOG(logINFO) << "Setting default receiver " << moduleId LOG(logINFO) << "Setting default receiver " << moduleIndex
<< " streaming zmq ip to " << ip; << " streaming zmq ip to " << ip;
} }
setReceiverStreamingIP(ip); setReceiverStreamingIP(ip);
@ -3426,7 +3421,7 @@ std::string Module::calculateChecksum(char *buffer, ssize_t bytes) {
void Module::programFPGAviaBlackfin(std::vector<char> buffer) { void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
// send program from memory to detector // send program from memory to detector
LOG(logINFO) << "Sending programming binary (from pof) to module " LOG(logINFO) << "Sending programming binary (from pof) to module "
<< moduleId << " (" << shm()->hostname << ")"; << moduleIndex << " (" << shm()->hostname << ")";
auto client = DetectorSocket(shm()->hostname, shm()->controlPort); auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_PROGRAM_FPGA); client.Send(F_PROGRAM_FPGA);
uint64_t filesize = buffer.size(); uint64_t filesize = buffer.size();
@ -3444,7 +3439,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
std::cout << '\n'; std::cout << '\n';
std::ostringstream os; std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")" os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage(); << " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str()); throw RuntimeError(os.str());
} }
@ -3464,7 +3459,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
std::cout << '\n'; std::cout << '\n';
std::ostringstream os; std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")" os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage(); << " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str()); throw RuntimeError(os.str());
} }
@ -3475,22 +3470,22 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
// checksum // checksum
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
std::ostringstream os; std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")" os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage(); << " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str()); throw RuntimeError(os.str());
} }
if (moduleId == 0) { if (moduleIndex == 0) {
LOG(logINFO) << "Checksum verified"; LOG(logINFO) << "Checksum verified";
} }
// copied to flash // copied to flash
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
std::ostringstream os; std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")" os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage(); << " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str()); throw RuntimeError(os.str());
} }
if (moduleId == 0) { if (moduleIndex == 0) {
LOG(logINFO) << "Copied to flash and checksum verified"; LOG(logINFO) << "Copied to flash and checksum verified";
} }
@ -3500,7 +3495,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
void Module::programFPGAviaNios(std::vector<char> buffer) { void Module::programFPGAviaNios(std::vector<char> buffer) {
LOG(logINFO) << "Sending programming binary (from rbf) to detector " LOG(logINFO) << "Sending programming binary (from rbf) to detector "
<< moduleId << " (" << shm()->hostname << ")"; << moduleIndex << " (" << shm()->hostname << ")";
auto client = DetectorSocket(shm()->hostname, shm()->controlPort); auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_PROGRAM_FPGA); client.Send(F_PROGRAM_FPGA);
@ -3517,14 +3512,14 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
std::ostringstream os; std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")" os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage(); << " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str()); throw RuntimeError(os.str());
} }
client.Send(buffer); client.Send(buffer);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
std::ostringstream os; std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")" os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage(); << " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str()); throw RuntimeError(os.str());
} }

View File

@ -66,12 +66,12 @@ class Module : public virtual slsDetectorDefs {
/** creating new shared memory /** creating new shared memory
verify is if shared memory version matches existing one */ verify is if shared memory version matches existing one */
explicit Module(detectorType type, int det_id = 0, int module_id = 0, explicit Module(detectorType type, int det_id = 0, int module_index = 0,
bool verify = true); bool verify = true);
/** opening existing shared memory /** opening existing shared memory
verify is if shared memory version matches existing one */ verify is if shared memory version matches existing one */
explicit Module(int det_id = 0, int module_id = 0, bool verify = true); explicit Module(int det_id = 0, int module_index = 0, bool verify = true);
virtual ~Module(); virtual ~Module();
@ -91,7 +91,6 @@ class Module : public virtual slsDetectorDefs {
int64_t getDetectorServerVersion() const; int64_t getDetectorServerVersion() const;
int64_t getSerialNumber() const; int64_t getSerialNumber() const;
int getModuleId() const; int getModuleId() const;
void setModuleId(const int value);
int64_t getReceiverSoftwareVersion() const; int64_t getReceiverSoftwareVersion() const;
static detectorType getTypeFromDetector(const std::string &hostname, static detectorType getTypeFromDetector(const std::string &hostname,
int cport = DEFAULT_PORTNO); int cport = DEFAULT_PORTNO);
@ -222,8 +221,8 @@ class Module : public virtual slsDetectorDefs {
void setSourceUDPMAC(const sls::MacAddr mac); void setSourceUDPMAC(const sls::MacAddr mac);
sls::MacAddr getSourceUDPMAC2() const; sls::MacAddr getSourceUDPMAC2() const;
void setSourceUDPMAC2(const sls::MacAddr mac); void setSourceUDPMAC2(const sls::MacAddr mac);
udpDestination getDestinationUDPList(const uint32_t entry) const; sls::UdpDestination getDestinationUDPList(const uint32_t entry) const;
void setDestinationUDPList(const defs::udpDestination dest); void setDestinationUDPList(const sls::UdpDestination dest);
int getNumberofUDPDestinations() const; int getNumberofUDPDestinations() const;
void setNumberofUDPDestinations(const int value); void setNumberofUDPDestinations(const int value);
int getFirstUDPDestination() const; int getFirstUDPDestination() const;
@ -748,7 +747,7 @@ class Module : public virtual slsDetectorDefs {
void programFPGAviaBlackfin(std::vector<char> buffer); void programFPGAviaBlackfin(std::vector<char> buffer);
void programFPGAviaNios(std::vector<char> buffer); void programFPGAviaNios(std::vector<char> buffer);
const int moduleId; const int moduleIndex;
mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0}; mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0};
}; };

View File

@ -337,7 +337,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
int msize[2] = {arg.numberOfDetector.x, arg.numberOfDetector.y}; int msize[2] = {arg.numberOfDetector.x, arg.numberOfDetector.y};
impl()->setDetectorSize(msize); impl()->setDetectorSize(msize);
} }
impl()->setModulePositionId(arg.moduleId); impl()->setModulePositionId(arg.moduleIndex);
impl()->setDetectorHostname(arg.hostname); impl()->setDetectorHostname(arg.hostname);
// udp setup // udp setup

View File

@ -55,9 +55,6 @@ std::ostream &operator<<(std::ostream &os,
std::string ToString(const slsDetectorDefs::currentSrcParameters &r); std::string ToString(const slsDetectorDefs::currentSrcParameters &r);
std::ostream &operator<<(std::ostream &os, std::ostream &operator<<(std::ostream &os,
const slsDetectorDefs::currentSrcParameters &r); const slsDetectorDefs::currentSrcParameters &r);
std::string ToString(const slsDetectorDefs::udpDestination &r);
std::ostream &operator<<(std::ostream &os,
const slsDetectorDefs::udpDestination &r);
const std::string &ToString(const std::string &s); const std::string &ToString(const std::string &s);
/** Convert std::chrono::duration with specified output unit */ /** Convert std::chrono::duration with specified output unit */

View File

@ -30,7 +30,7 @@ class IpAddr {
return addr_ != other; return addr_ != other;
} }
constexpr uint32_t uint32() const noexcept { return addr_; } constexpr uint32_t uint32() const noexcept { return addr_; }
}; } __attribute__((packed));
class MacAddr { class MacAddr {
private: private:
@ -57,13 +57,33 @@ class MacAddr {
return addr_ != other; return addr_ != other;
} }
constexpr uint64_t uint64() const noexcept { return addr_; } constexpr uint64_t uint64() const noexcept { return addr_; }
}; } __attribute__((packed));
struct UdpDestination {
uint32_t entry{};
uint32_t port{};
uint32_t port2{};
IpAddr ip;
IpAddr ip2;
MacAddr mac;
MacAddr mac2;
std::string str() const;
constexpr bool operator==(const UdpDestination &other) const {
return ((entry == other.entry) && (port == other.port) &&
(port2 == other.port2) && (ip== other.ip) &&
(ip2 == other.ip2) && (mac == other.mac) &&
(mac2 == other.mac2));
}
} __attribute__((packed));
std::ostream &operator<<(std::ostream &out, const IpAddr &addr);
std::ostream &operator<<(std::ostream &out, const MacAddr &addr);
std::ostream &operator<<(std::ostream &out, const UdpDestination &dest);
IpAddr HostnameToIp(const char *hostname); IpAddr HostnameToIp(const char *hostname);
std::string IpToInterfaceName(const std::string &ip); std::string IpToInterfaceName(const std::string &ip);
MacAddr InterfaceNameToMac(const std::string &inf); MacAddr InterfaceNameToMac(const std::string &inf);
IpAddr InterfaceNameToIp(const std::string &ifn); IpAddr InterfaceNameToIp(const std::string &ifn);
std::ostream &operator<<(std::ostream &out, const IpAddr &addr);
std::ostream &operator<<(std::ostream &out, const MacAddr &addr);
} // namespace sls } // namespace sls

View File

@ -494,35 +494,13 @@ typedef struct {
} }
} __attribute__((packed)); } __attribute__((packed));
struct udpDestination {
uint32_t entry_{};
uint32_t port_{};
uint32_t port2_{};
uint32_t ip_{};
uint32_t ip2_{};
uint64_t mac_{};
uint64_t mac2_{};
udpDestination() {}
udpDestination(uint32_t entry, uint32_t port = 0, uint32_t ip = 0, uint64_t mac = 0,
uint32_t port2 = 0, uint32_t ip2 = 0, uint64_t mac2 = 0)
: entry_(entry), port_(port), port2_(port2), ip_(ip), ip2_(ip2),
mac_(mac), mac2_(mac2) {}
bool operator==(const udpDestination &other) const {
return ((entry_ == other.entry_) && (port_ == other.port_) &&
(port2_ == other.port2_) && (ip_ == other.ip_) &&
(ip2_ == other.ip2_) && (mac_ == other.mac_) &&
(mac2_ == other.mac2_));
}
} __attribute__((packed));
/** /**
* structure to udpate receiver * structure to udpate receiver
*/ */
struct rxParameters { struct rxParameters {
detectorType detType{GENERIC}; detectorType detType{GENERIC};
xy numberOfDetector; xy numberOfDetector;
int moduleId{0}; int moduleIndex{0};
char hostname[MAX_STR_LENGTH]; char hostname[MAX_STR_LENGTH];
int udpInterfaces{1}; int udpInterfaces{1};
int udp_dstport{0}; int udp_dstport{0};

View File

@ -244,7 +244,6 @@ enum detFuncs {
F_SET_DBIT_PIPELINE, F_SET_DBIT_PIPELINE,
F_GET_DBIT_PIPELINE, F_GET_DBIT_PIPELINE,
F_GET_MODULE_ID, F_GET_MODULE_ID,
F_SET_MODULE_ID,
F_GET_DEST_UDP_LIST, F_GET_DEST_UDP_LIST,
F_SET_DEST_UDP_LIST, F_SET_DEST_UDP_LIST,
F_GET_NUM_DEST_UDP, F_GET_NUM_DEST_UDP,
@ -602,7 +601,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_DBIT_PIPELINE: return "F_SET_DBIT_PIPELINE"; case F_SET_DBIT_PIPELINE: return "F_SET_DBIT_PIPELINE";
case F_GET_DBIT_PIPELINE: return "F_GET_DBIT_PIPELINE"; case F_GET_DBIT_PIPELINE: return "F_GET_DBIT_PIPELINE";
case F_GET_MODULE_ID: return "F_GET_MODULE_ID"; case F_GET_MODULE_ID: return "F_GET_MODULE_ID";
case F_SET_MODULE_ID: return "F_SET_MODULE_ID";
case F_GET_DEST_UDP_LIST: return "F_GET_DEST_UDP_LIST"; case F_GET_DEST_UDP_LIST: return "F_GET_DEST_UDP_LIST";
case F_SET_DEST_UDP_LIST: return "F_SET_DEST_UDP_LIST"; case F_SET_DEST_UDP_LIST: return "F_SET_DEST_UDP_LIST";
case F_GET_NUM_DEST_UDP: return "F_GET_NUM_DEST_UDP"; case F_GET_NUM_DEST_UDP: return "F_GET_NUM_DEST_UDP";

View File

@ -1,15 +1,13 @@
/** API versions */ /** API versions */
#define GITBRANCH "roundrobin" #define GITBRANCH "roundrobin"
#define APILIB 0x210831 #define APILIB 0x210831
#define APIRECEIVER 0x210831 #define APIRECEIVER 0x210831
#define APIGUI 0x210819 #define APIGUI 0x210819
#define APICTB 0x210908
#define APIGOTTHARD 0x210908 #define APICTB 0x210909
#define APIGOTTHARD2 0x210908 #define APIGOTTHARD 0x210909
#define APIJUNGFRAU 0x210908 #define APIGOTTHARD2 0x210909
#define APIMYTHEN3 0x210908 #define APIJUNGFRAU 0x210909
#define APIMOENCH 0x210907 #define APIMYTHEN3 0x210909
#define APIEIGER 0x210908 #define APIMOENCH 0x210909
#define APIEIGER 0x210909

View File

@ -28,7 +28,7 @@ std::string ToString(const slsDetectorDefs::rxParameters &r) {
oss << '[' << "detType:" << r.detType << std::endl oss << '[' << "detType:" << r.detType << std::endl
<< "numberOfDetector.x:" << r.numberOfDetector.x << std::endl << "numberOfDetector.x:" << r.numberOfDetector.x << std::endl
<< "numberOfDetector.y:" << r.numberOfDetector.y << std::endl << "numberOfDetector.y:" << r.numberOfDetector.y << std::endl
<< "moduleId:" << r.moduleId << std::endl << "moduleIndex:" << r.moduleIndex << std::endl
<< "hostname:" << r.hostname << std::endl << "hostname:" << r.hostname << std::endl
<< "udpInterfaces:" << r.udpInterfaces << std::endl << "udpInterfaces:" << r.udpInterfaces << std::endl
<< "udp_dstport:" << r.udp_dstport << std::endl << "udp_dstport:" << r.udp_dstport << std::endl
@ -148,31 +148,6 @@ std::ostream &operator<<(std::ostream &os,
return os << ToString(r); return os << ToString(r);
} }
std::string ToString(const slsDetectorDefs::udpDestination &r) {
std::ostringstream oss;
oss << '[' << std::endl
<< "entry " << r.entry_ << std::endl
<< "ip " << IpAddr(r.ip_) << std::endl
<< "mac " << MacAddr(r.mac_) << std::endl
<< "port " << r.port_ << std::endl;
if (r.port2_ != 0) {
oss << "port2 " << r.port2_ << std::endl;
}
if (r.ip2_ != 0) {
oss << "ip2 " << IpAddr(r.ip2_) << std::endl;
}
if (r.mac2_ != 0) {
oss << "mac2 " << MacAddr(r.mac2_) << std::endl;
}
oss << ']';
return oss.str();
}
std::ostream &operator<<(std::ostream &os,
const slsDetectorDefs::udpDestination &r) {
return os << ToString(r);
}
std::string ToString(const defs::runStatus s) { std::string ToString(const defs::runStatus s) {
switch (s) { switch (s) {
case defs::ERROR: case defs::ERROR:

View File

@ -69,6 +69,26 @@ std::string MacAddr::str() const { return to_hex(':'); }
std::string MacAddr::hex() const { return to_hex(); } std::string MacAddr::hex() const { return to_hex(); }
std::string UdpDestination::str() const {
std::ostringstream oss;
oss << '[' << std::endl
<< "entry " << entry << std::endl
<< "ip " << ip << std::endl
<< "mac " << mac << std::endl
<< "port " << port << std::endl;
if (port2 != 0) {
oss << "port2 " << port2 << std::endl;
}
if (ip2 != 0) {
oss << "ip2 " << ip2 << std::endl;
}
if (mac2 != 0) {
oss << "mac2 " << mac2 << std::endl;
}
oss << ']';
return oss.str();
}
std::ostream &operator<<(std::ostream &out, const IpAddr &addr) { std::ostream &operator<<(std::ostream &out, const IpAddr &addr) {
return out << addr.str(); return out << addr.str();
} }
@ -77,6 +97,10 @@ std::ostream &operator<<(std::ostream &out, const MacAddr &addr) {
return out << addr.str(); return out << addr.str();
} }
std::ostream &operator<<(std::ostream &out, const UdpDestination &dest) {
return out << dest.str();
}
IpAddr HostnameToIp(const char *hostname) { IpAddr HostnameToIp(const char *hostname) {
addrinfo hints; addrinfo hints;
addrinfo *result = nullptr; addrinfo *result = nullptr;

View File

@ -9,7 +9,7 @@ TEST_CASE("Get size of empty file") {
char fname[] = "temfile_XXXXXX"; char fname[] = "temfile_XXXXXX";
std::ifstream ifs(fname); std::ifstream ifs(fname);
auto size = sls::getFileSize(ifs); auto size = sls::getFileSize(ifs);
REQUIRE(size == 0); REQUIRE(size <= 0); // -1 or zero
} }
TEST_CASE("Get size of file with data") { TEST_CASE("Get size of file with data") {

View File

@ -112,4 +112,19 @@ TEST_CASE("Copy construct a MacAddr") {
CHECK(addr == addr2); CHECK(addr == addr2);
} }
TEST_CASE("udp dst struct basic properties"){
static_assert(sizeof(UdpDestination) == 36);
UdpDestination dst{};
REQUIRE(dst.entry == 0);
REQUIRE(dst.port == 0);
REQUIRE(dst.port2 == 0);
REQUIRE(dst.ip == 0);
REQUIRE(dst.ip2 == 0);
REQUIRE(dst.mac == 0);
REQUIRE(dst.mac2 == 0);
}
// TODO!(Erik) Look up a real hostname and verify the IP // TODO!(Erik) Look up a real hostname and verify the IP