diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c index 42d5d528b..c8d619c8d 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c @@ -1224,7 +1224,47 @@ int initConfGain(int isettings,int val,int imod){ } -int configureMAC(int ipad,long long int macad,long long int servermacad,int ival){ +int configureMAC(int ipad,long long int macad,long long int servermacad,int ival, int adc){ + //setting adc mask + int reg; + int udpPacketSize=0x050E; + int ipPacketSize=0x0522; + switch(adc){ + case 0: + case 1: + case 2: + case 3: + case 4: + reg = (NCHAN*2)<ip.ip_ver = 0x4; mac_conf_regs->ip.ip_ihl = 0x5; mac_conf_regs->ip.ip_tos = 0x0; - mac_conf_regs->ip.ip_len = 0x0522; // was 0x0526; + mac_conf_regs->ip.ip_len = ipPacketSize;//0x0522; // was 0x0526; mac_conf_regs->ip.ip_ident = 0x0000; mac_conf_regs->ip.ip_flag = 0x2; mac_conf_regs->ip.ip_offset = 0x00; @@ -1347,7 +1387,7 @@ int configureMAC(int ipad,long long int macad,long long int servermacad,int ival mac_conf_regs->udp.udp_srcport = 0xE185; mac_conf_regs->udp.udp_destport = 0xC351; - mac_conf_regs->udp.udp_len = 0x050E; //was 0x0512; + mac_conf_regs->udp.udp_len = udpPacketSize;//0x050E; //was 0x0512; mac_conf_regs->udp.udp_chksum = 0x0000; #ifdef VERBOSE diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h index 75c7b0b67..3b13b4630 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h +++ b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h @@ -61,7 +61,7 @@ int getTemperature(int tempSensor,int imod); int initHighVoltage(int val,int imod); int initConfGain(int isettings,int val,int imod); -int configureMAC(int ipad, long long int macad, long long int servermacad, int ival); +int configureMAC(int ipad, long long int macad, long long int servermacad, int ival, int adc); u_int64_t getDetectorNumber(); u_int32_t getFirmwareVersion(); diff --git a/slsDetectorSoftware/gotthardDetectorServer/registers_g.h b/slsDetectorSoftware/gotthardDetectorServer/registers_g.h index af72416e1..1e5523dbe 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/registers_g.h +++ b/slsDetectorSoftware/gotthardDetectorServer/registers_g.h @@ -53,6 +53,8 @@ #define FPGA_SVN_REG 0x29<<11 +#define CHIP_OF_INTRST_REG 0x2A<<11 + //FIFO #define LOOK_AT_ME_REG 0x28<<11 @@ -269,5 +271,10 @@ #define SETTINGS_OFFSET 4 +/* CHIP_OF_INTRST_REG */ +#define CHANNEL_MASK 0xffff0000 +#define CHANNEL_OFFSET 16 +#define ACTIVE_ADC_MASK 0x0000001f + #endif diff --git a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c index aa2dcf932..ed56ca3e9 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c @@ -2759,6 +2759,7 @@ int configure_mac(int file_des) { int ipad; long long int imacadd; long long int iservermacadd; + int adc=-1; sprintf(mess,"Can't configure MAC\n"); @@ -2785,6 +2786,13 @@ int configure_mac(int file_des) { printf("\n"); #endif + n = receiveDataOnly(file_des,&adc,sizeof(adc)); + if (n < 0) { + sprintf(mess,"Error reading from socket\n"); + ret=FAIL; + } + + if (imod>=getNModBoard()) ret=FAIL; if (imod<0) @@ -2795,7 +2803,7 @@ int configure_mac(int file_des) { //#endif #ifdef MCB_FUNCS if (ret==OK) { - retval=configureMAC(ipad,imacadd,iservermacadd,digitalTestBit); + retval=configureMAC(ipad,imacadd,iservermacadd,digitalTestBit,adc); if(retval==-1) ret=FAIL; } diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 8f2afe1da..0224385e7 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -2705,13 +2705,13 @@ const char * multiSlsDetector::getSettingsFile() { } -int multiSlsDetector::configureMAC() { +int multiSlsDetector::configureMAC(int adc) { int ret=-100, ret1; for (int idet=0; idetnumberOfDetectors; idet++) { if (detectors[idet]) { - ret1=detectors[idet]->configureMAC(); + ret1=detectors[idet]->configureMAC(adc); if (ret==-100) ret=ret1; else if (ret!=ret1) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index a29d371db..c73e89511 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -888,8 +888,12 @@ class multiSlsDetector : public slsDetectorUtils { string getLastClientIP(); - - int configureMAC(); + /** + configures mac for gotthard readout + \param adc adc number + \returns OK or FAIL + */ + int configureMAC(int adc=-1); int setNumberOfModules(int i=-1, dimension d=X); int getMaxNumberOfModules(dimension d=X); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index cf2eeb51a..93f8ec6bd 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -4502,7 +4502,7 @@ char* slsDetector::setServerMAC(string serverMAC){ }; -int slsDetector::configureMAC(){ +int slsDetector::configureMAC(int adc){ int retval,i; int ret=FAIL; int fnum=F_CONFIGURE_MAC; @@ -4565,6 +4565,7 @@ int slsDetector::configureMAC(){ if (controlSocket->Connect()>=0) { controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(arg,sizeof(arg)); + controlSocket->SendDataOnly(&adc,sizeof(adc)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index f35ab3db8..4870a0ecf 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -306,8 +306,10 @@ class slsDetector : public slsDetectorUtils, public energyConversion { /** configures mac for gotthard readout + \param adc adc number + \returns OK or FAIL */ - int configureMAC(); + int configureMAC(int adc=-1); /** Reads the configuration file fname diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index aaa9850a3..8b1aa768f 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -2487,13 +2487,10 @@ string slsDetectorCommand::cmdConfigureMac(int narg, char *args[], int action) { char ans[1000]; if (action==PUT_ACTION){ - if (sscanf(args[1],"%d",&ival)) - if(ival==1){ + if (sscanf(args[1],"%d",&ival)){ myDet->setOnline(ONLINE_FLAG); - ret=myDet->configureMAC(); - } - else - return string("Not yet implemented with arguments other than 1"); + ret=myDet->configureMAC(ival); + } } else return string("Cannot get ")+cmd; @@ -2506,7 +2503,7 @@ string slsDetectorCommand::helpConfigureMac(int narg, char *args[], int action) ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) - os << "configuremac i \n configures the MAC of the detector. i=1 for configure; i=0 for unconfigure(not implemented yet)"<< std::endl; + os << "configuremac i \n configures the MAC of the detector. i is adc number. -1 for all adcs"<< std::endl; if (action==GET_ACTION || action==HELP_ACTION) os << "configuremac " << "Cannot get " << std::endl; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index db9a90f6c..dc8f9dcf3 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -473,10 +473,11 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { /** configures mac for gotthard readout + \param adc adc number \returns OK or FAIL */ - virtual int configureMAC()=0; + virtual int configureMAC(int adc=-1)=0; /** loads the modules settings/trimbits reading from a file