mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 13:27:14 +02:00
editing configuremac to include adc number
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@298 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -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)<<CHANNEL_OFFSET;
|
||||||
|
reg&=CHANNEL_MASK;
|
||||||
|
int mask =1<<adc;
|
||||||
|
reg|=(ACTIVE_ADC_MASK & mask);
|
||||||
|
bus_w(CHIP_OF_INTRST_REG,reg);
|
||||||
|
reg=bus_r(CHIP_OF_INTRST_REG);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Chip of Intrst Reg:%x\n",reg);
|
||||||
|
#endif
|
||||||
|
ipPacketSize= 256*2+14+20;
|
||||||
|
udpPacketSize=256*2+4+8+2;
|
||||||
|
break;
|
||||||
|
//for all adcs
|
||||||
|
default:
|
||||||
|
reg = (NCHAN*NCHIP)<<CHANNEL_OFFSET;
|
||||||
|
reg&=CHANNEL_MASK;
|
||||||
|
reg|=ACTIVE_ADC_MASK;
|
||||||
|
bus_w(CHIP_OF_INTRST_REG,reg);
|
||||||
|
reg=bus_r(CHIP_OF_INTRST_REG);
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("Chip of Intrst Reg:%x\n",reg);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
printf("IP Packet Size:%d\n",ipPacketSize);
|
||||||
|
printf("UDP Packet Size:%d\n",udpPacketSize);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//configuring mac
|
||||||
u_int32_t addrr=MULTI_PURPOSE_REG;
|
u_int32_t addrr=MULTI_PURPOSE_REG;
|
||||||
u_int32_t offset=ENET_CONF_REG, offset2=TSE_CONF_REG;
|
u_int32_t offset=ENET_CONF_REG, offset2=TSE_CONF_REG;
|
||||||
mac_conf *mac_conf_regs;
|
mac_conf *mac_conf_regs;
|
||||||
@ -1300,7 +1340,7 @@ int configureMAC(int ipad,long long int macad,long long int servermacad,int ival
|
|||||||
mac_conf_regs->ip.ip_ver = 0x4;
|
mac_conf_regs->ip.ip_ver = 0x4;
|
||||||
mac_conf_regs->ip.ip_ihl = 0x5;
|
mac_conf_regs->ip.ip_ihl = 0x5;
|
||||||
mac_conf_regs->ip.ip_tos = 0x0;
|
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_ident = 0x0000;
|
||||||
mac_conf_regs->ip.ip_flag = 0x2;
|
mac_conf_regs->ip.ip_flag = 0x2;
|
||||||
mac_conf_regs->ip.ip_offset = 0x00;
|
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_srcport = 0xE185;
|
||||||
mac_conf_regs->udp.udp_destport = 0xC351;
|
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;
|
mac_conf_regs->udp.udp_chksum = 0x0000;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
@ -61,7 +61,7 @@ int getTemperature(int tempSensor,int imod);
|
|||||||
int initHighVoltage(int val,int imod);
|
int initHighVoltage(int val,int imod);
|
||||||
int initConfGain(int isettings,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_int64_t getDetectorNumber();
|
||||||
u_int32_t getFirmwareVersion();
|
u_int32_t getFirmwareVersion();
|
||||||
|
@ -53,6 +53,8 @@
|
|||||||
#define FPGA_SVN_REG 0x29<<11
|
#define FPGA_SVN_REG 0x29<<11
|
||||||
|
|
||||||
|
|
||||||
|
#define CHIP_OF_INTRST_REG 0x2A<<11
|
||||||
|
|
||||||
//FIFO
|
//FIFO
|
||||||
#define LOOK_AT_ME_REG 0x28<<11
|
#define LOOK_AT_ME_REG 0x28<<11
|
||||||
|
|
||||||
@ -269,5 +271,10 @@
|
|||||||
#define SETTINGS_OFFSET 4
|
#define SETTINGS_OFFSET 4
|
||||||
|
|
||||||
|
|
||||||
|
/* CHIP_OF_INTRST_REG */
|
||||||
|
#define CHANNEL_MASK 0xffff0000
|
||||||
|
#define CHANNEL_OFFSET 16
|
||||||
|
#define ACTIVE_ADC_MASK 0x0000001f
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2759,6 +2759,7 @@ int configure_mac(int file_des) {
|
|||||||
int ipad;
|
int ipad;
|
||||||
long long int imacadd;
|
long long int imacadd;
|
||||||
long long int iservermacadd;
|
long long int iservermacadd;
|
||||||
|
int adc=-1;
|
||||||
|
|
||||||
sprintf(mess,"Can't configure MAC\n");
|
sprintf(mess,"Can't configure MAC\n");
|
||||||
|
|
||||||
@ -2785,6 +2786,13 @@ int configure_mac(int file_des) {
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
n = receiveDataOnly(file_des,&adc,sizeof(adc));
|
||||||
|
if (n < 0) {
|
||||||
|
sprintf(mess,"Error reading from socket\n");
|
||||||
|
ret=FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (imod>=getNModBoard())
|
if (imod>=getNModBoard())
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
if (imod<0)
|
if (imod<0)
|
||||||
@ -2795,7 +2803,7 @@ int configure_mac(int file_des) {
|
|||||||
//#endif
|
//#endif
|
||||||
#ifdef MCB_FUNCS
|
#ifdef MCB_FUNCS
|
||||||
if (ret==OK) {
|
if (ret==OK) {
|
||||||
retval=configureMAC(ipad,imacadd,iservermacadd,digitalTestBit);
|
retval=configureMAC(ipad,imacadd,iservermacadd,digitalTestBit,adc);
|
||||||
if(retval==-1)
|
if(retval==-1)
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
}
|
}
|
||||||
|
@ -2705,13 +2705,13 @@ const char * multiSlsDetector::getSettingsFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int multiSlsDetector::configureMAC() {
|
int multiSlsDetector::configureMAC(int adc) {
|
||||||
|
|
||||||
int ret=-100, ret1;
|
int ret=-100, ret1;
|
||||||
|
|
||||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
||||||
if (detectors[idet]) {
|
if (detectors[idet]) {
|
||||||
ret1=detectors[idet]->configureMAC();
|
ret1=detectors[idet]->configureMAC(adc);
|
||||||
if (ret==-100)
|
if (ret==-100)
|
||||||
ret=ret1;
|
ret=ret1;
|
||||||
else if (ret!=ret1)
|
else if (ret!=ret1)
|
||||||
|
@ -888,8 +888,12 @@ class multiSlsDetector : public slsDetectorUtils {
|
|||||||
|
|
||||||
string getLastClientIP();
|
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 setNumberOfModules(int i=-1, dimension d=X);
|
||||||
int getMaxNumberOfModules(dimension d=X);
|
int getMaxNumberOfModules(dimension d=X);
|
||||||
|
@ -4502,7 +4502,7 @@ char* slsDetector::setServerMAC(string serverMAC){
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::configureMAC(){
|
int slsDetector::configureMAC(int adc){
|
||||||
int retval,i;
|
int retval,i;
|
||||||
int ret=FAIL;
|
int ret=FAIL;
|
||||||
int fnum=F_CONFIGURE_MAC;
|
int fnum=F_CONFIGURE_MAC;
|
||||||
@ -4565,6 +4565,7 @@ int slsDetector::configureMAC(){
|
|||||||
if (controlSocket->Connect()>=0) {
|
if (controlSocket->Connect()>=0) {
|
||||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
controlSocket->SendDataOnly(arg,sizeof(arg));
|
controlSocket->SendDataOnly(arg,sizeof(arg));
|
||||||
|
controlSocket->SendDataOnly(&adc,sizeof(adc));
|
||||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
if (ret!=FAIL)
|
if (ret!=FAIL)
|
||||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
|
@ -306,8 +306,10 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
configures mac for gotthard readout
|
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
|
Reads the configuration file fname
|
||||||
|
@ -2487,13 +2487,10 @@ string slsDetectorCommand::cmdConfigureMac(int narg, char *args[], int action) {
|
|||||||
char ans[1000];
|
char ans[1000];
|
||||||
|
|
||||||
if (action==PUT_ACTION){
|
if (action==PUT_ACTION){
|
||||||
if (sscanf(args[1],"%d",&ival))
|
if (sscanf(args[1],"%d",&ival)){
|
||||||
if(ival==1){
|
|
||||||
myDet->setOnline(ONLINE_FLAG);
|
myDet->setOnline(ONLINE_FLAG);
|
||||||
ret=myDet->configureMAC();
|
ret=myDet->configureMAC(ival);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return string("Not yet implemented with arguments other than 1");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return string("Cannot get ")+cmd;
|
return string("Cannot get ")+cmd;
|
||||||
@ -2506,7 +2503,7 @@ string slsDetectorCommand::helpConfigureMac(int narg, char *args[], int action)
|
|||||||
|
|
||||||
ostringstream os;
|
ostringstream os;
|
||||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
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)
|
if (action==GET_ACTION || action==HELP_ACTION)
|
||||||
os << "configuremac " << "Cannot get " << std::endl;
|
os << "configuremac " << "Cannot get " << std::endl;
|
||||||
|
|
||||||
|
@ -473,10 +473,11 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
configures mac for gotthard readout
|
configures mac for gotthard readout
|
||||||
|
\param adc adc number
|
||||||
\returns OK or FAIL
|
\returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual int configureMAC()=0;
|
virtual int configureMAC(int adc=-1)=0;
|
||||||
|
|
||||||
|
|
||||||
/** loads the modules settings/trimbits reading from a file
|
/** loads the modules settings/trimbits reading from a file
|
||||||
|
Reference in New Issue
Block a user