mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 07:01:33 +01:00
Commandline (#66)
* WIP * WIP * removed status to string from defs * WIP * WIP * WIP removed unused functions in multi * WIP * print hex in a terrible way * WIP, loadconfig error * WIP, type to string * WIP * fix to conversion * WIP, hostname doesnt work * WIP * WIP * WIP * WIP, threshold * WIP, threshold * WIP * WIP, triggers * WIP, cycles to triggers * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * rx_udsocksize fx, WIP * WIP * WIP * WIP * file index (64 bit), WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * merge * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * New python mod
This commit is contained in:
@@ -122,7 +122,7 @@
|
||||
#define DELAY_LEFT_LSB_REG (0x12 << MEM_MAP_SHIFT)
|
||||
#define DELAY_LEFT_MSB_REG (0x13 << MEM_MAP_SHIFT)
|
||||
|
||||
/* Cycles Left 64 bit RO register TODO */
|
||||
/* Triggers Left 64 bit RO register TODO */
|
||||
#define CYCLES_LEFT_LSB_REG (0x14 << MEM_MAP_SHIFT)
|
||||
#define CYCLES_LEFT_MSB_REG (0x15 << MEM_MAP_SHIFT)
|
||||
|
||||
@@ -450,7 +450,7 @@
|
||||
#define DELAY_LSB_REG (0x60 << MEM_MAP_SHIFT)
|
||||
#define DELAY_MSB_REG (0x61 << MEM_MAP_SHIFT)
|
||||
|
||||
/* Cycles 64 bit RW register */
|
||||
/* Triggers 64 bit RW register */
|
||||
#define CYCLES_LSB_REG (0x62 << MEM_MAP_SHIFT)
|
||||
#define CYCLES_MSB_REG (0x63 << MEM_MAP_SHIFT)
|
||||
|
||||
|
||||
Binary file not shown.
@@ -560,7 +560,7 @@ void setupDetector() {
|
||||
setTimer(DIGITAL_SAMPLES, DEFAULT_NUM_SAMPLES); // update databytes and allocate ram
|
||||
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
|
||||
setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
|
||||
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
setTimer(TRIGGER_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
setTimer(FRAME_PERIOD, DEFAULT_PERIOD);
|
||||
setTimer(DELAY_AFTER_TRIGGER, DEFAULT_DELAY);
|
||||
setTiming(DEFAULT_TIMING_MODE);
|
||||
@@ -904,12 +904,12 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
|
||||
FILE_LOG(logINFO, ("\tGetting delay: %lldns\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
if(val >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting #cycles: %lld\n", (long long int)val));
|
||||
FILE_LOG(logINFO, ("Setting #triggers: %lld\n", (long long int)val));
|
||||
}
|
||||
retval = set64BitReg(val, CYCLES_LSB_REG, CYCLES_MSB_REG);
|
||||
FILE_LOG(logINFO, ("\tGetting #cycles: %lld\n", (long long int)retval));
|
||||
FILE_LOG(logINFO, ("\tGetting #triggers: %lld\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
case ANALOG_SAMPLES:
|
||||
@@ -974,9 +974,9 @@ int64_t getTimeLeft(enum timerIndex ind){
|
||||
FILE_LOG(logINFO, ("Getting delay left: %lldns\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
retval = get64BitReg(CYCLES_LEFT_LSB_REG, CYCLES_LEFT_MSB_REG);
|
||||
FILE_LOG(logINFO, ("Getting number of cycles left: %lld\n", (long long int)retval));
|
||||
FILE_LOG(logINFO, ("Getting number of triggers left: %lld\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
case ACTUAL_TIME:
|
||||
@@ -2200,7 +2200,7 @@ int startStateMachine(){
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int wait_in_s = (setTimer(FRAME_NUMBER, -1) *
|
||||
setTimer(CYCLES_NUMBER, -1) *
|
||||
setTimer(TRIGGER_NUMBER, -1) *
|
||||
(setTimer(FRAME_PERIOD, -1)/(1E9)));
|
||||
FILE_LOG(logDEBUG1, ("going to wait for %d s\n", wait_in_s));
|
||||
while(!virtual_stop && (wait_in_s >= 0)) {
|
||||
|
||||
@@ -6,7 +6,7 @@ support_lib = ../../slsSupportLib/include/
|
||||
BLACKFIN_CC = bfin-uclinux-gcc
|
||||
CROSS = powerpc-4xx-softfloat-
|
||||
CC = $(CROSS)gcc
|
||||
CFLAGS += -Wall -DEIGERD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
|
||||
CFLAGS += -Wall -DEIGERD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm
|
||||
PROGS = eigerDetectorServer
|
||||
DESTDIR = bin
|
||||
|
||||
Binary file not shown.
@@ -64,7 +64,7 @@ int eiger_triggermode = 0;
|
||||
int eiger_extgating = 0;
|
||||
int eiger_extgatingpolarity = 0;
|
||||
int eiger_nexposures = 1;
|
||||
int eiger_ncycles = 1;
|
||||
int eiger_ntriggers = 1;
|
||||
|
||||
|
||||
#ifdef VIRTUAL
|
||||
@@ -441,7 +441,7 @@ void setupDetector() {
|
||||
setTimer(SUBFRAME_ACQUISITION_TIME, DEFAULT_SUBFRAME_EXPOSURE);
|
||||
setTimer(SUBFRAME_DEADTIME, DEFAULT_SUBFRAME_DEADTIME);
|
||||
setTimer(FRAME_PERIOD, DEFAULT_PERIOD);
|
||||
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
setTimer(TRIGGER_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
setDynamicRange(DEFAULT_DYNAMIC_RANGE);
|
||||
eiger_photonenergy = DEFAULT_PHOTON_ENERGY;
|
||||
setParallelMode(DEFAULT_PARALLEL_MODE);
|
||||
@@ -617,20 +617,20 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
|
||||
switch(ind) {
|
||||
case FRAME_NUMBER:
|
||||
if (val >= 0) {
|
||||
FILE_LOG(logDEBUG1, ("Setting number of frames: %d * %d\n", (unsigned int)val, eiger_ncycles));
|
||||
FILE_LOG(logDEBUG1, ("Setting number of frames: %d * %d\n", (unsigned int)val, eiger_ntriggers));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetNExposures((unsigned int)val*eiger_ncycles)) {
|
||||
if (Feb_Control_SetNExposures((unsigned int)val*eiger_ntriggers)) {
|
||||
eiger_nexposures = val;
|
||||
//SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles());
|
||||
//SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfTriggers());
|
||||
on_dst = 0;
|
||||
int i;
|
||||
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
|
||||
ndsts_in_use = 1;
|
||||
nimages_per_request = eiger_nexposures * eiger_ncycles;
|
||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||
}
|
||||
#else
|
||||
eiger_nexposures = val;
|
||||
nimages_per_request = eiger_nexposures * eiger_ncycles;
|
||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||
#endif
|
||||
}return eiger_nexposures;
|
||||
|
||||
@@ -714,25 +714,25 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
|
||||
return eiger_virtual_period*1e9;
|
||||
#endif
|
||||
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
if (val >= 0) {
|
||||
FILE_LOG(logDEBUG1, ("Setting number of triggers: %d * %d\n",
|
||||
(unsigned int)val,eiger_nexposures));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetNExposures((unsigned int)val*eiger_nexposures)) {
|
||||
eiger_ncycles = val;
|
||||
//SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles());
|
||||
eiger_ntriggers = val;
|
||||
//SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfTriggers());
|
||||
on_dst = 0;
|
||||
int i;
|
||||
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
|
||||
nimages_per_request = eiger_nexposures * eiger_ncycles;
|
||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||
}
|
||||
#else
|
||||
eiger_ncycles = val;
|
||||
nimages_per_request = eiger_nexposures * eiger_ncycles;
|
||||
eiger_ntriggers = val;
|
||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||
#endif
|
||||
}
|
||||
return eiger_ncycles;
|
||||
return eiger_ntriggers;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Timer Index not implemented for this detector: %d\n", ind));
|
||||
break;
|
||||
@@ -1240,7 +1240,7 @@ int configureMAC() {
|
||||
on_dst = 0;
|
||||
|
||||
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
|
||||
nimages_per_request=eiger_nexposures * eiger_ncycles;
|
||||
nimages_per_request=eiger_nexposures * eiger_ntriggers;
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
/* BASE_ACQUISITION FPGA registers TODO --------------------------------------------------*/
|
||||
|
||||
/* Cycles left 64bit Register */
|
||||
/* Triggers left 64bit Register */
|
||||
#define GET_CYCLES_LSB_REG (0x10 + BASE_ACQUISITION)
|
||||
#define GET_CYCLES_MSB_REG (0x14 + BASE_ACQUISITION)
|
||||
|
||||
|
||||
Binary file not shown.
@@ -374,7 +374,7 @@ void setupDetector() {
|
||||
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
|
||||
setDefaultDacs();
|
||||
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
|
||||
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
setTimer(TRIGGER_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
|
||||
setTimer(ACQUISITION_TIME, DEFAULT_PERIOD);
|
||||
}
|
||||
@@ -436,12 +436,12 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
|
||||
retval = set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG )/ (1E-9 * SYSTEM_C0); //TODO
|
||||
FILE_LOG(logDEBUG1, ("Getting period: %lldns\n", (long long int)retval));
|
||||
break;
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
if(val >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting #cycles: %lld\n", (long long int)val));
|
||||
FILE_LOG(logINFO, ("Setting #triggers: %lld\n", (long long int)val));
|
||||
}
|
||||
retval = set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||
FILE_LOG(logDEBUG1, ("Getting #cycles: %lld\n", (long long int)retval));
|
||||
FILE_LOG(logDEBUG1, ("Getting #triggers: %lld\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -488,9 +488,9 @@ int64_t getTimeLeft(enum timerIndex ind){
|
||||
FILE_LOG(logINFO, ("Getting number of frames left: %lld\n",(long long int)retval));
|
||||
break;
|
||||
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
retval = get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG);
|
||||
FILE_LOG(logINFO, ("Getting number of cycles left: %lld\n", (long long int)retval));
|
||||
FILE_LOG(logINFO, ("Getting number of triggers left: %lld\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -870,7 +870,7 @@ int startStateMachine(){
|
||||
void* start_timer(void* arg) {
|
||||
int64_t periodns = setTimer(FRAME_PERIOD, -1);
|
||||
int numFrames = (setTimer(FRAME_NUMBER, -1) *
|
||||
setTimer(CYCLES_NUMBER, -1) );
|
||||
setTimer(TRIGGER_NUMBER, -1) );
|
||||
int64_t exp_ns = setTimer(ACQUISITION_TIME, -1);
|
||||
|
||||
|
||||
|
||||
@@ -318,11 +318,11 @@
|
||||
#define GET_DELAY_LSB_REG (0x6a << MEM_MAP_SHIFT)
|
||||
#define GET_DELAY_MSB_REG (0x6b << MEM_MAP_SHIFT)
|
||||
|
||||
/* Set Cycles 64 bit register */
|
||||
/* Set Triggers 64 bit register */
|
||||
#define SET_TRAINS_LSB_REG (0x6c << MEM_MAP_SHIFT)
|
||||
#define SET_TRAINS_MSB_REG (0x6d << MEM_MAP_SHIFT)
|
||||
|
||||
/* Get Cycles 64 bit register */
|
||||
/* Get Triggers 64 bit register */
|
||||
#define GET_TRAINS_LSB_REG (0x6e << MEM_MAP_SHIFT)
|
||||
#define GET_TRAINS_MSB_REG (0x6f << MEM_MAP_SHIFT)
|
||||
|
||||
|
||||
Binary file not shown.
@@ -421,7 +421,7 @@ void setupDetector() {
|
||||
setExtSignal(DEFAULT_TRIGGER_MODE);
|
||||
setTiming(DEFAULT_TIMING_MODE);
|
||||
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
|
||||
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
setTimer(TRIGGER_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
|
||||
setTimer(FRAME_PERIOD, DEFAULT_PERIOD);
|
||||
setTimer(DELAY_AFTER_TRIGGER, DEFAULT_DELAY);
|
||||
@@ -852,12 +852,12 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
|
||||
}
|
||||
break;
|
||||
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
if(val >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting Cycles: %lld\n", (long long int)val));
|
||||
FILE_LOG(logINFO, ("Setting Triggers: %lld\n", (long long int)val));
|
||||
}
|
||||
retval = set64BitReg(val, SET_TRAINS_LSB_REG, SET_TRAINS_MSB_REG);
|
||||
FILE_LOG(logDEBUG1, ("\tGetting Cycles: %lld\n", (long long int)retval));
|
||||
FILE_LOG(logDEBUG1, ("\tGetting Triggers: %lld\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -905,9 +905,9 @@ int64_t getTimeLeft(enum timerIndex ind){
|
||||
}
|
||||
break;
|
||||
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
retval = get64BitReg(GET_TRAINS_LSB_REG, GET_TRAINS_MSB_REG);
|
||||
FILE_LOG(logINFO, ("Getting number of cycles left: %lld\n", (long long int)retval));
|
||||
FILE_LOG(logINFO, ("Getting number of triggers left: %lld\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1466,7 +1466,7 @@ int configureMAC() {
|
||||
// remember old parameters
|
||||
enum timingMode oldtiming = getTiming();
|
||||
uint64_t oldframes = setTimer(FRAME_NUMBER, -1);
|
||||
uint64_t oldcycles = setTimer(CYCLES_NUMBER, -1);
|
||||
uint64_t oldtriggers = setTimer(TRIGGER_NUMBER, -1);
|
||||
uint64_t oldPeriod = setTimer(FRAME_PERIOD, -1);
|
||||
uint64_t oldExptime = setTimer(ACQUISITION_TIME, -1);
|
||||
|
||||
@@ -1474,12 +1474,12 @@ int configureMAC() {
|
||||
FILE_LOG(logINFO, ("\tSetting basic parameters\n"
|
||||
"\tTiming: auto\n"
|
||||
"\tframes: 1\n"
|
||||
"\tcycles: 1\n"
|
||||
"\ttriggers: 1\n"
|
||||
"\tperiod: 1s\n"
|
||||
"\texptime: 900ms\n"));
|
||||
setTiming(AUTO_TIMING);
|
||||
setTimer(FRAME_NUMBER, 1);
|
||||
setTimer(CYCLES_NUMBER, 1);
|
||||
setTimer(TRIGGER_NUMBER, 1);
|
||||
setTimer(FRAME_PERIOD, 1e9); // important to keep this until we have to wait for acquisition to start
|
||||
setTimer(ACQUISITION_TIME, 900 * 1000);
|
||||
|
||||
@@ -1507,14 +1507,14 @@ int configureMAC() {
|
||||
FILE_LOG(logINFO, ("\tSetting previous parameters:\n"
|
||||
"\tTiming: %d\n"
|
||||
"\tframes: %lld\n"
|
||||
"\tcycles: %lld\n"
|
||||
"\ttriggers: %lld\n"
|
||||
"\tperiod: %lld ns\n"
|
||||
"\texptime:%lld ns\n",
|
||||
(int)oldtiming, (long long int)oldframes, (long long int)oldcycles,
|
||||
(int)oldtiming, (long long int)oldframes, (long long int)oldtriggers,
|
||||
(long long int)oldPeriod, (long long int)oldExptime));
|
||||
setTiming(oldtiming);
|
||||
setTimer(FRAME_NUMBER, oldframes);
|
||||
setTimer(CYCLES_NUMBER, oldcycles);
|
||||
setTimer(TRIGGER_NUMBER, oldtriggers);
|
||||
setTimer(FRAME_PERIOD, oldPeriod);
|
||||
setTimer(ACQUISITION_TIME, oldExptime);
|
||||
FILE_LOG(logINFOBLUE, ("Done sending a frame at configuration\n"));
|
||||
@@ -1566,7 +1566,7 @@ int startStateMachine(){
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int wait_in_s = (setTimer(FRAME_NUMBER, -1) *
|
||||
setTimer(CYCLES_NUMBER, -1) *
|
||||
setTimer(TRIGGER_NUMBER, -1) *
|
||||
(setTimer(FRAME_PERIOD, -1)/(1E9)));
|
||||
FILE_LOG(logDEBUG1, ("going to wait for %d s\n", wait_in_s));
|
||||
while(!virtual_stop && (wait_in_s >= 0)) {
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
#define GET_DELAY_LSB_REG (0x12 << MEM_MAP_SHIFT) // different kind of delay
|
||||
#define GET_DELAY_MSB_REG (0x13 << MEM_MAP_SHIFT) // different kind of delay
|
||||
|
||||
/* Get Cycles 64 bit register */
|
||||
/* Get Triggers 64 bit register */
|
||||
#define GET_CYCLES_LSB_REG (0x14 << MEM_MAP_SHIFT)
|
||||
#define GET_CYCLES_MSB_REG (0x15 << MEM_MAP_SHIFT)
|
||||
|
||||
@@ -375,7 +375,7 @@
|
||||
#define SET_DELAY_LSB_REG (0x60 << MEM_MAP_SHIFT) // different kind of delay
|
||||
#define SET_DELAY_MSB_REG (0x61 << MEM_MAP_SHIFT) // different kind of delay
|
||||
|
||||
/* Set Cycles 64 bit register */
|
||||
/* Set Triggers 64 bit register */
|
||||
#define SET_CYCLES_LSB_REG (0x62 << MEM_MAP_SHIFT)
|
||||
#define SET_CYCLES_MSB_REG (0x63 << MEM_MAP_SHIFT)
|
||||
|
||||
|
||||
Binary file not shown.
@@ -445,7 +445,7 @@ void setupDetector() {
|
||||
setSettings(DEFAULT_SETTINGS);
|
||||
|
||||
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
|
||||
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
setTimer(TRIGGER_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
|
||||
setTimer(FRAME_PERIOD, DEFAULT_PERIOD);
|
||||
setTimer(DELAY_AFTER_TRIGGER, DEFAULT_DELAY);
|
||||
@@ -627,12 +627,12 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
|
||||
FILE_LOG(logDEBUG1, ("Getting delay: %lldns\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
if(val >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting #cycles: %lld\n", (long long int)val));
|
||||
FILE_LOG(logINFO, ("Setting #triggers: %lld\n", (long long int)val));
|
||||
}
|
||||
retval = set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||
FILE_LOG(logDEBUG1, ("Getting #cycles: %lld\n", (long long int)retval));
|
||||
FILE_LOG(logDEBUG1, ("Getting #triggers: %lld\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
case STORAGE_CELL_NUMBER:
|
||||
@@ -690,9 +690,9 @@ int64_t getTimeLeft(enum timerIndex ind){
|
||||
FILE_LOG(logINFO, ("Getting delay left: %lldns\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
retval = get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG);
|
||||
FILE_LOG(logINFO, ("Getting number of cycles left: %lld\n", (long long int)retval));
|
||||
FILE_LOG(logINFO, ("Getting number of triggers left: %lld\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
case ACTUAL_TIME:
|
||||
@@ -1674,7 +1674,7 @@ int startStateMachine(){
|
||||
void* start_timer(void* arg) {
|
||||
int64_t periodns = setTimer(FRAME_PERIOD, -1);
|
||||
int numFrames = (setTimer(FRAME_NUMBER, -1) *
|
||||
setTimer(CYCLES_NUMBER, -1) *
|
||||
setTimer(TRIGGER_NUMBER, -1) *
|
||||
(setTimer(STORAGE_CELL_NUMBER, -1) + 1));
|
||||
int64_t exp_ns = setTimer(ACQUISITION_TIME, -1);
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
#define DELAY_LEFT_LSB_REG (0x12 << MEM_MAP_SHIFT)
|
||||
#define DELAY_LEFT_MSB_REG (0x13 << MEM_MAP_SHIFT)
|
||||
|
||||
/* Cycles Left 64 bit RO register TODO */
|
||||
/* Triggers Left 64 bit RO register TODO */
|
||||
#define CYCLES_LEFT_LSB_REG (0x14 << MEM_MAP_SHIFT)
|
||||
#define CYCLES_LEFT_MSB_REG (0x15 << MEM_MAP_SHIFT)
|
||||
|
||||
@@ -446,7 +446,7 @@
|
||||
#define DELAY_LSB_REG (0x60 << MEM_MAP_SHIFT)
|
||||
#define DELAY_MSB_REG (0x61 << MEM_MAP_SHIFT)
|
||||
|
||||
/* Cycles 64 bit RW register */
|
||||
/* Triggers 64 bit RW register */
|
||||
#define CYCLES_LSB_REG (0x62 << MEM_MAP_SHIFT)
|
||||
#define CYCLES_MSB_REG (0x63 << MEM_MAP_SHIFT)
|
||||
|
||||
|
||||
@@ -523,7 +523,7 @@ void setupDetector() {
|
||||
setTimer(SAMPLES, DEFAULT_NUM_SAMPLES); // update databytes and allocate ram
|
||||
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
|
||||
setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
|
||||
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
setTimer(TRIGGER_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
setTimer(FRAME_PERIOD, DEFAULT_PERIOD);
|
||||
setTimer(DELAY_AFTER_TRIGGER, DEFAULT_DELAY);
|
||||
setTiming(DEFAULT_TIMING_MODE);
|
||||
@@ -847,12 +847,12 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
|
||||
FILE_LOG(logINFO, ("\tGetting delay: %lldns\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
if(val >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting #cycles: %lld\n", (long long int)val));
|
||||
FILE_LOG(logINFO, ("Setting #triggers: %lld\n", (long long int)val));
|
||||
}
|
||||
retval = set64BitReg(val, CYCLES_LSB_REG, CYCLES_MSB_REG);
|
||||
FILE_LOG(logINFO, ("\tGetting #cycles: %lld\n", (long long int)retval));
|
||||
FILE_LOG(logINFO, ("\tGetting #triggers: %lld\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
case SAMPLES:
|
||||
@@ -901,9 +901,9 @@ int64_t getTimeLeft(enum timerIndex ind){
|
||||
FILE_LOG(logINFO, ("Getting delay left: %lldns\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
retval = get64BitReg(CYCLES_LEFT_LSB_REG, CYCLES_LEFT_MSB_REG);
|
||||
FILE_LOG(logINFO, ("Getting number of cycles left: %lld\n", (long long int)retval));
|
||||
FILE_LOG(logINFO, ("Getting number of triggers left: %lld\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
case ACTUAL_TIME:
|
||||
@@ -1813,7 +1813,7 @@ int startStateMachine(){
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int wait_in_s = (setTimer(FRAME_NUMBER, -1) *
|
||||
setTimer(CYCLES_NUMBER, -1) *
|
||||
setTimer(TRIGGER_NUMBER, -1) *
|
||||
(setTimer(FRAME_PERIOD, -1)/(1E9)));
|
||||
FILE_LOG(logDEBUG1, ("going to wait for %d s\n", wait_in_s));
|
||||
while(!virtual_stop && (wait_in_s >= 0)) {
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
#define GET_DELAY_LSB_REG (0x0002 * REG_OFFSET + BASE_PATTERN_CONTROL)
|
||||
#define GET_DELAY_MSB_REG (0x0003 * REG_OFFSET + BASE_PATTERN_CONTROL)
|
||||
|
||||
/* Cycles left 64bit Register */
|
||||
/* Triggers left 64bit Register */
|
||||
#define GET_CYCLES_LSB_REG (0x0004 * REG_OFFSET + BASE_PATTERN_CONTROL)
|
||||
#define GET_CYCLES_MSB_REG (0x0005 * REG_OFFSET + BASE_PATTERN_CONTROL)
|
||||
|
||||
|
||||
Binary file not shown.
@@ -360,7 +360,7 @@ void setupDetector() {
|
||||
|
||||
// Initialization of acquistion parameters
|
||||
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
|
||||
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
setTimer(TRIGGER_NUMBER, DEFAULT_NUM_CYCLES);
|
||||
|
||||
setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
|
||||
setTimer(FRAME_PERIOD, DEFAULT_PERIOD);
|
||||
@@ -440,12 +440,12 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
|
||||
FILE_LOG(logINFO, ("\tGetting delay: %lldns\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
if(val >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting #cycles: %lld\n", (long long int)val));
|
||||
FILE_LOG(logINFO, ("Setting #triggers: %lld\n", (long long int)val));
|
||||
}
|
||||
retval = set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||
FILE_LOG(logDEBUG1, ("Getting #cycles: %lld\n", (long long int)retval));
|
||||
FILE_LOG(logDEBUG1, ("Getting #triggers: %lld\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -498,9 +498,9 @@ int64_t getTimeLeft(enum timerIndex ind){
|
||||
FILE_LOG(logINFO, ("Getting number of frames left: %lld\n",(long long int)retval));
|
||||
break;
|
||||
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
retval = get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG);
|
||||
FILE_LOG(logINFO, ("Getting number of cycles left: %lld\n", (long long int)retval));
|
||||
FILE_LOG(logINFO, ("Getting number of triggers left: %lld\n", (long long int)retval));
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -960,7 +960,7 @@ int startStateMachine(){
|
||||
void* start_timer(void* arg) {
|
||||
int64_t periodns = setTimer(FRAME_PERIOD, -1);
|
||||
int numFrames = (setTimer(FRAME_NUMBER, -1) *
|
||||
setTimer(CYCLES_NUMBER, -1) );
|
||||
setTimer(TRIGGER_NUMBER, -1) );
|
||||
int64_t exp_ns = setTimer(ACQUISITION_TIME, -1);
|
||||
|
||||
|
||||
|
||||
@@ -67,5 +67,11 @@ void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||
*/
|
||||
void getIpAddressinString(char* cip, uint32_t ip);
|
||||
|
||||
/**
|
||||
* Convert string to ip address
|
||||
* @param cip string source
|
||||
* @param ip result
|
||||
*/
|
||||
void getIpAddressFromString(char* cip, uint32_t* ip);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,8 +25,8 @@ extern int errno;
|
||||
|
||||
// Variables that will be exported
|
||||
int lockStatus = 0;
|
||||
char lastClientIP[INET_ADDRSTRLEN] = "";
|
||||
char thisClientIP[INET_ADDRSTRLEN] = "";
|
||||
uint32_t lastClientIP = 0u;
|
||||
uint32_t thisClientIP = 0u;
|
||||
int differentClients = 0;
|
||||
int isControlServer = 1;
|
||||
int ret = FAIL;
|
||||
@@ -34,7 +34,7 @@ int fnum = 0;
|
||||
char mess[MAX_STR_LENGTH];
|
||||
|
||||
// Local variables
|
||||
char dummyClientIP[INET_ADDRSTRLEN] = "";
|
||||
uint32_t dummyClientIP = 0u;
|
||||
int myport = -1;
|
||||
// socket descriptor set
|
||||
fd_set readset, tempset;
|
||||
@@ -220,9 +220,14 @@ int acceptConnection(int socketDescriptor) {
|
||||
}
|
||||
// accept success
|
||||
else {
|
||||
inet_ntop(AF_INET, &(addressC.sin_addr), dummyClientIP, INET_ADDRSTRLEN);
|
||||
char buf[INET_ADDRSTRLEN] = "";
|
||||
memset(buf, 0, INET_ADDRSTRLEN);
|
||||
inet_ntop(AF_INET, &(addressC.sin_addr), buf, INET_ADDRSTRLEN);
|
||||
FILE_LOG(logDEBUG3, ("%s socket accepted connection, fd= %d\n",
|
||||
(isControlServer ? "control":"stop"), file_des));
|
||||
|
||||
getIpAddressFromString(buf, &dummyClientIP);
|
||||
|
||||
// add the file descriptor from accept
|
||||
FD_SET(file_des, &readset);
|
||||
maxfd = (maxfd < file_des)?file_des:maxfd;
|
||||
@@ -381,9 +386,9 @@ int receiveDataOnly(int file_des, void* buf,int length) {
|
||||
}
|
||||
|
||||
if (total_received>0)
|
||||
strcpy(thisClientIP,dummyClientIP);
|
||||
thisClientIP = dummyClientIP;
|
||||
|
||||
if (strcmp(lastClientIP,thisClientIP)) {
|
||||
if (lastClientIP == thisClientIP) {
|
||||
differentClients = 1;
|
||||
}
|
||||
else
|
||||
@@ -545,7 +550,7 @@ int receiveModule(int file_des, sls_detector_module* myMod) {
|
||||
}
|
||||
n = receiveData(file_des, myMod->chanregs, sizeof(int) * (myMod->nchan), INT32);
|
||||
FILE_LOG(level, ("chanregs received. %d bytes.\n", n));
|
||||
if (!n){
|
||||
if (!n && myMod->nchan != 0){
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
@@ -557,7 +562,9 @@ int receiveModule(int file_des, sls_detector_module* myMod) {
|
||||
|
||||
void Server_LockedError() {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n", lastClientIP);
|
||||
char buf[INET_ADDRSTRLEN] = "";
|
||||
getIpAddressinString(buf, dummyClientIP);
|
||||
sprintf(mess,"Detector locked by %s\n", buf);
|
||||
FILE_LOG(logWARNING, (mess));
|
||||
}
|
||||
|
||||
@@ -610,3 +617,16 @@ void getIpAddressinString(char* cip, uint32_t ip) {
|
||||
memset(cip, 0, INET_ADDRSTRLEN);
|
||||
inet_ntop(AF_INET, &ip, cip, INET_ADDRSTRLEN);
|
||||
}
|
||||
|
||||
|
||||
void getIpAddressFromString(char* cip, uint32_t* ip) {
|
||||
char buf[INET_ADDRSTRLEN]="";
|
||||
memset(buf, 0, INET_ADDRSTRLEN);
|
||||
char* byte = strtok (cip,".");
|
||||
while (byte != NULL) {
|
||||
sprintf(cip,"%02x",atoi(byte));
|
||||
strcat(buf, cip);
|
||||
byte = strtok (NULL, ".");
|
||||
}
|
||||
sscanf(buf, "%x", ip);
|
||||
}
|
||||
@@ -28,8 +28,8 @@ const enum detectorType myDetectorType = GENERIC;
|
||||
|
||||
// Global variables from communication_funcs
|
||||
extern int lockStatus;
|
||||
extern char lastClientIP[INET_ADDRSTRLEN];
|
||||
extern char thisClientIP[INET_ADDRSTRLEN];
|
||||
extern uint32_t lastClientIP;
|
||||
extern uint32_t thisClientIP;
|
||||
extern int differentClients;
|
||||
extern int isControlServer;
|
||||
extern int ret;
|
||||
@@ -41,7 +41,7 @@ int sockfd = 0;
|
||||
int debugflag = 0;
|
||||
udpStruct udpDetails = {32410, 32411, 50001, 50002, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
int configured = FAIL;
|
||||
char configureMessage[MAX_STR_LENGTH]="";
|
||||
char configureMessage[MAX_STR_LENGTH]="udp parameters not configured yet";
|
||||
int maxydet = -1;
|
||||
int detectorId = -1;
|
||||
|
||||
@@ -71,8 +71,6 @@ void init_detector() {
|
||||
}
|
||||
else initStopServer();
|
||||
strcpy(mess,"dummy message");
|
||||
strcpy(lastClientIP,"none");
|
||||
strcpy(thisClientIP,"none1");
|
||||
lockStatus=0;
|
||||
}
|
||||
|
||||
@@ -122,7 +120,7 @@ const char* getTimerName(enum timerIndex ind) {
|
||||
case ACQUISITION_TIME: return "acquisition_time";
|
||||
case FRAME_PERIOD: return "frame_period";
|
||||
case DELAY_AFTER_TRIGGER: return "delay_after_trigger";
|
||||
case CYCLES_NUMBER: return "cycles_number";
|
||||
case TRIGGER_NUMBER: return "triggers_number";
|
||||
case ACTUAL_TIME: return "actual_time";
|
||||
case MEASUREMENT_TIME: return "measurement_time";
|
||||
case PROGRESS: return "progress";
|
||||
@@ -1670,7 +1668,7 @@ int start_acquisition(int file_des) {
|
||||
ret = startStateMachine();
|
||||
if (ret == FAIL) {
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
sprintf(mess, "Could not start acquisition. Could not create udp socket in server. Check rx_udpip & rx_udpport.\n");
|
||||
sprintf(mess, "Could not start acquisition. Could not create udp socket in server. Check udp_dstip & udp_dstport.\n");
|
||||
#else
|
||||
sprintf(mess, "Could not start acquisition\n");
|
||||
#endif
|
||||
@@ -1778,7 +1776,7 @@ int start_and_read_all(int file_des) {
|
||||
ret = startStateMachine();
|
||||
if (ret == FAIL) {
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
sprintf(mess, "Could not start acquisition. Could not create udp socket in server. Check rx_udpip & rx_udpport.\n");
|
||||
sprintf(mess, "Could not start acquisition. Could not create udp socket in server. Check udp_dstip & udp_dstport.\n");
|
||||
#else
|
||||
sprintf(mess, "Could not start acquisition\n");
|
||||
#endif
|
||||
@@ -1841,7 +1839,7 @@ int set_timer(int file_des) {
|
||||
case FRAME_NUMBER:
|
||||
case ACQUISITION_TIME:
|
||||
case FRAME_PERIOD:
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
case ANALOG_SAMPLES:
|
||||
case DIGITAL_SAMPLES:
|
||||
@@ -1911,7 +1909,7 @@ int set_timer(int file_des) {
|
||||
#else
|
||||
switch(ind) {
|
||||
case FRAME_NUMBER:
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
case STORAGE_CELL_NUMBER:
|
||||
validate64(tns, retval, vtimerName, DEC); // no conversion, so all good
|
||||
break;
|
||||
@@ -1983,13 +1981,13 @@ int get_time_left(int file_des) {
|
||||
case FRAME_NUMBER:
|
||||
case FRAME_PERIOD:
|
||||
case DELAY_AFTER_TRIGGER:
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
#elif GOTTHARDD
|
||||
case ACQUISITION_TIME:
|
||||
case FRAME_NUMBER:
|
||||
case FRAME_PERIOD:
|
||||
case DELAY_AFTER_TRIGGER:
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
#elif CHIPTESTBOARDD
|
||||
case FRAMES_FROM_START:
|
||||
case FRAMES_FROM_START_PG:
|
||||
@@ -1998,7 +1996,7 @@ int get_time_left(int file_des) {
|
||||
case FRAME_NUMBER:
|
||||
case FRAME_PERIOD:
|
||||
case DELAY_AFTER_TRIGGER:
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
#elif MOENCHD
|
||||
case FRAMES_FROM_START:
|
||||
case FRAMES_FROM_START_PG:
|
||||
@@ -2007,13 +2005,13 @@ int get_time_left(int file_des) {
|
||||
case FRAME_NUMBER:
|
||||
case FRAME_PERIOD:
|
||||
case DELAY_AFTER_TRIGGER:
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
#elif MYTHEN3D
|
||||
case FRAME_NUMBER:
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
#elif GOTTHARD2D
|
||||
case FRAME_NUMBER:
|
||||
case CYCLES_NUMBER:
|
||||
case TRIGGER_NUMBER:
|
||||
#endif
|
||||
retval = getTimeLeft(ind);
|
||||
FILE_LOG(logDEBUG1, ("Timer left index %d: %lld\n", ind, retval));
|
||||
@@ -2270,15 +2268,17 @@ int lock_server(int file_des) {
|
||||
// set
|
||||
if (lock >= 0) {
|
||||
if (!lockStatus || // if it was unlocked, anyone can lock
|
||||
(!strcmp(lastClientIP, thisClientIP)) || // if it was locked, need same ip
|
||||
(!strcmp(lastClientIP,"none"))) { // if it was locked, must be by "none"
|
||||
(lastClientIP == thisClientIP) || // if it was locked, need same ip
|
||||
(lastClientIP == 0u)) { // if it was locked, must be by "none"
|
||||
lockStatus = lock;
|
||||
if (lock) {
|
||||
FILE_LOG(logINFO, ("Server lock to %s\n", lastClientIP));
|
||||
char buf[INET_ADDRSTRLEN] = "";
|
||||
getIpAddressinString(buf, lastClientIP);
|
||||
FILE_LOG(logINFO, ("Server lock to %s\n", buf));
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Server unlocked\n"));
|
||||
}
|
||||
strcpy(lastClientIP, thisClientIP);
|
||||
lastClientIP = thisClientIP;
|
||||
} else {
|
||||
Server_LockedError();
|
||||
}
|
||||
@@ -2293,7 +2293,9 @@ int lock_server(int file_des) {
|
||||
int get_last_client_ip(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
return Server_SendResult(file_des, OTHER, UPDATE, lastClientIP, sizeof(lastClientIP));
|
||||
uint32_t retval = lastClientIP;
|
||||
retval = __builtin_bswap32(retval);
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
@@ -2303,7 +2305,7 @@ int set_port(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int p_number = -1;
|
||||
char oldLastClientIP[INET_ADDRSTRLEN] = {0};
|
||||
uint32_t oldLastClientIP = 0;
|
||||
|
||||
if (receiveData(file_des, &p_number, sizeof(p_number), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
@@ -2320,7 +2322,7 @@ int set_port(int file_des) {
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Setting %s port to %d\n",
|
||||
(isControlServer ? "control":"stop"), p_number));
|
||||
strcpy(oldLastClientIP, lastClientIP);
|
||||
oldLastClientIP = lastClientIP;
|
||||
sd = bindSocket(p_number);
|
||||
}
|
||||
}
|
||||
@@ -2331,7 +2333,7 @@ int set_port(int file_des) {
|
||||
closeConnection(file_des);
|
||||
exitServer(sockfd);
|
||||
sockfd = sd;
|
||||
strcpy(lastClientIP, oldLastClientIP);
|
||||
lastClientIP = oldLastClientIP;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -2355,7 +2357,9 @@ int send_update(int file_des) {
|
||||
int i32 = -1;
|
||||
int64_t i64 = -1;
|
||||
|
||||
n = sendData(file_des,lastClientIP,sizeof(lastClientIP),OTHER);
|
||||
i32 = lastClientIP;
|
||||
i32 = __builtin_bswap32(i32);
|
||||
n = sendData(file_des, &i32,sizeof(i32),INT32);
|
||||
if (n < 0) return printSocketReadError();
|
||||
|
||||
// dr
|
||||
@@ -2421,8 +2425,8 @@ int send_update(int file_des) {
|
||||
if (n < 0) return printSocketReadError();
|
||||
#endif
|
||||
|
||||
// #cycles
|
||||
i64 = setTimer(CYCLES_NUMBER,GET_FLAG);
|
||||
// #triggers
|
||||
i64 = setTimer(TRIGGER_NUMBER,GET_FLAG);
|
||||
n = sendData(file_des,&i64,sizeof(i64),INT64);
|
||||
if (n < 0) return printSocketReadError();
|
||||
|
||||
@@ -2458,7 +2462,7 @@ int send_update(int file_des) {
|
||||
#endif
|
||||
|
||||
if (lockStatus == 0) {
|
||||
strcpy(lastClientIP, thisClientIP);
|
||||
lastClientIP = thisClientIP;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -2466,219 +2470,6 @@ int send_update(int file_des) {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
int configure_mac(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
const size_t array_size = 50;
|
||||
const size_t n_args = 14;
|
||||
const size_t n_retvals = 2;
|
||||
char args[n_args][array_size];
|
||||
char retvals[n_retvals][array_size];
|
||||
|
||||
memset(args, 0, sizeof(args));
|
||||
memset(retvals, 0, sizeof(retvals));
|
||||
|
||||
if (receiveData(file_des, args, sizeof(args), OTHER) < 0)
|
||||
return printSocketReadError();
|
||||
|
||||
FILE_LOG(logDEBUG1, ("\n Configuring MAC\n"));
|
||||
// dest port
|
||||
uint32_t dstPort = 0;
|
||||
sscanf(args[0], "%x", &dstPort);
|
||||
FILE_LOG(logDEBUG1, ("Dst Port: %x\n", dstPort));
|
||||
// dest ip
|
||||
uint32_t dstIp = 0;
|
||||
sscanf(args[1], "%x", &dstIp);
|
||||
{
|
||||
char ipstring[INET_ADDRSTRLEN];
|
||||
getIpAddressinString(ipstring, dstIp);
|
||||
FILE_LOG(logINFO, ("Dst Ip Addr: %s\n", ipstring));
|
||||
}
|
||||
|
||||
// dest mac
|
||||
uint64_t dstMac = 0;
|
||||
#ifdef VIRTUAL
|
||||
sscanf(args[2], "%lx", &dstMac);
|
||||
#else
|
||||
sscanf(args[2], "%llx", &dstMac);
|
||||
#endif
|
||||
{
|
||||
char macstring[50];
|
||||
getMacAddressinString(macstring, 50, dstMac);
|
||||
FILE_LOG(logDEBUG1, ("Dst Mac Addr: %s\n", macstring));
|
||||
}
|
||||
// source ip
|
||||
uint32_t srcIp = 0;
|
||||
sscanf(args[3], "%x", &srcIp);
|
||||
{
|
||||
char ipstring[INET_ADDRSTRLEN];
|
||||
getIpAddressinString(ipstring, srcIp);
|
||||
FILE_LOG(logINFO, ("Src Ip Addr: %s\n", ipstring));
|
||||
}
|
||||
// source mac
|
||||
uint64_t srcMac = 0;
|
||||
#ifdef VIRTUAL
|
||||
sscanf(args[4], "%lx", &srcMac);
|
||||
#else
|
||||
sscanf(args[4], "%llx", &srcMac);
|
||||
#endif
|
||||
{
|
||||
char macstring[50];
|
||||
getMacAddressinString(macstring, 50, srcMac);
|
||||
FILE_LOG(logDEBUG1, ("Src Mac Addr: %s\n", macstring));
|
||||
}
|
||||
|
||||
#if defined(JUNGFRAUD) || defined(EIGERD)
|
||||
// source port 2
|
||||
uint32_t dstPort2 = 0;
|
||||
sscanf(args[5], "%x", &dstPort2);
|
||||
FILE_LOG(logDEBUG1, ("Dst Port2: %x\n", dstPort2));
|
||||
#endif
|
||||
#ifdef JUNGFRAUD
|
||||
// dest ip2
|
||||
uint32_t dstIp2 = 0;
|
||||
sscanf(args[6], "%x", &dstIp2);
|
||||
{
|
||||
char ipstring[INET_ADDRSTRLEN];
|
||||
getIpAddressinString(ipstring, dstIp2);
|
||||
FILE_LOG(logDEBUG1, ("Dst Ip Addr2: %s\n", ipstring));
|
||||
}
|
||||
// dest mac2
|
||||
uint64_t dstMac2 = 0;
|
||||
#ifdef VIRTUAL
|
||||
sscanf(args[7], "%lx", &dstMac2);
|
||||
#else
|
||||
sscanf(args[7], "%llx", &dstMac2);
|
||||
#endif
|
||||
{
|
||||
char macstring[50];
|
||||
getMacAddressinString(macstring, 50, dstMac2);
|
||||
FILE_LOG(logDEBUG1, ("Dst Mac Addr2: %s\n", macstring));
|
||||
}
|
||||
// source ip2
|
||||
uint32_t srcIp2 = 0;
|
||||
sscanf(args[8], "%x", &srcIp2);
|
||||
{
|
||||
char ipstring[INET_ADDRSTRLEN];
|
||||
getIpAddressinString(ipstring, srcIp2);
|
||||
FILE_LOG(logDEBUG1, ("Src Ip Addr2: %s\n", ipstring));
|
||||
}
|
||||
// source mac2
|
||||
uint64_t srcMac2 = 0;
|
||||
#ifdef VIRTUAL
|
||||
sscanf(args[9], "%lx", &srcMac2);
|
||||
#else
|
||||
sscanf(args[9], "%llx", &srcMac2);
|
||||
#endif
|
||||
{
|
||||
char macstring[50];
|
||||
getMacAddressinString(macstring, 50, srcMac2);
|
||||
FILE_LOG(logDEBUG1, ("Src Mac Addr2: %s\n", macstring));
|
||||
}
|
||||
|
||||
// number of interfaces
|
||||
int numInterfaces = 0;
|
||||
sscanf(args[10], "%d", &numInterfaces);
|
||||
int selInterface = 1;
|
||||
sscanf(args[11], "%d", &selInterface);
|
||||
|
||||
#endif
|
||||
#if defined(JUNGFRAUD) || defined(EIGERD)
|
||||
int pos[2] = {0, 0};
|
||||
sscanf(args[12], "%x", &pos[X]);
|
||||
sscanf(args[13], "%x", &pos[Y]);
|
||||
FILE_LOG(logDEBUG1, ("Position: [%d, %d]\n", pos[X], pos[Y]));
|
||||
#endif
|
||||
|
||||
|
||||
// set only
|
||||
if ((Server_VerifyLock() == OK)) {
|
||||
|
||||
// stop detector if it was running
|
||||
enum runStatus status = getRunStatus();
|
||||
if (status != IDLE && status != RUN_FINISHED && status != STOPPED) {
|
||||
if (status == RUNNING)
|
||||
stopStateMachine();
|
||||
#if !defined(EIGERD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
|
||||
cleanFifos();
|
||||
#endif
|
||||
status = getRunStatus();
|
||||
if (status != IDLE && status != RUN_FINISHED && status != STOPPED) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Cannot configure mac when detector is not idle. Detector at %s state\n", getRunStateName(status));
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == OK) {
|
||||
#ifdef EIGERD
|
||||
// change mac to hardware mac
|
||||
if (srcMac != getDetectorMAC()) {
|
||||
FILE_LOG(logWARNING, ("actual detector mac address %llx does not match "
|
||||
"the one from client %llx\n",
|
||||
(long long unsigned int)getDetectorMAC(),
|
||||
(long long unsigned int)srcMac));
|
||||
srcMac = getDetectorMAC();
|
||||
FILE_LOG(logWARNING,("matched detectormac to the hardware mac now\n"));
|
||||
}
|
||||
|
||||
// always remember the ip sent from the client (could be for 10g(if not dhcp))
|
||||
if (srcIp != getDetectorIP())
|
||||
custom10gIp = srcIp;
|
||||
|
||||
//only for 1Gbe, change ip to hardware ip
|
||||
if (!enableTenGigabitEthernet(-1)) {
|
||||
FILE_LOG(logWARNING, ("Using DHCP IP for Configuring MAC\n"));
|
||||
srcIp = getDetectorIP();
|
||||
}
|
||||
// 10 gbe (use ip given from client)
|
||||
else
|
||||
srcIp = custom10gIp;
|
||||
ret = configureMAC(dstIp, dstMac, srcMac, srcIp, dstPort, dstPort2);
|
||||
#elif JUNGFRAUD
|
||||
ret = configureMAC(numInterfaces, selInterface, dstIp, dstMac, srcMac, srcIp, dstPort, dstIp2, dstMac2, srcMac2, srcIp2, dstPort2);
|
||||
#else
|
||||
ret = configureMAC(dstIp, dstMac, srcMac, srcIp, dstPort);
|
||||
#endif
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
if (ret != OK) {
|
||||
if (ret == FAIL)
|
||||
sprintf(mess,"Could not configure mac because of incorrect udp 1G destination IP and port\n");
|
||||
else if (ret == -1)
|
||||
sprintf(mess, "Could not allocate RAM\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
#else
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess,"Configure Mac failed\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
FILE_LOG(logINFO, ("\tConfigure MAC successful\n"));
|
||||
}
|
||||
#if defined(EIGERD) || defined (JUNGFRAUD)
|
||||
if (ret != FAIL) {
|
||||
ret = setDetectorPosition(pos);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not set detector position\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// set retval vals
|
||||
if (ret != FAIL) {
|
||||
sprintf(retvals[0],"%llx", (long long unsigned int)srcMac);
|
||||
sprintf(retvals[1],"%x", srcIp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Server_SendResult(file_des, OTHER, UPDATE, retvals, sizeof(retvals));
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
int enable_ten_giga(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@@ -3225,15 +3016,23 @@ int set_rate_correct(int file_des) {
|
||||
|
||||
// switching on in right mode
|
||||
else {
|
||||
if (tau_ns < 0)
|
||||
if (tau_ns < 0) {
|
||||
tau_ns = getDefaultSettingsTau_in_nsec();
|
||||
if (tau_ns < 0) {
|
||||
ret = FAIL;
|
||||
strcpy(mess,"Default settings file not loaded. No default tau yet\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
}
|
||||
else if (tau_ns > 0) {
|
||||
//changing tau to a user defined value changes settings to undefined
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined (tau changed)\n"));
|
||||
}
|
||||
int64_t retval = setRateCorrection(tau_ns);
|
||||
validate64(tau_ns, retval, "set rate correction", DEC);
|
||||
if (ret == OK) {
|
||||
int64_t retval = setRateCorrection(tau_ns);
|
||||
validate64(tau_ns, retval, "set rate correction", DEC);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user