diff --git a/slsDetectorSoftware/jungfrauDetectorServer/.gitignore b/slsDetectorSoftware/jungfrauDetectorServer/.gitignore deleted file mode 100644 index 0173208ed..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServer/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.gdb diff --git a/slsDetectorSoftware/jungfrauDetectorServer/.target-makefrag b/slsDetectorSoftware/jungfrauDetectorServer/.target-makefrag deleted file mode 100755 index ce093ecac..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServer/.target-makefrag +++ /dev/null @@ -1 +0,0 @@ -AXIS_BUILDTYPE ?= cris-axis-linux-gnu diff --git a/slsDetectorSoftware/jungfrauDetectorServer/Makefile b/slsDetectorSoftware/jungfrauDetectorServer/Makefile index 436b54b8d..8ff6779c8 100755 --- a/slsDetectorSoftware/jungfrauDetectorServer/Makefile +++ b/slsDetectorSoftware/jungfrauDetectorServer/Makefile @@ -1,57 +1,26 @@ -# $Id: Makefile,v 1.1.1.1 2006/02/04 03:35:01 freza Exp $ -# first compile -# make cris-axis-linux-gnu +CROSS = bfin-uclinux- +CC = $(CROSS)gcc +CFLAGS += -Wall -DJUNGFRAUD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE +LDLIBS += -lm -lstdc++ +PROGS = jungfrauDetectorServer +DESTDIR ?= bin +INSTMODE = 0777 -CROSS = bfin-uclinux- -CC = $(CROSS)gcc +SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c +OBJS = $(SRC_CLNT:.c=.o) + +all: clean $(PROGS) -CFLAGS += -Wall -DJUNGFRAUD -DMCB_FUNCS -DDACS_INT #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL +boot: $(OBJS) - -PROGS= jungfrauDetectorServer -INSTDIR= /tftpboot -INSTMODE= 0777 - - - -BINS = testlib_sharedlibc -SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c -OBJS = $(SRCS:%.c=%.o) - - - -all: clean $(PROGS) - -test: clean jungfrauADCTEst - -boot: $(OBJS) - -jungfrauDetectorServer: $(OBJS) - echo $(OBJS) - $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) - - -jungfrauADCTEst: $(OBJS) - echo $(OBJS) - $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) -DTESTADC - - - - -install: $(PROGS) - $(INSTALL) -d $(INSTDIR) - $(INSTALL) -m $(INSTMODE) $(PROGS) $(INSTDIR) - - -romfs: - $(ROMFSINST) /bin/$(PROGS) +$(PROGS): $(OBJS) + echo $(OBJS) + mkdir -p $(DESTDIR) + $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) + mv $(PROGS) $(DESTDIR) + rm *.gdb clean: - rm -rf $(PROGS) *.o *.gdb - - - - - - + rm -rf $(DESTDIR)/$(PROGS) *.o + diff --git a/slsDetectorSoftware/jungfrauDetectorServer/Makefile.virtual b/slsDetectorSoftware/jungfrauDetectorServer/Makefile.virtual old mode 100755 new mode 100644 index 38dd2537c..8ee348341 --- a/slsDetectorSoftware/jungfrauDetectorServer/Makefile.virtual +++ b/slsDetectorSoftware/jungfrauDetectorServer/Makefile.virtual @@ -1,30 +1,25 @@ +CC = gcc +CFLAGS += -Wall -DJUNGFRAUD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE +LDLIBS += -lm -lstdc++ -DESTDIR ?= ./ +PROGS = jungfrauDetectorServer +DESTDIR ?= bin +INSTMODE = 0777 -CC = gcc -CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DVIRTUAL - - -PROGS= $(DESTDIR)/moenchVirtualServer - - -SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c -OBJS = $(SRCS:%.c=%.o) - -moenchVirtualServer = $(PROGS) - -all: clean $(PROGS) +SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c +OBJS = $(SRC_CLNT:.c=.o) + +all: clean $(PROGS) +boot: $(OBJS) $(PROGS): $(OBJS) - $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) - + echo $(OBJS) + mkdir -p $(DESTDIR) + $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) + mv $(PROGS) $(DESTDIR) + rm *.gdb clean: - rm -rf $(PROGS) *.o *.gdb - - - - - - + rm -rf $(DESTDIR)/$(PROGS) *.o + diff --git a/slsDetectorSoftware/jungfrauDetectorServer/README.txt b/slsDetectorSoftware/jungfrauDetectorServer/README.txt deleted file mode 100644 index 7785cee12..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServer/README.txt +++ /dev/null @@ -1,11 +0,0 @@ -add the following to /etc/rc before using programfpga command before cat motd - - -#registering 7th and 9th pin to linux kernel -echo 7 > /sys/class/gpio/export -echo 9 > /sys/class/gpio/export -#define direction for the linux kernel -echo in > /sys/class/gpio/gpio7/direction -echo out > /sys/class/gpio/gpio9/direction -#needed, else all write errors when server starts up, because linux tries to take control fof gpio -echo 1 > /sys/class/gpio/gpio9/value diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/RegisterDefs.h b/slsDetectorSoftware/jungfrauDetectorServer/RegisterDefs.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServerNewStructure/RegisterDefs.h rename to slsDetectorSoftware/jungfrauDetectorServer/RegisterDefs.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/ansi.h b/slsDetectorSoftware/jungfrauDetectorServer/ansi.h index c8131b6ec..a122db0ad 120000 --- a/slsDetectorSoftware/jungfrauDetectorServer/ansi.h +++ b/slsDetectorSoftware/jungfrauDetectorServer/ansi.h @@ -1 +1 @@ -/afs/psi.ch/project/sls_det_software/dhanya_softwareDevelopment/mySoft/slsDetectorsPackage/slsReceiverSoftware/include/ansi.h \ No newline at end of file +../../slsReceiverSoftware/include/ansi.h \ No newline at end of file diff --git a/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.0.1.1 b/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.0.1.1 new file mode 100755 index 000000000..d6ccbca7b Binary files /dev/null and b/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.0.1.1 differ diff --git a/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c b/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c deleted file mode 100755 index fb1e6868f..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c +++ /dev/null @@ -1,1292 +0,0 @@ -//#define TESTADC - - -#include "server_defs.h" -#include "firmware_funcs.h" -#include "mcb_funcs.h" -#include "registers_m.h" -#include "gitInfoJungfrau.h" - - -#include -#include /* exit() */ -#include -#include /* memset(), memcpy() */ -#include -#include -#include -#include -#include -#include /* uname() */ -#include -#include /* socket(), bind(), listen(), accept() */ -#include /* fork(), write(), close() */ -#include -#include -#include -#include -#include -#include -#include - - - - -typedef struct ip_header_struct { - u_int16_t ip_len; - u_int8_t ip_tos; - u_int8_t ip_ihl:4 ,ip_ver:4; - u_int16_t ip_offset:13,ip_flag:3; - u_int16_t ip_ident; - u_int16_t ip_chksum; - u_int8_t ip_protocol; - u_int8_t ip_ttl; - u_int32_t ip_sourceip; - u_int32_t ip_destip; -} ip_header; - - -u_int32_t CSP0BASE = 0; -int highvoltage = 0; -int dacValues[NDAC]; -int32_t clkPhase[2] = {0, 0}; -char mtdvalue[10]; -int masterMode=NO_MASTER, syncMode=NO_SYNCHRONIZATION, timingMode=AUTO_TIMING; -enum externalSignalFlag signals[4]={EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF}; - - - - - - -int mapCSP0(void) { - printf("Mapping memory\n"); -#ifndef VIRTUAL - int fd; - fd = open("/dev/mem", O_RDWR | O_SYNC, 0); - if (fd == -1) { - printf("\nCan't find /dev/mem!\n"); - return FAIL; - } -#ifdef VERBOSE - printf("/dev/mem opened\n"); -#endif - CSP0BASE = (u_int32_t)mmap(0, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, CSP0); - if (CSP0BASE == (u_int32_t)MAP_FAILED) { - printf("\nCan't map memmory area!!\n"); - return FAIL; - } - printf("CSPOBASE mapped from %08x to %08x\n",CSP0BASE,CSP0BASE+MEM_SIZE); -#else - CSP0BASE = malloc(MEM_SIZE); - printf("memory allocated\n"); -#endif - printf("Status Register: %08x\n",bus_r(STATUS_REG)); - return OK; -} - - -u_int16_t bus_w16(u_int32_t offset, u_int16_t data) { - volatile u_int16_t *ptr1; - ptr1=(u_int16_t*)(CSP0BASE+offset*2); - *ptr1=data; - return OK; -} - -u_int16_t bus_r16(u_int32_t offset){ - volatile u_int16_t *ptr1; - ptr1=(u_int16_t*)(CSP0BASE+offset*2); - return *ptr1; -} - -// ramType is DARK_IMAGE_REG or GAIN_IMAGE_REG -u_int16_t ram_w16(u_int32_t ramType, int adc, int adcCh, int Ch, u_int16_t data) { - unsigned int adr = (ramType | adc << 8 | adcCh << 5 | Ch ); - return bus_w16(adr,data); -} - -// ramType is DARK_IMAGE_REG or GAIN_IMAGE_REG -u_int16_t ram_r16(u_int32_t ramType, int adc, int adcCh, int Ch){ - unsigned int adr = (ramType | adc << 8 | adcCh << 5 | Ch ); - return bus_r16(adr); -} - -u_int32_t bus_w(u_int32_t offset, u_int32_t data) { - volatile u_int32_t *ptr1; - ptr1=(u_int32_t*)(CSP0BASE+offset*2); - *ptr1=data; - return OK; -} - -u_int32_t bus_r(u_int32_t offset) { - volatile u_int32_t *ptr1; - ptr1=(u_int32_t*)(CSP0BASE+offset*2); - return *ptr1; -} - - - - -void initializeDetector(){ - printf("Initializing Detector\n"); - - //initial test - if ( (checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL) ) { - cprintf(BG_RED, "Dangerous to continue. Goodbye!\n"); - exit(-1); - } - - printf("Resetting PLL\n"); - resetPLL(); - resetCore(); - resetPeripheral(); - cleanFifos(); - - //allocating module structure for the detector in the server -#ifdef MCB_FUNCS - initDetector(); -#endif - - prepareADC(); - - // initialize dac series - initDac(0); /* todo might work without */ - initDac(8); //only for old board compatibility - - //set dacs - printf("Setting Default Dac values\n") - { - int i = 0; - int retval = -1; - const int defaultvals[NDAC] = DEFAULT_DAC_VALS; - for(i = 0; i < NDAC; ++i) { - retval = setDac(i, defaultvals[i]); - if (retval != defaultvals[i]) - cprintf(RED, "Error: Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], retval); - } - } - - bus_w(DAQ_REG, 0x0); /* Only once at server startup */ - - setClockDivider(HALF_SPEED); - cleanFifos(); /* todo might work without */ - resetCore(); /* todo might work without */ - - - //Initialization of acquistion parameters - setSettings(DEFAULT_SETTINGS,-1); - setFrames(DEFAULT_NUM_FRAMES); - setTrains(DEFAULT_NUM_CYCLES); - setExposureTime(DEFAULT_EXPTIME); - setPeriod(DEFAULT_PERIOD); - setDelay(DEFAULT_DELAY); - setHighVoltage(DEFAULT_HIGH_VOLTAGE); - -} - -int checkType() { - volatile u_int32_t type = ((bus_r(FPGA_VERSION_REG) & DETECTOR_TYPE_MSK) >> DETECTOR_TYPE_OFST); - if (type != JUNGFRAU){ - cprintf(BG_RED,"This is not a Jungfrau Server (read %d, expected %d)\n",type, JUNGFRAU); - return FAIL; - } - - - printVersions(); - - return OK; -} - -void printVersions() { - cprintf(BLUE,"\n\n" - "********************************************************\n" - "*********************Jungfrau Server********************\n" - "********************************************************\n\n" - "Firmware Version:\t 0x%llx\n" - "Software Version:\t 0x%llx\n" - //"F/w-S/w API Version:\t\t %lld\n" - //"Required Firmware Version:\t %d\n" - "********************************************************\n", - (long long unsigned int)getId(DETECTOR_FIRMWARE_VERSION), - (long long unsigned int)getId(DETECTOR_SOFTWARE_VERSION) - //,(long long unsigned int)getId(SOFTWARE_FIRMWARE_API_VERSION) - //REQUIRED_FIRMWARE_VERSION); - ); -} - - - - - - -int testFifos(void) { - printf("Fifo test not implemented!\n"); - return OK; -} - -u_int32_t testFpga(void) { - printf("\nTesting FPGA...\n"); - - //fixed pattern - int ret = OK; - volatile u_int32_t val = bus_r(FIX_PATT_REG); - if (val == FIX_PATT_VAL) { - printf("Fixed pattern: successful match 0x%08x\n",val); - } else { - cprintf(RED,"Fixed pattern does not match! Read 0x%08x, expected 0x%08x\n", val, FIX_PATT_VAL); - ret = FAIL; - } - printf("\n"); - return ret; -} - -u_int32_t testRAM(void) { - int result=OK; - printf("RAM Test not implemented!\n"); - return result; -} - -int testBus() { - printf("\nTesting Bus...\n"); - - int ret = OK; - u_int32_t addr = SET_DELAY_LSB_REG; - int times = 1000 * 1000; - int i = 0; - - for (i = 0; i < times; ++i) { - bus_w(addr, i * 100); - if (i * 100 != bus_r(SET_DELAY_LSB_REG)) { - cprintf(RED,"ERROR: Mismatch! Wrote 0x%x, read 0x%x\n", i * 100, bus_r(SET_DELAY_LSB_REG)); - ret = FAIL; - } - } - - if (ret == OK) - printf("Successfully tested bus %d times\n", times); - - printf("\n"); - return ret; -} - - - - - -u_int64_t getDetectorNumber() { - char output[255],mac[255]=""; - u_int64_t res=0; - FILE* sysFile = popen("ifconfig eth0 | grep HWaddr | cut -d \" \" -f 11", "r"); - fgets(output, sizeof(output), sysFile); - pclose(sysFile); - //getting rid of ":" - char * pch; - pch = strtok (output,":"); - while (pch != NULL){ - strcat(mac,pch); - pch = strtok (NULL, ":"); - } - sscanf(mac,"%llx",&res); - return res; -} - -u_int64_t getFirmwareVersion() { - return ((bus_r(FPGA_VERSION_REG) & BOARD_REVISION_MSK) >> BOARD_REVISION_OFST); -} - -int64_t getId(enum idMode arg) { - int64_t retval = -1; - - switch(arg){ - case DETECTOR_SERIAL_NUMBER: - retval = getDetectorNumber(); - break; - case DETECTOR_FIRMWARE_VERSION: - retval=getFirmwareSVNVersion(); - retval=(retval <<32) | getFirmwareVersion(); - break; - case DETECTOR_SOFTWARE_VERSION: - retval= SVNREV; - retval= (retval <<32) | SVNDATE; - break; - default: - printf("Required unknown id %d \n", arg); - break; - } - return retval; -} - - - - - -void defineGPIOpins(){ - //define the gpio pins - system("echo 7 > /sys/class/gpio/export"); - system("echo 9 > /sys/class/gpio/export"); - //define their direction - system("echo in > /sys/class/gpio/gpio7/direction"); - system("echo out > /sys/class/gpio/gpio9/direction"); -} - -void resetFPGA(){ - cprintf(BLUE,"\n*** Reseting FPGA ***\n"); - FPGAdontTouchFlash(); - FPGATouchFlash(); - usleep(250*1000); -} - -void FPGAdontTouchFlash(){ - //tell FPGA to not touch flash - system("echo 0 > /sys/class/gpio/gpio9/value"); - //usleep(100*1000); -} - -void FPGATouchFlash(){ - //tell FPGA to touch flash to program itself - system("echo 1 > /sys/class/gpio/gpio9/value"); -} - - -void eraseFlash(){ -#ifdef VERY_VERBOSE - printf("\n at eraseFlash \n"); -#endif - - char command[255]; - sprintf(command,"flash_eraseall %s",mtdvalue); - system(command); - printf("flash erased\n"); -} - - -int startWritingFPGAprogram(FILE** filefp){ -#ifdef VERY_VERBOSE - printf("\n at startWritingFPGAprogram \n"); -#endif - - //getting the drive - char output[255]; - FILE* fp = popen("awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd", "r"); - fgets(output, sizeof(output), fp); - pclose(fp); - strcpy(mtdvalue,"/dev/"); - char* pch = strtok(output,":"); - if(pch == NULL){ - cprintf(RED,"Could not get mtd value\n"); - return FAIL; - } - strcat(mtdvalue,pch); - printf ("\nFlash drive found: %s\n",mtdvalue); - - - FPGAdontTouchFlash(); - - //writing the program to flash - *filefp = fopen(mtdvalue, "w"); - if(*filefp == NULL){ - cprintf(RED,"Unable to open %s in write mode\n",mtdvalue); - return FAIL; - } - printf("flash ready for writing\n"); - - return OK; -} - -int stopWritingFPGAprogram(FILE* filefp){ -#ifdef VERY_VERBOSE - printf("\n at stopWritingFPGAprogram \n"); -#endif - - int wait = 0; - if(filefp!= NULL){ - fclose(filefp); - wait = 1; - } - - //touch and program - FPGATouchFlash(); - - if(wait){ -#ifdef VERY_VERBOSE - printf("Waiting for FPGA to program from flash\n"); -#endif - //waiting for success or done - char output[255]; - int res=0; - while(res == 0){ - FILE* sysFile = popen("cat /sys/class/gpio/gpio7/value", "r"); - fgets(output, sizeof(output), sysFile); - pclose(sysFile); - sscanf(output,"%d",&res); -#ifdef VERY_VERBOSE - printf("gpi07 returned %d\n",res); -#endif - } - } - printf("FPGA has picked up the program from flash\n\n"); - - - return OK; -} - -int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp){ -#ifdef VERY_VERBOSE - printf("\n at writeFPGAProgram \n"); - cprintf(BLUE,"address of fpgasrc:%p\n",(void *)fpgasrc); - cprintf(BLUE,"fsize:%d\n",fsize); - cprintf(BLUE,"pointer:%p\n",(void*)filefp); -#endif - - if(fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp )!= fsize){ - cprintf(RED,"Could not write FPGA source to flash\n"); - return FAIL; - } -#ifdef VERY_VERBOSE - cprintf(BLUE,"program written to flash\n"); -#endif - return OK; -} - - - - - - - - -long int calcChecksum(int sourceip, int destip) { - - ip_header ip; - int count; - unsigned short *addr; - long int sum = 0; - long int checksum; - ip.ip_ver = 0x4; - ip.ip_ihl = 0x5; - ip.ip_tos = 0x0; - ip.ip_len = IP_PACKETSIZE; - ip.ip_ident = 0x0000; - ip.ip_flag = 0x2; //not nibble aligned (flag& offset - ip.ip_offset = 0x000; - ip.ip_ttl = 0x40; - ip.ip_protocol = 0x11; - ip.ip_chksum = 0x0000 ; // pseudo - ip.ip_sourceip = sourceip; - ip.ip_destip = destip; - - count = sizeof(ip); - addr =& (ip); /* warning: assignment from incompatible pointer type */ - while( count > 1 ) { - sum += *addr++; - count -= 2; - } - if (count > 0) sum += *addr; // Add left-over byte, if any - while (sum>>16) sum = (sum & 0xffff) + (sum >> 16);// Fold 32-bit sum to 16 bits - checksum = (~sum) & 0xffff; - - printf("IP checksum is 0x%lx\n",checksum); - - return checksum; -} - - - -void configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, int sourceip, uint32_t destport) { - uint32_t sourceport = DEFAULT_TX_UDP_PORT; - long int checksum=calcChecksum(sourceip, destip); - - bus_w(TX_IP_REG, sourceip); - bus_w(RX_IP_REG, destip); - bus_w(RX_MAC_LSB_REG, (destmac << RX_MAC_LSB_OFST) & RX_MAC_LSB_MSK); - bus_w(RX_MAC_MSB_REG, (destmac << RX_MAC_MSB_OFST) & RX_MAC_MSB_MSK); - bus_w(TX_MAC_LSB_REG, (sourcemac << TX_MAC_LSB_OFST) & TX_MAC_LSB_MSK); - bus_w(TX_MAC_MSB_REG, (sourcemac << TX_MAC_MSB_OFST) & TX_MAC_MSB_MSK); - bus_w(UDP_PORT_REG, - ((sourceport << UDP_PORT_TX_OFST) & UDP_PORT_TX_MSK) | - ((destport << UDP_PORT_RX_OFST) & UDP_PORT_RX_MSK)); - bus_w(TX_IP_CHECKSUM_REG,(checksum << TX_IP_CHECKSUM_OFST) & TX_IP_CHECKSUM_MSK); - - cleanFifos(); - resetCore(); - - usleep(500 * 1000); /* todo maybe without */ -} - - - - - - - - -// program dacq settings - -int64_t set64BitReg(int64_t value, int aLSB, int aMSB){ - int64_t v64; - u_int32_t vLSB,vMSB; - if (value!=-1) { - vLSB=value&(0xffffffff); - bus_w(aLSB,vLSB); - v64=value>> 32; - vMSB=v64&(0xffffffff); - bus_w(aMSB,vMSB); - } - return get64BitReg(aLSB, aMSB); - -} - -int64_t get64BitReg(int aLSB, int aMSB){ - int64_t v64; - u_int32_t vLSB,vMSB; - vLSB=bus_r(aLSB); - vMSB=bus_r(aMSB); - v64=vMSB; - v64=(v64<<32) | vLSB; - - printf("reg64(%x,%x) %x %x %llx\n", aLSB, aMSB, vLSB, vMSB, v64); - - return v64; -} - -int64_t setFrames(int64_t value){ - if(value!=-1) - printf("\nSetting number of frames to %lld\n",(long long int)value); - - int64_t retval = set64BitReg(value, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG); - printf("Getting number of frames: %lld\n",(long long int)retval); - return retval; -} - -int64_t getFrames(){ - return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG); -} - -int64_t setExposureTime(int64_t value){ - if (value!=-1){ - printf("\nSetting exptime to %lldns\n",(long long int)value); - value*=(1E-3*CLK_RUN); - } - int64_t retval = set64BitReg(value,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG)/(1E-3*CLK_RUN); - printf("Getting exptime: %lldns\n",(long long int)retval); - return retval; -} - -int64_t getExposureTime(){ - return 0; -} - -int64_t setGates(int64_t value){ - return 0; -} - -int64_t getGates(){ - return 0; -} - -int64_t setDelay(int64_t value){ - if (value!=-1){ - printf("\nSetting delay to %lldns\n",(long long int)value); - value*=(1E-3*CLK_SYNC); - } - - int64_t retval = set64BitReg(value,SET_DELAY_LSB_REG, SET_DELAY_MSB_REG)/(1E-3*CLK_SYNC); - printf("Getting delay: %lldns\n",(long long int)retval); - return retval; -} - -int64_t getDelay(){ - return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG)/(1E-3*CLK_SYNC); -} - -int64_t setPeriod(int64_t value){ - if (value!=-1){ - printf("\nSetting period to %lldns\n",(long long int)value); - value*=(1E-3*CLK_SYNC); - } - - int64_t retval = set64BitReg(value,SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/(1E-3*CLK_SYNC); - printf("Getting period: %lldns\n",(long long int)retval); - return retval; -} - -int64_t getPeriod(){ - return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG)/(1E-3*CLK_SYNC); -} - -int64_t setTrains(int64_t value){ - if(value!=-1) - printf("\nSetting number of cycles to %lld\n",(long long int)value); - - int64_t retval = set64BitReg(value, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG); - printf("Getting number of cycles: %lld\n",(long long int)retval); - return retval; -} - -int64_t getTrains(){ - return get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG); -} - -int64_t setProbes(int64_t value){ - return 0; -} - -int64_t getProbes(){ - return 0; -} - - - -int64_t getActualTime(){ - return get64BitReg(TIME_FROM_START_LSB_REG, TIME_FROM_START_MSB_REG)/(1E-9*CLK_SYNC); -} - -int64_t getMeasurementTime(){ - return get64BitReg(START_FRAME_TIME_LSB_REG, START_FRAME_TIME_MSB_REG)/(1E-9*CLK_SYNC); - -} - -int64_t getFramesFromStart(){ - int64_t v1=get64BitReg(FRAMES_FROM_START_PG_LSB_REG, FRAMES_FROM_START_PG_MSB_REG); - printf("Frames from start run control %lld\n",v1); - return v1; -} - - - - - - -u_int32_t runBusy(void) { - u_int32_t s = ((bus_r(STATUS_REG) & RUN_BUSY_MSK) >> RUN_BUSY_OFST); -#ifdef VERBOSE - printf("Status Register: %08x\n", s); -#endif - return s; -} - - - - -// State Machine - -int startStateMachine(){ - printf("*******Starting State Machine*******\n"); - - cleanFifos(); - - //start state machine - bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_START_ACQ_MSK); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_START_ACQ_MSK); - - printf("Status Register: %08x\n",bus_r(STATUS_REG)); - return OK; -} - - - - -int stopStateMachine(){ - cprintf(BG_RED,"*******Stopping State Machine*******\n"); - - //stop state machine - bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STOP_ACQ_MSK); - usleep(100); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STOP_ACQ_MSK); - - printf("Status Register: %08x\n",bus_r(STATUS_REG)); - return OK; -} - - - -enum runStatus getStatus() { -#ifdef VERBOSE - printf("Getting status\n"); -#endif - - enum runStatus s; - u_int32_t retval = bus_r(STATUS_REG); - printf("Status Register: %08x\n",retval); - - //running - if(((retval & RUN_BUSY_MSK) >> RUN_BUSY_OFST)) { - if ((retval & WAITING_FOR_TRIGGER_MSK) >> WAITING_FOR_TRIGGER_OFST) { - printf("-----------------------------------WAITING-----------------------------------\n"); - s=WAITING; - } - else{ - printf("-----------------------------------RUNNING-----------------------------------\n"); - s=RUNNING; - } - } - - //not running - else { - if ((retval & STOPPED_MSK) >> STOPPED_OFST) { - printf("-----------------------------------STOPPED--------------------------\n"); - s=STOPPED; - } else if ((retval & RUNMACHINE_BUSY_MSK) >> RUNMACHINE_BUSY_OFST) { - printf("-----------------------------------READ MACHINE BUSY--------------------------\n"); - s=TRANSMITTING; - } else if (!retval) { - printf("-----------------------------------IDLE--------------------------------------\n"); - s=IDLE; - } else { - printf("-----------------------------------Unknown status %08x--------------------------------------\n", retval); - s=ERROR; - } - } - - return s; -} - - -void waitForAcquisitionEnd(){ - while(runBusy()){ - usleep(500); - } -} - - - - - - - - - - -void serializeToSPI(u_int32_t addr, u_int32_t val, u_int16_t csmask, int numbitstosend, u_int16_t clkmask, u_int16_t digoutmask, int digofset) { -#ifdef VERBOSE - if (numbitstosend == 16) - printf("Writing to ADC SPI Register: 0x%04x\n",val); - else - printf("Writing to SPI Register: 0x%08x\n", val); -#endif - - u_int16_t valw; - - // start point - valw = 0xffff; /**todo testwith old board 0xff for adc_spi */ // old board compatibility (not using specific bits) - bus_w16 (addr, valw); - - // chip sel bar down - valw &= ~csmask; /* todo with test: done a bit different, not with previous value */ - bus_w16 (addr, valw); - - { - int i = 0; - for (i = 0; i < numbitstosend; ++i) { - - // clk down - valw &= ~clkmask; - bus_w16 (addr, valw); - - // write data (i) - valw = ((valw & ~digoutmask) + // unset bit - (((val >> (numbitstosend - 1 - i)) & 0x1) << digofset)); // each bit from val starting from msb - bus_w16 (addr, valw); - - // clk up - valw |= clkmask ; - bus_w16 (addr, valw); - } - } - - // chip sel bar up - valw |= csmask; /* todo with test: not done for spi */ - bus_w16 (addr, valw); - - //clk down - valw &= ~clkmask; - bus_w16 (addr, valw); - - // stop point = start point of course - valw = 0xffff; /**todo testwith old board 0xff for adc_spi */ // old board compatibility (not using specific bits) - bus_w16 (addr, valw); - - printf("\n"); -} - - - -void initDac(int dacnum) { - printf("\n Initializing dac for %d to \n",dacnum); - - u_int32_t codata; - int csdx = dacnum / NDAC + DAC_SERIAL_CS_OUT_OFST; // old board (16 dacs),so can be DAC_SERIAL_CS_OUT_OFST or +1 - int dacchannel = 0xf; // all channels - int dacvalue = 0x6; // can be any random value (just writing to power up) - printf("Write to Input Register\n" - "Chip select bit:%d\n" - "Dac Channel:0x%x\n3" - "Dac Value:0x%x", - csdx, dacchannel, dacvalue); - - codata = LTC2620_DAC_CMD_WRITE + // command to write to input register - ((dacchannel << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) + // all channels - ((dacvalue << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK); // any random value - serializeToSPI(SPI_REG, codata, (0x1 << csdx), LTC2620_DAC_NUMBITS, - DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); -} - - -int setDac(int dacnum, int dacvalue){ - - u_int32_t codata; - int csdx = dacnum / NDAC + DAC_SERIAL_CS_OUT_OFST; // old board (16 dacs),so can be DAC_SERIAL_CS_OUT_OFST or +1 - int dacchannel = dacnum % NDAC; // 0-8, dac channel number (also for dacnum 9-15 in old board) - - if ( (dacvalue >= 0) || (dacvalue == -100)) { - printf("\n Setting of DAC %d with value %d\n",dacnum, dacvalue); - // command - if (dacvalue >= 0) { - printf("Write to Input Register and Update\n"); - codata = LTC2620_DAC_CMD_SET; - - } else if (dacvalue == -100) { - printf("POWER DOWN\n"); - codata = LTC2620_DAC_CMD_POWER_DOWN; - } - // address - printf("Chip select bit:%d\n" - "Dac Channel:0x%x\n3" - "Dac Value:0x%x", - csdx, dacchannel, dacvalue); - codata += ((dacchannel << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) + - ((dacvalue << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK); - // to spi - serializeToSPI(SPI_REG, codata, (0x1 << csdx), LTC2620_DAC_NUMBITS, - DAC_SERIAL_CLK_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_MSK, DAC_SERIAL_DIGITAL_OUT_OFST); - - dacValues[dacnum] = dacvalue; - } else - printf("\nGetting DAC %d\n",dacnum); - return dacValues[dacnum]; -} - - - -int setHighVoltage(int val, int imod){ - - u_int32_t dacvalue; - float alpha = 0.55; - // setting hv - if (val >= 0) { - // limit values - if (val < 60) { - dacvalue = 0; - val = 60; - } else if (val >= 200) { - dacvalue = 0x1; - val = 200; - } else { - dacvalue = 1. + (200.-val) / alpha; - val=200.-(dacvalue-1)*alpha; - } - printf ("\n Setting High voltage to %d (dacval %d)\n",val, dacvalue); - dacvalue &= MAX1932_HV_DATA_MSK; - serializeToSPI(SPI_REG, dacvalue, HV_SERIAL_CS_OUT_MSK, MAX1932_HV_NUMBITS, - HV_SERIAL_CLK_OUT_MSK, HV_SERIAL_DIGITAL_OUT_MSK, HV_SERIAL_DIGITAL_OUT_OFST); - highvoltage = val; - } - return highvoltage; -} - - - -void setAdc(int addr, int val) { - - u_int32_t codata; - codata = val + (addr << 8); - printf("\n Setting Adc spi register. Addr: 0x%04x Value: 0x%04x\n", addr, val); - serializeToSPI(ADC_SPI_REG, codata, ADC_SERIAL_CS_OUT_MSK, AD9257_ADC_NUMBITS, - ADC_SERIAL_CLK_OUT_MSK, ADC_SERIAL_DATA_OUT_MSK, ADC_SERIAL_DATA_OUT_OFST); -} - - - - -void prepareADC(){ - printf("Preparing ADC\n"); - - //power mode reset - setAdc(AD9257_POWER_MODE_REG, - (AD9257_INT_RESET_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK); - //power mode chip run - setAdc(AD9257_POWER_MODE_REG, - (AD9257_INT_CHIP_RUN_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK); - - //output clock phase - setAdc(AD9257_OUT_PHASE_REG, - (AD9257_OUT_CLK_60_VAL << AD9257_OUT_CLK_OFST) & AD9257_OUT_CLK_MSK); - - // lvds-iee reduced , binary offset - setAdc(AD9257_OUT_MODE_REG, - (AD9257_OUT_LVDS_IEEE_VAL << AD9257_OUT_LVDS_OPT_OFST) & AD9257_OUT_LVDS_OPT_MSK); - - // all devices on chip to receive next command - setAdc(AD9257_DEV_IND_2_REG, - AD9257_CHAN_H_MSK | AD9257_CHAN_G_MSK | AD9257_CHAN_F_MSK | AD9257_CHAN_E_MSK); - setAdc(AD9257_DEV_IND_1_REG, - AD9257_CHAN_D_MSK | AD9257_CHAN_C_MSK | AD9257_CHAN_B_MSK | AD9257_CHAN_A_MSK | - AD9257_CLK_CH_DCO_MSK | AD9257_CLK_CH_IFCO_MSK); - - // vref 1.33 - setAdc(AD9257_VREF_REG, - (AD9257_VREF_1_33_VAL << AD9257_VREF_OFST) & AD9257_VREF_MSK); - - // no test mode - setAdc(AD9257_TEST_MODE_REG, - (AD9257_NONE_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK); - -#ifdef TESTADC - printf("***************************************** *******\n"); - printf("******* PUTTING ADC IN TEST MODE!!!!!!!!! *******\n"); - printf("***************************************** *******\n"); - // mixed bit frequency test mode - setAdc(AD9257_TEST_MODE_REG, - (AD9257_MIXED_BIT_FREQ_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK); -#endif -} - - - - - - - - - -int setDynamicRange(int dr) { - return DYNAMIC_RANGE; -} - -int getDynamicRange() { - return DYNAMIC_RANGE; -} - -int getNModBoard() { - return NMOD; -} - -int setNMod(int n) { - return NMOD; -} - -int getNMod() { - return NMOD; -} - - - - - -int powerChip (int on){ - if(on != -1){ - if(on){ - printf("\nPowering on the chip\n"); - bus_w(CHIP_POWER_REG, bus_r(CHIP_POWER_REG) | CHIP_POWER_ENABLE_MSK); - } - else{ - printf("\nPowering off the chip\n"); - bus_w(CHIP_POWER_REG, bus_r(CHIP_POWER_REG) & ~CHIP_POWER_ENABLE_MSK); - } - } - return bus_r(CHIP_POWER_REG); -} - - - -void cleanFifos() { - printf("Clearing Acquisition Fifos\n"); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_ACQ_FIFO_CLR_MSK); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_ACQ_FIFO_CLR_MSK); -} - -void resetCore() { - printf("Resetting Core\n"); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_CORE_RST_MSK); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_CORE_RST_MSK); -} - -void resetPeripheral() { - printf("Resetting Peripheral\n"); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_PERIPHERAL_RST_MSK); - bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_PERIPHERAL_RST_MSK); -} - - - - -int adcPhase(int st){ /**carlos needed clkphase 1 and 2? cehck with Aldo */ - printf("\nSetting ADC Phase to %d\n",st); - if (st > 65535 || st < -65535) - return clkPhase[0]; - clkPhase[1] = st - clkPhase[0]; - - printf("phase %d\n", clkPhase[1] ); - configurePll(); - clkPhase[0] = st; - return clkPhase[0]; -} - - -int getPhase() { - return clkPhase[0]; -} - - - - - - -u_int32_t setClockDivider(int d) { - if(d!=-1){ - switch(d){ - //stop state machine if running - if(runBusy()) - stopStateMachine(); - - case FULL_SPEED://40 - printf("Setting Half Speed (20 MHz):\n"); - /**to be done*/ - - printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED); bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED); - printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED); bus_w(CONFIG_REG, CONFIG_HALF_SPEED); - printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL); - printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED); adcPhase(ADC_PHASE_HALF_SPEED); - break; - case HALF_SPEED: - printf("Setting Half Speed (20 MHz):\n"); - printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_HALF_SPEED); bus_w(SAMPLE_REG, SAMPLE_ADC_HALF_SPEED); - printf("Setting Config Reg to 0x%x\n", CONFIG_HALF_SPEED); bus_w(CONFIG_REG, CONFIG_HALF_SPEED); - printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_HALF_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL); - printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED); adcPhase(ADC_PHASE_HALF_SPEED); - break; - case QUARTER_SPEED: - printf("Setting Half Speed (10 MHz):\n"); - printf("Setting Sample Reg to 0x%x\n", SAMPLE_ADC_QUARTER_SPEED); bus_w(SAMPLE_REG, SAMPLE_ADC_QUARTER_SPEED); - printf("Setting Config Reg to 0x%x\n", CONFIG_QUARTER_SPEED); bus_w(CONFIG_REG, CONFIG_QUARTER_SPEED); - printf("Setting ADC Ofst Reg to 0x%x\n", ADC_OFST_QUARTER_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_QUARTER_SPEED_VAL); - printf("Setting ADC Phase Reg to 0x%x\n", ADC_PHASE_QUARTER_SPEED); adcPhase(ADC_PHASE_QUARTER_SPEED); - break; - } - printf("\n"); - } - return getClockDivider(); -} - - - - - - -u_int32_t getClockDivider(int ic) { - - u_int32_t val = bus_r(CONFIG_REG); - int speed = val & CONFIG_READOUT_SPEED_MSK; - switch(speed){ - case CONFIG_FULL_SPEED_40MHZ_VAL: - return FULL_SPEED; - case CONFIG_HALF_SPEED_20MHZ_VAL: - return HALF_SPEED; - case CONFIG_QUARTER_SPEED_10MHZ_VAL: - return QUARTER_SPEED; - default: - return -1; - } -} - - - - - - - - - - - - -/**carlos shouldnt exist what sort of temperatre?s tempr in reg is 1b<11 and temp pit is 1c<11 ..firmware (only 0x1c 32 bit ) Aldo.. is it connected??*/ -int getTemperature(int tempSensor, int imod){ - int val; - imod=0;//ignoring more than 1 mod for now - int i,j,repeats=6; - u_int32_t tempVal=0; -#ifdef VERBOSE - char cTempSensor[2][100]={"ADCs/ASICs","VRs/FPGAs"}; - printf("Getting Temperature of module:%d for the %s for tempsensor:%d\n",imod,cTempSensor[tempSensor],tempSensor); -#endif - bus_w(TEMP_IN_REG,(T1_CLK_BIT)|(T1_CS_BIT)|(T2_CLK_BIT)|(T2_CS_BIT));//standby - bus_w(TEMP_IN_REG,((T1_CLK_BIT)&~(T1_CS_BIT))|(T2_CLK_BIT));//high clk low cs - - for(i=0;i<20;i++) { - //repeats is number of register writes for delay - for(j=0;j>1);//fpga - } - } - - bus_w(TEMP_IN_REG,(T1_CLK_BIT)|(T1_CS_BIT)|(T2_CLK_BIT)|(T2_CS_BIT));//standby - val=((int)tempVal)/4.0; - -#ifdef VERBOSE - printf("Temperature of module:%d for the %s is %.2fC\n",imod,cTempSensor[tempSensor],val); -#endif - return val; -} - - - - - - - - - - - -void resetPLL() { - // reset PLL Reconfiguration and PLL - bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) | PLL_CTRL_RECONFIG_RST_MSK | PLL_CTRL_RST_MSK); - usleep(100); - bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) & ~PLL_CTRL_RECONFIG_RST_MSK & ~PLL_CTRL_RST_MSK); -} - - -u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val) { - - // set parameter - bus_w(PLL_PARAM_REG, val); - - // set address - bus_w(PLL_CONTROL_REG, (reg << PLL_CTRL_ADDR_OFST) & PLL_CTRL_ADDR_MSK); - usleep(10*1000); - - //write parameter - bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) | PLL_CTRL_WR_PARAMETER_MSK); - bus_w(PLL_CONTROL_REG, bus_r(PLL_CONTROL_REG) & ~PLL_CTRL_WR_PARAMETER_MSK); - usleep(10*1000); - - return val; -} - - - - - - -void configurePll() { - u_int32_t val; - int32_t phase=0, inv=0; - - printf("phase in %d\n", clkPhase[1]); - if (clkPhase[1]>0) { - inv=0; - phase=clkPhase[1]; - } else { - inv=1; - phase=-1*clkPhase[1]; - } - printf("phase out %d %08x\n", phase, phase); - - if (inv) { - val = ((phase << PLL_SHIFT_NUM_SHIFTS_OFST) & PLL_SHIFT_NUM_SHIFTS_MSK) | PLL_SHIFT_CNT_SLCT_C1_VAL | PLL_SHIFT_UP_DOWN_NEG_VAL; - printf("**************** phase word %08x\n", val); - setPllReconfigReg(PLL_PHASE_SHIFT_REG, val); - } else { - val = ((phase << PLL_SHIFT_NUM_SHIFTS_OFST) & PLL_SHIFT_NUM_SHIFTS_MSK) | PLL_SHIFT_CNT_SLCT_C0_VAL | PLL_SHIFT_UP_DOWN_NEG_VAL; - printf("**************** phase word %08x\n", val); - setPllReconfigReg(PLL_PHASE_SHIFT_REG, val); - - printf("**************** phase word %08x\n", val); - val = ((phase << PLL_SHIFT_NUM_SHIFTS_OFST) & PLL_SHIFT_NUM_SHIFTS_MSK) | PLL_SHIFT_CNT_SLCT_C2_VAL; - setPllReconfigReg(PLL_PHASE_SHIFT_REG, val); - } - usleep(10000); -} - - - - - - - - - -int loadImage(int index, short int ImageVals[]){ - printf("loadImage Not implemented yet\n"); - return OK; -} - - -int readCounterBlock(int startACQ, short int CounterVals[]){ - -//not implemented - return FAIL; -} - - - - -int resetCounterBlock(int startACQ){ - - //not implemented - return FAIL; - -} - - - -int calibratePedestal(int frames){ - //not implemented - return FAIL; -} - - - - - - - -int setTiming(int ti) { - - if(ti != GET_EXTERNAL_COMMUNICATION_MODE){ - switch((int)ti){ - case AUTO_TIMING: bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK); break; - case TRIGGER_EXPOSURE: bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK); break; - default: - cprintf(RED,"Unknown timing mode %d\n", ti); - return GET_EXTERNAL_COMMUNICATION_MODE; - } - } - if (bus_r(EXT_SIGNAL_REG) == EXT_SIGNAL_MSK) - return TRIGGER_EXPOSURE; - return AUTO_TIMING; -} - - - -int setMaster(int f) { - return NO_MASTER; -} - - - -int setSynchronization(int s) { - return NO_SYNCHRONIZATION; - -} - - diff --git a/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.h b/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.h deleted file mode 100755 index 4508391a3..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef FIRMWARE_FUNCS_H -#define FIRMWARE_FUNCS_H -#include "sls_detector_defs.h" - -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include - -int mapCSP0(void); -u_int16_t bus_w16(u_int32_t offset, u_int16_t data); -u_int16_t bus_r16(u_int32_t offset); -u_int16_t ram_w16(u_int32_t ramType, int adc, int adcCh, int Ch, u_int16_t data); -u_int16_t ram_r16(u_int32_t ramType, int adc, int adcCh, int Ch); -u_int32_t bus_w(u_int32_t offset, u_int32_t data); -u_int32_t bus_r(u_int32_t offset); - -void initializeDetector(); -int checkType(); -void printVersions(); - -int testFifos(void); -u_int32_t testFpga(void); -u_int32_t testRAM(void); -int testBus(void); - -u_int64_t getDetectorNumber(); -u_int64_t getFirmwareVersion(); -int64_t getId(enum idMode arg); - -void defineGPIOpins(); -void resetFPGA(); -void FPGAdontTouchFlash(); -void FPGATouchFlash(); -void eraseFlash(); -int startWritingFPGAprogram(FILE** filefp); -int stopWritingFPGAprogram(FILE* filefp); -int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp); - -long int calcChecksum(int sourceip, int destip); -void configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, int sourceip, uint32_t destport); - -int64_t set64BitReg(int64_t value, int aLSB, int aMSB); -int64_t get64BitReg(int aLSB, int aMSB); - -int64_t setFrames(int64_t value); -int64_t getFrames(); - -int64_t setExposureTime(int64_t value); -int64_t getExposureTime(); - -int64_t setGates(int64_t value); -int64_t getGates(); - -int64_t setDelay(int64_t value); -int64_t getDelay(); - -int64_t setPeriod(int64_t value); -int64_t getPeriod(); - -int64_t setTrains(int64_t value); -int64_t getTrains(); - -int64_t setProbes(int64_t value); -int64_t getProbes(); - -int64_t getActualTime(); -int64_t getMeasurementTime(); -int64_t getFramesFromStart(); - -u_int32_t runBusy(void); -int startStateMachine(); -int stopStateMachine(); -enum runStatus getStatus(); -void waitForAcquisitionEnd(); - -void serializeToSPI(u_int32_t addr, u_int32_t val, u_int16_t csmask, int numbitstosend, u_int16_t clkmask, u_int16_t digoutmask, int digofset); -void initDac(int dacnum); -int setDac(int dacnum, int dacvalue); -int setHighVoltage(int val, int imod); -void setAdc(int addr, int val); -void prepareADC(); - -int setDynamicRange(int dr); -int getDynamicRange(); -int getNModBoard(); -int setNMod(int n); -int getNMod(); - -int powerChip (int on); -void cleanFifos(); -void resetCore(); -void resetPeripheral(); -int adcPhase(int st); -int getPhase(); - -u_int32_t setClockDivider(int d); -u_int32_t getClockDivider(); - -int getTemperature(int tempSensor,int imod); -int initConfGain(int isettings,int val,int imod); -int initSpeedConfGain(int val); - -void resetPLL(); -u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val); -void configurePll(); - -int loadImage(int index, short int ImageVals[]); -int readCounterBlock(int startACQ, short int CounterVals[]); -int resetCounterBlock(int startACQ); -int calibratePedestal(int frames); - -int setTiming(int t); -int setMaster(int f); -int setSynchronization(int s); - -#endif diff --git a/slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServerv3.0.0.1 b/slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServerv3.0.0.1 deleted file mode 100755 index ba692a1ba..000000000 Binary files a/slsDetectorSoftware/jungfrauDetectorServer/jungfrauDetectorServerv3.0.0.1 and /dev/null differ diff --git a/slsDetectorSoftware/jungfrauDetectorServer/mcb_funcs.c b/slsDetectorSoftware/jungfrauDetectorServer/mcb_funcs.c deleted file mode 100755 index 158ca2cba..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServer/mcb_funcs.c +++ /dev/null @@ -1,323 +0,0 @@ -#ifdef MCB_FUNCS - -#include "registers_m.h" -#include "server_defs.h" -#include "firmware_funcs.h" -#include "mcb_funcs.h" - -#include -#include -#include -#include -#include - -/* global variables */ - - - -enum detectorSettings thisSettings; - -int sChan, sChip, sMod, sDac, sAdc; -const int allSelected=-2; -const int noneSelected=-1; - -sls_detector_module *detectorModules=NULL; -int *detectorChips=NULL; -int *detectorChans=NULL; -int *detectorDacs=NULL; -int *detectorAdcs=NULL; - - - -int initDetector() { - int imod; - int n=getNModBoard(); -#ifdef VERBOSE - printf("Board is for %d modules\n",n); -#endif - detectorModules=malloc(n*sizeof(sls_detector_module)); - detectorDacs=malloc(n*NDAC*sizeof(int)); - detectorAdcs=malloc(n*NADC*sizeof(int)); - detectorChips=NULL; - detectorChans=NULL; - detectorAdcs=NULL; -#ifdef VERBOSE - printf("modules from 0x%x to 0x%x\n",(unsigned int)(detectorModules), (unsigned int)(detectorModules+n)); - printf("dacs from 0x%x to 0x%x\n",(unsigned int)(detectorDacs), (unsigned int)(detectorDacs+n*NDAC)); - printf("adcs from 0x%x to 0x%x\n",(unsigned int)(detectorAdcs), (unsigned int)(detectorAdcs+n*NADC)); -#endif - - - for (imod=0; imoddacs=detectorDacs+imod*NDAC; - (detectorModules+imod)->adcs=detectorAdcs+imod*NADC; - (detectorModules+imod)->ndac=NDAC; - (detectorModules+imod)->nadc=NADC; - (detectorModules+imod)->nchip=NCHIP; - (detectorModules+imod)->nchan=NCHIP*NCHAN; - (detectorModules+imod)->module=imod; - (detectorModules+imod)->gain=0; - (detectorModules+imod)->offset=0; - (detectorModules+imod)->reg=0; - } - thisSettings=UNINITIALIZED; - sChan=noneSelected; - sChip=noneSelected; - sMod=noneSelected; - sDac=noneSelected; - sAdc=noneSelected; - - return OK; -} - - - - - -int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) { - - int idac, iadc; - - int ret=OK; - -#ifdef VERBOSE - printf("Copying module %x to module %x\n",(unsigned int)(srcMod),(unsigned int)(destMod)); -#endif - - if (srcMod->module>=0) { -#ifdef VERBOSE - printf("Copying module number %d to module number %d\n",srcMod->module,destMod->module); -#endif - destMod->module=srcMod->module; - } - if (srcMod->serialnumber>=0){ -/* #ifdef VERBOSE */ -/* printf("Copying module serial number %x to module serial number %x\n",srcMod->serialnumber,destMod->serialnumber); */ -/* #endif */ - destMod->serialnumber=srcMod->serialnumber; - } - - /* - if ((srcMod->nchip)>(destMod->nchip)) { - printf("Number of chip of source is larger than number of chips of destination\n"); - return FAIL; - } - if ((srcMod->nchan)>(destMod->nchan)) { - printf("Number of channels of source is larger than number of channels of destination\n"); - return FAIL; - } - */ - - if ((srcMod->ndac)>(destMod->ndac)) { - printf("Number of dacs of source is larger than number of dacs of destination\n"); - return FAIL; - } - if ((srcMod->nadc)>(destMod->nadc)) { - printf("Number of dacs of source is larger than number of dacs of destination\n"); - return FAIL; - } - -#ifdef VERBOSE - printf("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac); - printf("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc); - //printf("Chips: src %d, dest %d\n",srcMod->nchip,destMod->nchip); - //printf("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan); - -#endif - - - - destMod->ndac=srcMod->ndac; - destMod->nadc=srcMod->nadc; - // destMod->nchip=srcMod->nchip; - //destMod->nchan=srcMod->nchan; - if (srcMod->reg>=0) - destMod->reg=srcMod->reg; -#ifdef VERBOSE - printf("Copying register %x (%x)\n",destMod->reg,srcMod->reg ); -#endif - if (srcMod->gain>=0) - destMod->gain=srcMod->gain; - if (srcMod->offset>=0) - destMod->offset=srcMod->offset; - - // printf("copying gain and offset %f %f to %f %f\n",srcMod->gain,srcMod->offset,destMod->gain,destMod->offset); - - - for (idac=0; idac<(srcMod->ndac); idac++) { - if (*((srcMod->dacs)+idac)>=0) - *((destMod->dacs)+idac)=*((srcMod->dacs)+idac); - } - - for (iadc=0; iadc<(srcMod->nadc); iadc++) { - if (*((srcMod->adcs)+iadc)>=0) - *((destMod->adcs)+iadc)=*((srcMod->adcs)+iadc); - } - - return ret; -} - - - - - - - -int setSettings(int i, int imod) { -//#ifdef VERBOSE - if(i!=-1) - printf("\nSetting settings wit value %d\n",i); -//#endif - int isett=-1,val=-1,retval=-1; - enum conf_gain { - dynamic = 0x0f00, //dynamic - dynamichighgain0 = v, //dynamichighgain0 - fixgain1 = 0x0f02, //fixgain1 - fixgain2 = 0x0f06, //fixgain2 - forceswitchgain1 = 0x1f00, //forceswitchgain1 - forceswitchgain2 = 0x3f00 //forceswitchgain2 - }; - - //determine conf value to write - if(i!=GET_SETTINGS){ - switch(i){ - case DYNAMICGAIN: val = dynamic; break; - case DYNAMICHG0: val = dynamichighgain0; break; - case FIXGAIN1: val = fixgain1; break; - case FIXGAIN2: val = fixgain2; break; - case FORCESWITCHG1: val = forceswitchgain1; break; - case FORCESWITCHG2: val = forceswitchgain2; break; - default: - printf("Error: This settings is not defined for this detector %d\n",i); - return GET_SETTINGS; - } - } - - retval = initConfGain(i,val,imod); - - switch(retval){ - case dynamic: isett=DYNAMICGAIN; break; - case dynamichighgain0: isett=DYNAMICHG0; break; - case fixgain1: isett=FIXGAIN1; break; - case fixgain2: isett=FIXGAIN2; break; - case forceswitchgain1: isett=FORCESWITCHG1; break; - case forceswitchgain2: isett=FORCESWITCHG2; break; - default: - isett=UNDEFINED; - printf("Error:Wrong settings read out from Gain Reg 0x%x\n",retval); - break; - } - - thisSettings=isett; -//#ifdef VERBOSE - printf("detector settings are %d\n",thisSettings); -//#endif - return thisSettings; -} - - - - - - - -/* Initialization*/ - - - -int initModulebyNumber(sls_detector_module myMod) { - printf("\nInitializing Module\n"); - int nchip,nchan;//int ichip, nchip, ichan, nchan; - int im, modmi,modma; - // int ft, cae, ae, coe, ocoe, counts, chanreg; - int imod; - // int obe; - // int ow; - /* int v[NDAC];*/ - int retval =-1, idac; - - - nchip=myMod.nchip; - nchan=(myMod.nchan)/nchip; - imod=myMod.module; - sMod=imod; - if (sMod==ALLMOD) - sMod=allSelected; - if (sMod==allSelected) { - modmi=0; - modma=NMODX;//getNModBoard(); - } else if (sMod==noneSelected || sMod>NMODX || sMod<0) {// (sMod==noneSelected || sMod>getNModBoard() || sMod<0) { - modmi=0; - modma=-1; - } else { - modmi=sMod; - modma=sMod+1; - } - - //printf("ndac:%d\n",NDAC); - - for (idac=0; idacmodule; -#ifdef VERBOSE - printf("Getting module %d\n",imod); -#endif - if (detectorModules) { - copyModule(myMod,detectorModules+imod); - ; - } else - return FAIL; - - return OK; -} - - - - - - - -// Fifo continuous read - - -int getModuleNumber(int modnum) { - int val = 0xfff; - // val=readin(modnum); - return val; -} - - - - - - - - - - -#endif - - diff --git a/slsDetectorSoftware/jungfrauDetectorServer/mcb_funcs.h b/slsDetectorSoftware/jungfrauDetectorServer/mcb_funcs.h deleted file mode 100755 index b4eca93c5..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServer/mcb_funcs.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifdef MCB_FUNCS - -#ifndef MCB_FUNCS_H -#define MCB_FUNCS_H - -#include "sls_detector_defs.h" - -int initDetector(); -int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod); -int setSettings(int i,int imod); -int initModulebyNumber(sls_detector_module); -int getModulebyNumber(sls_detector_module*); -int getModuleNumber(int modnum); - -#endif - -#endif diff --git a/slsDetectorSoftware/jungfrauDetectorServer/registers_m.h b/slsDetectorSoftware/jungfrauDetectorServer/registers_m.h deleted file mode 100755 index 5bec80984..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServer/registers_m.h +++ /dev/null @@ -1,360 +0,0 @@ -#ifndef REGISTERS_G_H -#define REGISTERS_G_H - - -#include "sls_detector_defs.h" - - -/* Definitions for FPGA*/ -#define CSP0 0x20200000 -#define MEM_SIZE 0x100000 - -/* FPGA Version register */ -#define FPGA_VERSION_REG (0x00 << 11) - -#define BOARD_REVISION_OFST (0) -#define BOARD_REVISION_MSK (0x00FFFFFF << BOARD_REVISION_OFST) -#define DETECTOR_TYPE_OFST (24) -#define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST) - - - -/* Fix pattern register */ -#define FIX_PATT_REG (0x01 << 11) - -/* Status register */ -#define STATUS_REG (0x02 << 11) - -#define RUN_BUSY_OFST (0) -#define RUN_BUSY_MSK (0x00000001 << RUN_BUSY_OFST) -#define WAITING_FOR_TRIGGER_OFST (3) -#define WAITING_FOR_TRIGGER_MSK (0x00000001 << WAITING_FOR_TRIGGER_OFST) -#define DELAYBEFORE_OFST (4) //Not used in software -#define DELAYBEFORE_MSK (0x00000001 << DELAYBEFORE_OFST) //Not used in software -#define DELAYAFTER_OFST (5) //Not used in software -#define DELAYAFTER_MSK (0x00000001 << DELAYAFTER_OFST) //Not used in software -#define STOPPED_OFST (15) -#define STOPPED_MSK (0x00000001 << STOPPED_OFST) -#define RUNMACHINE_BUSY_OFST (17) -#define RUNMACHINE_BUSY_MSK (0x00000001 << RUNMACHINE_BUSY_OFST) - - -/* Look at me register */ -#define LOOK_AT_ME_REG (0x03 << 11) //Not used in firmware or software - -/* System Status register */ -#define SYSTEM_STATUS_REG (0x04 << 11) //Not used in software - -#define DDR3_CAL_DONE_OFST (0) //Not used in software -#define DDR3_CAL_DONE_MSK (0x00000001 << DDR3_CAL_DONE_OFST) //Not used in software -#define DDR3_CAL_FAIL_OFST (1) //Not used in software -#define DDR3_CAL_FAIL_MSK (0x00000001 << DDR3_CAL_FAIL_OFST) //Not used in software -#define DDR3_INIT_DONE_OFST (2) //Not used in software -#define DDR3_INIT_DONE_MSK (0x00000001 << DDR3_INIT_DONE_OFST) //Not used in software -#define RECONFIG_PLL_LCK_OFST (3) //Not used in software -#define RECONFIG_PLL_LCK_MSK (0x00000001 << RECONFIG_PLL_LCK_OFST) //Not used in software -#define PLL_A_LCK_OFST (4) //Not used in software -#define PLL_A_LCK_MSK (0x00000001 << PLL_A_LCK_OFST) //Not used in software -#define DD3_PLL_LCK_OFST (5) //Not used in software -#define DD3_PLL_LCK_MSK (0x00000001 << DD3_PLL_LCK_OFST) //Not used in software - - -/* Module Control Board Serial Number Register */ -#define MOD_SERIAL_NUM_REG (0x0A << 11) //Not used in software - -#define HARDWARE_SERIAL_NUM_OFST (0) //Not used in software -#define HARDWARE_SERIAL_NUM_MSK (0x000000FF << HARDWARE_SERIAL_NUM_OFST) //Not used in software -#define HARDWARE_VERSION_NUM_OFST (16) //Not used in software -#define HARDWARE_VERSION_NUM_MSK (0x0000003F << HARDWARE_VERSION_NUM_OFST) //Not used in software - - -/* Time from Start 64 bit register */ -#define TIME_FROM_START_LSB_REG (0x10 << 11) -#define TIME_FROM_START_MSB_REG (0x11 << 11) - -/* Get Delay 64 bit register */ -#define GET_DELAY_LSB_REG (0x12 << 11) -#define GET_DELAY_MSB_REG (0x13 << 11) - -/* Get Cycles 64 bit register */ -#define GET_CYCLES_LSB_REG (0x14 << 11) -#define GET_CYCLES_MSB_REG (0x15 << 11) - -/* Get Frames 64 bit register */ -#define GET_FRAMES_LSB_REG (0x16 << 11) -#define GET_FRAMES_MSB_REG (0x17 << 11) - -/* Get Period 64 bit register */ -#define GET_PERIOD_LSB_REG (0x18 << 11) -#define GET_PERIOD_MSB_REG (0x19 << 11) - -/* Get Period 64 bit register */ -#define GET_EXPTIME_LSB_REG (0x1A << 11) -#define GET_EXPTIME_MSB_REG (0x1B << 11) - -/* Get Period 64 bit register */ -#define GET_GATES_LSB_REG (0x1C << 11) -#define GET_GATES_MSB_REG (0x1D << 11) - -/* Get Frames from Start 64 bit register (frames from start Run Control) */ -#define FRAMES_FROM_START_PG_LSB_REG (0x24 << 11) -#define FRAMES_FROM_START_PG_MSB_REG (0x25 << 11) - -/* Measurement Time 64 bit register (timestamp at a frame start until reset)*/ -#define START_FRAME_TIME_LSB_REG (0x26 << 11) -#define START_FRAME_TIME_MSB_REG (0x27 << 11) - -/* SPI (Serial Peripheral Interface) Register */ -#define SPI_REG (0x40 << 11) - -#define DAC_SERIAL_DIGITAL_OUT_OFST (0) -#define DAC_SERIAL_DIGITAL_OUT_MSK (0x00000001 << DAC_SERIAL_DIGITAL_OUT_OFST) -#define DAC_SERIAL_CLK_OUT_OFST (1) -#define DAC_SERIAL_CLK_OUT_MSK (0x00000001 << DAC_SERIAL_CLK_OUT_OFST) -#define DAC_SERIAL_CS_OUT_OFST (2) -#define DAC_SERIAL_CS_OUT_MSK (0x00000001 << DAC_SERIAL_CS_OUT_OFST) -#define HV_SERIAL_DIGITAL_OUT_OFST (8) -#define HV_SERIAL_DIGITAL_OUT_MSK (0x00000001 << HV_SERIAL_DIGITAL_OUT_OFST) -#define HV_SERIAL_CLK_OUT_OFST (9) -#define HV_SERIAL_CLK_OUT_MSK (0x00000001 << HV_SERIAL_CLK_OUT_OFST) -#define HV_SERIAL_CS_OUT_OFST (10) -#define HV_SERIAL_CS_OUT_MSK (0x00000001 << HV_SERIAL_CS_OUT_OFST) - - -/* ADC SPI (Serial Peripheral Interface) Register */ -#define ADC_SPI_REG (0x41 << 11) - -#define ADC_SERIAL_CLK_OUT_OFST (0) -#define ADC_SERIAL_CLK_OUT_MSK (0x00000001 << ADC_SERIAL_CLK_OUT_OFST) -#define ADC_SERIAL_DATA_OUT_OFST (1) -#define ADC_SERIAL_DATA_OUT_MSK (0x00000001 << ADC_SERIAL_DATA_OUT_OFST) -#define ADC_SERIAL_CS_OUT_OFST (2) -#define ADC_SERIAL_CS_OUT_MSK (0x0000000F << ADC_SERIAL_CS_OUT_OFST) - -/* ADC offset Register */ -#define ADC_OFST_REG (0x42 << 11) - -/* ADC Port Invert Register */ -#define ADC_PORT_INVERT_REG (0x43 << 11) - -/* Receiver IP Address Register */ -#define RX_IP_REG (0x45 << 11) - -/* UDP Port */ -#define UDP_PORT_REG (0x46 << 11) - -#define UDP_PORT_RX_OFST (0) -#define UDP_PORT_RX_MSK (0x0000FFFF << UDP_PORT_RX_OFST) -#define UDP_PORT_TX_OFST (16) -#define UDP_PORT_TX_MSK (0x0000FFFF << UDP_PORT_TX_OFST) - -/* Receiver Mac Address 64 bit Register */ -#define RX_MAC_LSB_REG (0x47 << 11) -#define RX_MAC_MSB_REG (0x48 << 11) - -#define RX_MAC_LSB_OFST (0) -#define RX_MAC_LSB_MSK (0x0000FFFF << RX_MAC_LSB_OFST) -#define RX_MAC_MSB_OFST (0) -#define RX_MAC_MSB_MSK (0x000000FF << RX_MAC_MSB_OFST) - -/* Detector/ Transmitter Mac Address 64 bit Register */ -#define TX_MAC_LSB_REG (0x49 << 11) -#define TX_MAC_MSB_REG (0x4A << 11) - -#define TX_MAC_LSB_OFST (0) -#define TX_MAC_LSB_MSK (0x0000FFFF << TX_MAC_LSB_OFST) -#define TX_MAC_MSB_OFST (0) -#define TX_MAC_MSB_MSK (0x000000FF << TX_MAC_MSB_OFST) - -/* Detector/ Transmitter IP Address Register */ -#define TX_IP_REG (0x4B << 11) - -/* Detector/ Transmitter IP Checksum Register */ -#define TX_IP_CHECKSUM_REG (0x4C << 11) - -#define TX_IP_CHECKSUM_OFST (0) -#define TX_IP_CHECKSUM_MSK (0x000000FF << TX_IP_CHECKSUM_OFST) - -/* Configuration Register */ -#define CONFIG_REG (0x4D << 11) - -#define CONFIG_OPERATION_MODE_OFST (16) -#define CONFIG_OPERATION_MODE_MSK (0x00000001 << CONFIG_OPERATION_MODE_OFST) -#define CONFIG_MODE_1_X_10GBE_VAL ((0x0 << CONFIG_OPERATION_MODE_OFST) & CONFIG_OPERATION_MODE_MSK) -#define CONFIG_MODE_2_X_10GBE_VAL ((0x1 << CONFIG_OPERATION_MODE_OFST) & CONFIG_OPERATION_MODE_MSK) -#define CONFIG_READOUT_SPEED_OFST (20) -#define CONFIG_READOUT_SPEED_MSK (0x00000003 << CONFIG_READOUT_SPEED_OFST) -#define CONFIG_QUARTER_SPEED_10MHZ_VAL ((0x0 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK) -#define CONFIG_HALF_SPEED_20MHZ_VAL ((0x1 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK) -#define CONFIG_FULL_SPEED_VAL ((0x2 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK) -#define CONFIG_TDMA_OFST (24) -#define CONFIG_TDMA_MSK (0x00000001 << CONFIG_TDMA_OFST) -#define CONFIG_TDMA_DISABLE_VAL ((0x0 << CONFIG_TDMA_OFST) & CONFIG_TDMA_MSK) -#define CONFIG_TDMA_ENABLE_VAL ((0x1 << CONFIG_TDMA_OFST) & CONFIG_TDMA_MSK) -#define CONFIG_TDMA_TIMESLOT_OFST (25) -#define CONFIG_TDMA_TIMESLOT_MSK (0x0000001F << CONFIG_TDMA_TIMESLOT_OFST) -#define CONFIG_TDMA_TIMESLOT_0_VAL ((0x0 << CONFIG_TDMA_TIMESLOT_OFST) & CONFIG_TDMA_TIMESLOT_MSK) - -/* External Signal Register */ -#define EXT_SIGNAL_REG (0x4E << 11) - -#define EXT_SIGNAL_OFST (0) -#define EXT_SIGNAL_MSK (0x00000003 << EXT_SIGNAL_OFST) //enabled when both bits high - -/* Control Register */ -#define CONTROL_REG (0x4F << 11) - -#define CONTROL_START_ACQ_OFST (0) -#define CONTROL_START_ACQ_MSK (0x00000001 << CONTROL_START_ACQ_OFST) -#define CONTROL_STOP_ACQ_OFST (1) -#define CONTROL_STOP_ACQ_MSK (0x00000001 << CONTROL_STOP_ACQ_OFST) -#define CONTROL_CORE_RST_OFST (10) -#define CONTROL_CORE_RST_MSK (0x00000001 << CONTROL_CORE_RST_OFST) -#define CONTROL_PERIPHERAL_RST_OFST (11) //DDR3 HMem Ctrlr, GBE, Temp -#define CONTROL_PERIPHERAL_RST_MSK (0x00000001 << CONTROL_PERIPHERAL_RST_OFST) //DDR3 HMem Ctrlr, GBE, Temp -#define CONTROL_DDR3_MEM_RST_OFST (12) //only PHY, not DDR3 PLL ,Not used in software -#define CONTROL_DDR3_MEM_RST_MSK (0x00000001 << CONTROL_DDR3_MEM_RST_OFST) //only PHY, not DDR3 PLL ,Not used in software -#define CONTROL_ACQ_FIFO_CLR_OFST (14) -#define CONTROL_ACQ_FIFO_CLR_MSK (0x00000001 << CONTROL_ACQ_FIFO_CLR_OFST) - -/* Reconfiguratble PLL Paramater Register */ -#define PLL_PARAM_REG (0x50 << 11) - -/* Reconfiguratble PLL Control Regiser */ -#define PLL_CONTROL_REG (0x51 << 11) - -#define PLL_CTRL_RECONFIG_RST_OFST (0) //parameter reset -#define PLL_CTRL_RECONFIG_RST_MSK (0x00000001 << PLL_CTRL_RECONFIG_RST_OFST) //parameter reset -#define PLL_CTRL_WR_PARAMETER_OFST (2) -#define PLL_CTRL_WR_PARAMETER_MSK (0x00000001 << PLL_CTRL_WR_PARAMETER_OFST) -#define PLL_CTRL_RST_OFST (3) -#define PLL_CTRL_RST_MSK (0x00000001 << PLL_CTRL_RST_OFST) -#define PLL_CTRL_ADDR_OFST (16) -#define PLL_CTRL_ADDR_MSK (0x0000003F << PLL_CTRL_ADDR_OFST) - -/* Sample Register (Obsolete) */ -#define SAMPLE_REG (0x59 << 11) /** carlos set speed differently*/ - -#define SAMPLE_ADC_SAMPLE_SEL_OFST (0) /** carlos cant use the bits*/ -#define SAMPLE_ADC_SAMPLE_SEL_MSK (0x00000007 << SAMPLE_ADC_SAMPLE_SEL_OFST) -#define SAMPLE_ADC_SAMPLE_0_VAL ((0x0 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK) -#define SAMPLE_ADC_SAMPLE_1_VAL ((0x1 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK) -#define SAMPLE_ADC_SAMPLE_2_VAL ((0x2 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK) -#define SAMPLE_ADC_SAMPLE_3_VAL ((0x3 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK) -#define SAMPLE_ADC_SAMPLE_4_VAL ((0x4 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK) -#define SAMPLE_ADC_SAMPLE_5_VAL ((0x5 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK) -#define SAMPLE_ADC_SAMPLE_6_VAL ((0x6 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK) -#define SAMPLE_ADC_SAMPLE_7_VAL ((0x7 << SAMPLE_ADC_SAMPLE_SEL_OFST) & SAMPLE_ADC_SAMPLE_SEL_MSK) - -#define SAMPLE_ADC_DECMT_FACTOR_OFST (4) -#define SAMPLE_ADC_DECMT_FACTOR_MSK (0x00000007 << SAMPLE_ADC_DECMT_FACTOR_OFST) -#define SAMPLE_ADC_DECMT_FACTOR_0_VAL ((0x0 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK) -#define SAMPLE_ADC_DECMT_FACTOR_1_VAL ((0x1 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK) -#define SAMPLE_ADC_DECMT_FACTOR_2_VAL ((0x2 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK) -#define SAMPLE_ADC_DECMT_FACTOR_3_VAL ((0x3 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK) -#define SAMPLE_ADC_DECMT_FACTOR_4_VAL ((0x4 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK) -#define SAMPLE_ADC_DECMT_FACTOR_5_VAL ((0x5 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK) -#define SAMPLE_ADC_DECMT_FACTOR_6_VAL ((0x6 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK) -#define SAMPLE_ADC_DECMT_FACTOR_7_VAL ((0x7 << SAMPLE_ADC_DECMT_FACTOR_OFST) & SAMPLE_ADC_DECMT_FACTOR_MSK) - -#define SAMPLE_DGTL_SAMPLE_SEL_OFST (8) -#define SAMPLE_DGTL_SAMPLE_SEL_MSK (0x0000000F << SAMPLE_DGTL_SAMPLE_SEL_OFST) -#define SAMPLE_DGTL_SAMPLE_0_VAL ((0x0 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_1_VAL ((0x1 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_2_VAL ((0x2 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_3_VAL ((0x3 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_4_VAL ((0x4 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_5_VAL ((0x5 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_6_VAL ((0x6 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_7_VAL ((0x7 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_8_VAL ((0x8 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_9_VAL ((0x9 << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_10_VAL ((0xa << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_11_VAL ((0xb << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_12_VAL ((0xc << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_13_VAL ((0xd << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_14_VAL ((0xe << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) -#define SAMPLE_DGTL_SAMPLE_15_VAL ((0xf << SAMPLE_DGTL_SAMPLE_SEL_OFST) & SAMPLE_DGTL_SAMPLE_SEL_MSK) - -#define SAMPLE_DGTL_DECMT_FACTOR_OFST (12) -#define SAMPLE_DGTL_DECMT_FACTOR_MSK (0x00000003 << SAMPLE_DGTL_DECMT_FACTOR_OFST) -#define SAMPLE_DECMT_FACTOR_1_VAL ((0x0 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK) -#define SAMPLE_DECMT_FACTOR_2_VAL ((0x1 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK) -#define SAMPLE_DECMT_FACTOR_4_VAL ((0x2 << SAMPLE_DGTL_DECMT_FACTOR_OFST) & SAMPLE_DGTL_DECMT_FACTOR_MSK) - -/** Vref Comp Mod Register */ -#define VREF_COMP_MOD_REG (0x5C << 11) //Not used in software, TBD in firmware - -/** DAQ Register */ -#define DAQ_REG (0x5D << 11) //TBD in firmware - -/** carlos ?? */ -/* settings/conf gain register */ -#define GAIN_MASK 0x0000ffff -#define GAIN_OFFSET 0 -#define SPEED_GAIN_MASK 0xf0000000 -#define SPEED_GAIN_OFFSET 28 -/***************/ - -/** Chip Power Register */ -#define CHIP_POWER_REG (0x5E << 11) - -#define CHIP_POWER_ENABLE_OFST (0) -#define CHIP_POWER_ENABLE_MSK (0x00000001 << CHIP_POWER_ENABLE_OFST) - -/* Set Delay 64 bit register */ -#define SET_DELAY_LSB_REG (0x60 << 11) -#define SET_DELAY_MSB_REG (0x61 << 11) - -/* Set Cycles 64 bit register */ -#define SET_CYCLES_LSB_REG (0x62 << 11) -#define SET_CYCLES_MSB_REG (0x63 << 11) - -/* Set Frames 64 bit register */ -#define SET_FRAMES_LSB_REG (0x64 << 11) -#define SET_FRAMES_MSB_REG (0x65 << 11) - -/* Set Period 64 bit register */ -#define SET_PERIOD_LSB_REG (0x66 << 11) -#define SET_PERIOD_MSB_REG (0x67 << 11) - -/* Set Period 64 bit register */ -#define SET_EXPTIME_LSB_REG (0x68 << 11) -#define SET_EXPTIME_MSB_REG (0x69 << 11) - -/* Module Coordinates Register 0 */ -#define COORD_0 (0x7C << 11) - -#define COORD_0_Y_OFST (0) -#define COORD_0_Y_MSK (0x0000FFFF << COORD_0_Y_OFST) -#define COORD_0_X_OFST (16) -#define COORD_0_X_MSK (0x0000FFFF << COORD_0_X_OFST) - -/* Module Coordinates Register 1 */ -#define COORD_1 (0x7D << 11) - -#define COORD_0_Z_OFST (0) -#define COORD_0_Z_MSK (0x0000FFFF << COORD_0_Z_OFST) - - - - - - - - - - -/**carlos */ -#define SET_GATES_LSB_REG 106<<11//0x7c<<11 -#define SET_GATES_MSB_REG 107<<11//0x7d<<11 - - -/**ADC SYNC CLEAN FIFO*/ -#define ADCSYNC_CLEAN_FIFO_BITS 0x300000 -#define CLEAN_FIFO_MASK 0x0fffff - - - -#endif - diff --git a/slsDetectorSoftware/jungfrauDetectorServer/server.c b/slsDetectorSoftware/jungfrauDetectorServer/server.c deleted file mode 100755 index eb422c06c..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServer/server.c +++ /dev/null @@ -1,121 +0,0 @@ -/* A simple server in the internet domain using TCP - The port number is passed as an argument */ - -#include "sls_detector_defs.h" - -#include -#include "communication_funcs.h" -#include "server_funcs.h" -#include - - - -extern int sockfd; -extern int phase_shift; - - - -void error(char *msg) -{ - perror(msg); -} - -int main(int argc, char *argv[]) -{ - int portno, b; - char cmd[500]; - int retval=OK; - int sd, fd; - int iarg; - - - for(iarg=1; iarg 2) && (!strcasecmp(argv[2],"stopserver"))){ - portno = DEFAULT_PORTNO+1; - if ( sscanf(argv[1],"%d",&portno) ==0) { - printf("could not open stop server: unknown port\n"); - return 1; - } - b=0; - printf("\n\nStop Server\nOpening stop server on port %d\n",portno); - } - - //control server - else { - portno = DEFAULT_PORTNO; - sprintf(cmd,"%s %d stopserver &",argv[0],DEFAULT_PORTNO+1); - printf("\n\nControl Server\nOpening control server on port %d\n",portno ); - //printf("\n\ncmd:%s\n",cmd); - system(cmd); - b=1; - } - - - - init_detector(b); - - - sd=bindSocket(portno); - sockfd=sd; - if (getServerError(sd)) { - printf("server error!\n"); - return -1; - } - - /* assign function table */ - function_table(); -#ifdef VERBOSE - printf("function table assigned \n"); -#endif - - - /* waits for connection */ - while(retval!=GOODBYE) { -#ifdef VERBOSE - printf("\n"); -#endif -#ifdef VERY_VERBOSE - printf("Waiting for client call\n"); -#endif - fd=acceptConnection(sockfd); -#ifdef VERY_VERBOSE - printf("Conenction accepted\n"); -#endif - retval=decode_function(fd); -#ifdef VERY_VERBOSE - printf("function executed\n"); -#endif - closeConnection(fd); -#ifdef VERY_VERBOSE - printf("connection closed\n"); -#endif - } - - exitServer(sockfd); - printf("Goodbye!\n"); - - return 0; -} - diff --git a/slsDetectorSoftware/jungfrauDetectorServer/server_defs.h b/slsDetectorSoftware/jungfrauDetectorServer/server_defs.h deleted file mode 100755 index 16800080f..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServer/server_defs.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef SERVER_DEFS_H -#define SERVER_DEFS_H -#include "sls_detector_defs.h" -#include - -#define GOODBYE (-200) - -/* Hardware Definitions */ -#define NMAXMODY (1) -#define NMAXMODX (1) -#define NMAXMOD (NMAXMODX * NMAXMODY) -#define NMODY (1) -#define NMODX (1) -#define NMOD (NMODX * NMODY) -#define NCHAN (256 * 256) -#define NCHIP (8) -#define NADC (0) -#define NDAC (8) -#define NCHANS (NCHAN * NCHIP * NMAXMOD) -#define NDACS (NDAC * NMAXMOD) -#define DYNAMIC_RANGE (16) -#define DATA_BYTES (NMAXMOD * NCHIP * NCHAN * 2) -#define IP_PACKETSIZE (0x0522) /**carlos?? calcChecksum*/ -#define UDP_PACKETSIZE (0x050E) /**carlos?? calcChecksum*/ -#define CLK_EXPTIME (40) /** 0x28 better name? */ -#define CLK_FC (20) /** 0x14 better name? */ - -#define CLK_FREQ 156.25E+6 /**carlos used in firmware_funcs.. but needed ?*/ - -/** Default Acqusition Parameters */ -#define DEFAULT_NUM_FRAMES (1*1000*1000) -#define DEFAULT_NUM_CYCLES (0) -#define DEFAULT_EXPTIME (10*1000) -#define DEFAULT_PERIOD (2*1000*1000) -#define DEFAULT_DELAY (0) -#define DEFAULT_NUM_GATES (0) -#define DEFAULT_HIGH_VOLTAGE (0) - -/* Other Default Values */ -//enum DACNAMES { VB_COMP, VDD_PROT, VIN_COM, VREF_PRECH, VB_PIXBUF, VB_DS, VREF_DS, VREF_COMP }; -#define DEFAULT_DAC_VALS { 1220, 3000, 1053, 1450, 750, 1000, 480, 420 }; -enum adcVals {TEMP_FPGA, TEMP_ADC}; -#define DEFAULT_SETTINGS (DYNAMICGAIN) -#define DEFAULT_TX_UDP_PORT (0x7e9a) - -/* Defines in the Firmware */ -#define FIX_PATT_VAL (0xACDC2014) -#define ADC_PORT_INVERT_VAL (0x453b2a9c) -#define ADC_OFST_HALF_SPEED_VAL (0x20) -#define ADC_OFST_QUARTER_SPEED_VAL (0x10) - -#define SAMPLE_ADC_HALF_SPEED (0x7f7c) -#define SAMPLE_ADC_QUARTER_SPEED (0x8981) -#define DAQ_HALF_SPEED (0x0) -#define DAQ_QUARTER_SPEED (0xf) -#define ADC_PHASE_HALF_SPEED (0x41) -#define ADC_PHASE_QUARTER_SPEED (0x19) - -/* Maybe not required for jungfrau */ -#define NTRIMBITS (6) -#define NCOUNTBITS (24) -#define NCHIPS_PER_ADC (2) -#define TRIM_DR (((int)pow(2,NTRIMBITS))-1) -#define COUNT_DR (((int)pow(2,NCOUNTBITS))-1) -#define ALLMOD (0xffff) -#define ALLFIFO (0xffff) - -/* LTC2620 DAC DEFINES */ -#define LTC2620_DAC_CMD_OFST (20) -#define LTC2620_DAC_CMD_MSK (0x0000000F << LTC2620_DAC_CMD_OFST) -#define LTC2620_DAC_ADDR_OFST (16) -#define LTC2620_DAC_ADDR_MSK (0x0000000F << LTC2620_DAC_ADDR_OFST) -#define LTC2620_DAC_DATA_OFST (4) -#define LTC2620_DAC_DATA_MSK (0x00000FFF << LTC2620_DAC_DATA_OFST) - -#define LTC2620_DAC_CMD_WRITE (0x00000000 << LTC2620_DAC_CMD_OFST) -#define LTC2620_DAC_CMD_SET (0x00000003 << LTC2620_DAC_CMD_OFST) -#define LTC2620_DAC_CMD_POWER_DOWN (0x00000004 << LTC2620_DAC_CMD_OFST) -#define LTC2620_DAC_NUMBITS (24) - - -/* MAX1932 HV DEFINES */ -#define MAX1932_HV_NUMBITS (8) -#define MAX1932_HV_DATA_OFST (0) -#define MAX1932_HV_DATA_MSK (0x000000FF << MAX1932_HV_DATA_OFST) - -/* AD9257 ADC DEFINES */ -#define AD9257_ADC_NUMBITS (24) - -#define AD9257_DEV_IND_2_REG (0x04) -#define AD9257_CHAN_H_OFST (0) -#define AD9257_CHAN_H_MSK (0x00000001 << AD9257_CHAN_H_OFST) -#define AD9257_CHAN_G_OFST (1) -#define AD9257_CHAN_G_MSK (0x00000001 << AD9257_CHAN_G_OFST) -#define AD9257_CHAN_F_OFST (2) -#define AD9257_CHAN_F_MSK (0x00000001 << AD9257_CHAN_F_OFST) -#define AD9257_CHAN_E_OFST (3) -#define AD9257_CHAN_E_MSK (0x00000001 << AD9257_CHAN_E_OFST) - -#define AD9257_DEV_IND_1_REG (0x05) -#define AD9257_CHAN_D_OFST (0) -#define AD9257_CHAN_D_MSK (0x00000001 << AD9257_CHAN_D_OFST) -#define AD9257_CHAN_C_OFST (1) -#define AD9257_CHAN_C_MSK (0x00000001 << AD9257_CHAN_C_OFST) -#define AD9257_CHAN_B_OFST (2) -#define AD9257_CHAN_B_MSK (0x00000001 << AD9257_CHAN_B_OFST) -#define AD9257_CHAN_A_OFST (3) -#define AD9257_CHAN_A_MSK (0x00000001 << AD9257_CHAN_A_OFST) -#define AD9257_CLK_CH_DCO_OFST (4) -#define AD9257_CLK_CH_DCO_MSK (0x00000001 << AD9257_CLK_CH_DCO_OFST) -#define AD9257_CLK_CH_IFCO_OFST (5) -#define AD9257_CLK_CH_IFCO_MSK (0x00000001 << AD9257_CLK_CH_IFCO_OFST) - -#define AD9257_POWER_MODE_REG (0x08) -#define AD9257_POWER_INTERNAL_OFST (0) -#define AD9257_POWER_INTERNAL_MSK (0x00000003 << AD9257_POWER_INTERNAL_OFST) -#define AD9257_INT_RESET_VAL (0x3) -#define AD9257_INT_CHIP_RUN_VAL (0x0) -#define AD9257_POWER_EXTERNAL_OFST (5) -#define AD9257_POWER_EXTERNAL_MSK (0x00000001 << AD9257_POWER_EXTERNAL_OFST) -#define AD9257_EXT_FULL_POWER_VAL (0x0) -#define AD9257_EXT_STANDBY_VAL (0x1) - -#define AD9257_OUT_MODE_REG (0x14) -#define AD9257_OUT_FORMAT_OFST (0) -#define AD9257_OUT_FORMAT_MSK (0x00000001 << AD9257_OUT_FORMAT_OFST) -#define AD9257_OUT_BINARY_OFST_VAL (0) -#define AD9257_OUT_TWOS_COMPL_VAL (1) -#define AD9257_OUT_LVDS_OPT_OFST (6) -#define AD9257_OUT_LVDS_OPT_MSK (0x00000001 << AD9257_OUT_LVDS_OPT_OFST) -#define AD9257_OUT_LVDS_ANSI_VAL (0) -#define AD9257_OUT_LVDS_IEEE_VAL (1) - -#define AD9257_OUT_PHASE_REG (0x16) -#define AD9257_OUT_CLK_OFST (0) -#define AD9257_OUT_CLK_MSK (0x0000000F << AD9257_OUT_CLK_OFST) -#define AD9257_OUT_CLK_60_VAL (0x1) -#define AD9257_IN_CLK_OFST (4) -#define AD9257_IN_CLK_MSK (0x00000007 << AD9257_IN_CLK_OFST) -#define AD9257_IN_CLK_0_VAL (0x0) - -#define AD9257_VREF_REG (0x18) -#define AD9257_VREF_OFST (0) -#define AD9257_VREF_MSK (0x00000003 << AD9257_VREF_OFST) -#define AD9257_VREF_1_33_VAL (0x2) - -#define AD9257_TEST_MODE_REG (0x0D) -#define AD9257_OUT_TEST_OFST (0) -#define AD9257_OUT_TEST_MSK (0x0000000F << AD9257_OUT_TEST_OFST) -#define AD9257_NONE_VAL (0x0) -#define AD9257_MIXED_BIT_FREQ_VAL (0xC) -#define AD9257_TEST_RESET_SHORT_GEN (4) -#define AD9257_TEST_RESET_LONG_GEN (5) -#define AD9257_USER_IN_MODE_OFST (6) -#define AD9257_USER_IN_MODE_MSK (0x00000003 << AD9257_USER_IN_MODE_OFST) - - -#endif diff --git a/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.c b/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.c deleted file mode 100755 index eabe39b2c..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.c +++ /dev/null @@ -1,2955 +0,0 @@ -#include "sls_detector_defs.h" -#include "sls_receiver_defs.h" -#include "server_funcs.h" -#include "server_defs.h" -#include "firmware_funcs.h" -#include "mcb_funcs.h" -#include "registers_m.h" -#include "gitInfoJungfrau.h" - - - -extern int lockStatus; -extern char lastClientIP[INET_ADDRSTRLEN]; -extern char thisClientIP[INET_ADDRSTRLEN]; -extern int differentClients; - -//defined in the detector specific make file -#ifdef MYTHEND -const enum detectorType myDetectorType=MYTHEN; -#elif PROPIXD -const enum detectorType myDetectorType=PROPIX; -#elif GOTTHARDD -const enum detectorType myDetectorType=GOTTHARD; -#elif EIGERD -const enum detectorType myDetectorType=EIGER; -#elif PICASSOD -const enum detectorType myDetectorType=PICASSO; -#elif MOENCHD -const enum detectorType myDetectorType=MOENCH; -#elif JUNGFRAUD -const enum detectorType myDetectorType=JUNGFRAU; -#else -const enum detectorType myDetectorType=GENERIC; -#endif - - - -// Global variables -int (*flist[256])(int); -char mess[MAX_STR_LENGTH]; - -int adcvpp = 0x4; /** Carlos will we use this somewhere */ -//set adc val?? - - - - -int init_detector(int controlserver) { - if(controlserver){ - defineGPIOpins(); - resetFPGA(); - }else - usleep(300*1000); - - if (mapCSP0()==FAIL) { - printf("Could not map memory\n"); - exit(1); - } - if (controlserver) - initializeDetector(); - - //common for both control and stop server - strcpy(mess,"dummy message"); - strcpy(lastClientIP,"none"); - strcpy(thisClientIP,"none1"); - lockStatus=0; - return OK; -} - - -int decode_function(int file_des) { - int fnum,n; - int retval=FAIL; -#ifdef VERBOSE - printf( "receive data\n"); -#endif - n = receiveDataOnly(file_des,&fnum,sizeof(fnum)); - if (n <= 0) { -#ifdef VERBOSE - printf("ERROR reading from socket %d, %d %d\n", n, fnum, file_des); -#endif - return FAIL; - } -#ifdef VERBOSE - else - printf("size of data received %d\n",n); -#endif - -#ifdef VERBOSE - printf( "calling function fnum = %d %x %x %x\n",fnum,(unsigned int)(flist[fnum]), (unsigned int)(flist[F_READ_REGISTER]),(unsigned int)(&read_register)); -#endif - if (fnum<0 || fnum>255) - fnum=255; - retval=(*flist[fnum])(file_des); - if (retval==FAIL) - printf( "Error executing the function = %d \n",fnum); - return retval; -} - - -int function_table() { - int i; - for (i=0;i<256;i++){ - flist[i]=&M_nofunc; - } - flist[F_EXIT_SERVER]=&exit_server; - flist[F_EXEC_COMMAND]=&exec_command; - flist[F_GET_DETECTOR_TYPE]=&get_detector_type; - flist[F_SET_NUMBER_OF_MODULES]=&set_number_of_modules; - flist[F_GET_MAX_NUMBER_OF_MODULES]=&get_max_number_of_modules; - flist[F_SET_EXTERNAL_SIGNAL_FLAG]=&set_external_signal_flag; - flist[F_SET_EXTERNAL_COMMUNICATION_MODE]=&set_external_communication_mode; - flist[F_GET_ID]=&get_id; - flist[F_DIGITAL_TEST]=&digital_test; - flist[F_WRITE_REGISTER]=&write_register; - flist[F_READ_REGISTER]=&read_register; - flist[F_SET_DAC]=&set_dac; - flist[F_GET_ADC]=&get_adc; - flist[F_SET_CHANNEL]=&set_channel; - flist[F_SET_CHIP]=&set_chip; - flist[F_SET_MODULE]=&set_module; - flist[F_GET_CHANNEL]=&get_channel; - flist[F_GET_CHIP]=&get_chip; - flist[F_GET_MODULE]=&get_module; - flist[F_GET_THRESHOLD_ENERGY]=&get_threshold_energy; - flist[F_SET_THRESHOLD_ENERGY]=&set_threshold_energy; - flist[F_SET_SETTINGS]=&set_settings; - flist[F_START_ACQUISITION]=&start_acquisition; - flist[F_STOP_ACQUISITION]=&stop_acquisition; - flist[F_START_READOUT]=&start_readout; - flist[F_GET_RUN_STATUS]=&get_run_status; - flist[F_READ_FRAME]=&read_frame; - flist[F_READ_ALL]=&read_all; - flist[F_START_AND_READ_ALL]=&start_and_read_all; - flist[F_SET_TIMER]=&set_timer; - flist[F_GET_TIME_LEFT]=&get_time_left; - flist[F_SET_DYNAMIC_RANGE]=&set_dynamic_range; - flist[F_SET_ROI]=&set_roi; - flist[F_SET_SPEED]=&set_speed; - flist[F_SET_READOUT_FLAGS]=&set_readout_flags; - flist[F_EXECUTE_TRIMMING]=&execute_trimming; - flist[F_LOCK_SERVER]=&lock_server; - flist[F_SET_PORT]=&set_port; - flist[F_GET_LAST_CLIENT_IP]=&get_last_client_ip; - flist[F_UPDATE_CLIENT]=&update_client; - flist[F_CONFIGURE_MAC]=&configure_mac; - flist[F_LOAD_IMAGE]=&load_image; - flist[F_SET_MASTER]=&set_master; - flist[F_SET_SYNCHRONIZATION_MODE]=&set_synchronization; - flist[F_READ_COUNTER_BLOCK]=&read_counter_block; - flist[F_RESET_COUNTER_BLOCK]=&reset_counter_block; - flist[F_START_RECEIVER]=&start_receiver; - flist[F_STOP_RECEIVER]=&stop_receiver; - flist[F_CALIBRATE_PEDESTAL]=&calibrate_pedestal; - flist[F_WRITE_ADC_REG]=&write_adc_register; - flist[F_PROGRAM_FPGA]=&program_fpga; - flist[F_RESET_FPGA]=&reset_fpga; - flist[F_POWER_CHIP]=&power_chip; - - return OK; -} - - -int M_nofunc(int file_des){ - - int ret=FAIL; - sprintf(mess,"Unrecognized Function\n"); - printf(mess); - - sendDataOnly(file_des,&ret,sizeof(ret)); - sendDataOnly(file_des,mess,sizeof(mess)); - return GOODBYE; -} - - -int exit_server(int file_des) { - int retval=FAIL; - sendDataOnly(file_des,&retval,sizeof(retval)); - printf("closing server."); - sprintf(mess,"closing server"); - sendDataOnly(file_des,mess,sizeof(mess)); - return GOODBYE; -} - -int exec_command(int file_des) { - char cmd[MAX_STR_LENGTH]; - char answer[MAX_STR_LENGTH]; - int retval=OK; - int sysret=0; - int n=0; - - /* receive arguments */ - n = receiveDataOnly(file_des,cmd,MAX_STR_LENGTH); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - retval=FAIL; - } - - /* execute action if the arguments correctly arrived*/ - if (retval==OK) { -#ifdef VERBOSE - printf("executing command %s\n", cmd); -#endif - if (lockStatus==0 || differentClients==0) - sysret=system(cmd); - - //should be replaced by popen - if (sysret==0) { - sprintf(answer,"Succeeded\n"); - if (lockStatus==1 && differentClients==1) - sprintf(answer,"Detector locked by %s\n", lastClientIP); - } else { - sprintf(answer,"Failed\n"); - retval=FAIL; - } - } else { - sprintf(answer,"Could not receive the command\n"); - } - - /* send answer */ - n = sendDataOnly(file_des,&retval,sizeof(retval)); - n = sendDataOnly(file_des,answer,MAX_STR_LENGTH); - if (n < 0) { - sprintf(mess,"Error writing to socket"); - retval=FAIL; - } - - - /*return ok/fail*/ - return retval; - -} - - - - - -int get_detector_type(int file_des) { - int n=0; - enum detectorType ret; - int retval=OK; - - sprintf(mess,"Can't return detector type\n"); - - - /* receive arguments */ - /* execute action */ - ret=myDetectorType; - -#ifdef VERBOSE - printf("Returning detector type %d\n",ret); -#endif - - /* send answer */ - /* send OK/failed */ - if (differentClients==1) - retval=FORCE_UPDATE; - - n += sendDataOnly(file_des,&retval,sizeof(retval)); - if (retval!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&ret,sizeof(ret)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - /*return ok/fail*/ - return retval; - - -} - - -int set_number_of_modules(int file_des) { - int n; - int arg[2], ret=0; - int retval=OK; - int dim, nm; - - sprintf(mess,"Can't set number of modules\n"); - - /* receive arguments */ - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket %d", n); - retval=GOODBYE; - } - if (retval==OK) { - dim=arg[0]; - nm=arg[1]; - - /* execute action */ -#ifdef VERBOSE - printf("Setting the number of modules in dimension %d to %d\n",dim,nm ); -#endif - - //if (nm!=GET_FLAG) { - if (dim!=X && nm!=GET_FLAG) { - retval=FAIL; - sprintf(mess,"Can't change module number in dimension %d\n",dim); - } else { - if (lockStatus==1 && differentClients==1 && nm!=GET_FLAG) { - sprintf(mess,"Detector locked by %s\n", lastClientIP); - retval=FAIL; - } else { - ret=setNMod(nm); - if (NMODX==nm || nm==GET_FLAG) { - retval=OK; - if (differentClients==1) - retval=FORCE_UPDATE; - } else - retval=FAIL; - } - } - } - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&retval,sizeof(retval)); - if (retval!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&ret,sizeof(ret)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - /*return ok/fail*/ - return retval; - -} - - -int get_max_number_of_modules(int file_des) { - int n; - int ret; - int retval=OK; - enum dimension arg; - - sprintf(mess,"Can't get max number of modules\n"); - /* receive arguments */ - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - retval=FAIL; - } - /* execute action */ -#ifdef VERBOSE - printf("Getting the max number of modules in dimension %d \n",arg); -#endif - - - switch (arg) { - case X: - ret=getNModBoard(); - break; - case Y: - ret=NMAXMODY; - break; - default: - ret=FAIL; - retval=FAIL; - break; - } -#ifdef VERBOSE - printf("Max number of module in dimension %d is %d\n",arg,ret ); -#endif - - - - if (differentClients==1 && retval==OK) { - retval=FORCE_UPDATE; - } - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&retval,sizeof(retval)); - if (retval!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&ret,sizeof(ret)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - - - /*return ok/fail*/ - return retval; -} - - -//index 0 is in gate -//index 1 is in trigger -//index 2 is out gate -//index 3 is out trigger - -int set_external_signal_flag(int file_des) { - int n; - int arg[2]; - int ret=OK; - int signalindex; - enum externalSignalFlag flag, retval; - - sprintf(mess,"Can't set external signal flag\n"); - - /* receive arguments */ - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - retval=SIGNAL_OFF; - if (ret==OK) { - signalindex=arg[0]; - flag=arg[1]; - /* execute action */ - switch (flag) { - case GET_EXTERNAL_SIGNAL_FLAG: - retval=getExtSignal(signalindex); - break; - - default: - if (differentClients==0 || lockStatus==0) { - retval=setExtSignal(signalindex,flag); - } else { - if (lockStatus!=0) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n", lastClientIP); - } - } - } -#ifdef VERBOSE - printf("Setting external signal %d to flag %d\n",signalindex,flag ); - printf("Set to flag %d\n",retval); -#endif - } else - ret=FAIL; - - - if (ret==OK && differentClients!=0) - ret=FORCE_UPDATE; - - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - - /*return ok/fail*/ - return ret; - -} - - -int set_external_communication_mode(int file_des) { - int n; - enum externalCommunicationMode arg, ret=GET_EXTERNAL_COMMUNICATION_MODE; - int retval=OK; - - sprintf(mess,"Can't set external communication mode\n"); - - /* receive arguments */ - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - retval=FAIL; - } - /* - enum externalCommunicationMode{ - GET_EXTERNAL_COMMUNICATION_MODE, - AUTO, - TRIGGER_EXPOSURE_SERIES, - TRIGGER_EXPOSURE_BURST, - TRIGGER_READOUT, - TRIGGER_COINCIDENCE_WITH_INTERNAL_ENABLE, - GATE_FIX_NUMBER, - GATE_FIX_DURATION, - GATE_WITH_START_TRIGGER, - GATE_COINCIDENCE_WITH_INTERNAL_ENABLE - }; - */ - if (retval==OK) { - /* execute action */ - ret=setTiming(arg); -#ifdef VERBOSE - printf("Setting external communication mode to %d\n", arg); -#endif - } else - ret=FAIL; - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&retval,sizeof(retval)); - if (retval!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&ret,sizeof(ret)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - /*return ok/fail*/ - return retval; -} - - - -int get_id(int file_des) { - // sends back 64 bits! - int64_t retval=-1; - int ret=OK; - int n=0; - enum idMode arg; - - sprintf(mess,"Can't return id\n"); - - /* receive arguments */ - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - -#ifdef VERBOSE - printf("Getting id %d\n", arg); -#endif - - switch (arg) { - case DETECTOR_SERIAL_NUMBER: - case DETECTOR_FIRMWARE_VERSION: - case DETECTOR_SOFTWARE_VERSION: - retval = getId(arg); - break; - default: - printf("Required unknown id %d \n", arg); - ret=FAIL; - retval=FAIL; - break; - } - -#ifdef VERBOSE - printf("Id is %llx\n", retval); -#endif - - if (differentClients==1) - ret=FORCE_UPDATE; - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - /*return ok/fail*/ - return ret; - -} - -int digital_test(int file_des) { - - int retval; - int ret=OK; - int imod=-1; - int n=0; - int ival; - enum digitalTestMode arg; - - sprintf(mess,"Can't send digital test\n"); - - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - -#ifdef VERBOSE - printf("Digital test mode %d\n",arg ); -#endif - - switch (arg) { - case CHIP_TEST: - n = receiveDataOnly(file_des,&imod,sizeof(imod)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - retval=FAIL; - } - ret = FAIL; - strcpy(mess, "Not implemented for this detector\n"); - break; - case MODULE_FIRMWARE_TEST: - retval=0x2; - break; - case DETECTOR_FIRMWARE_TEST: - retval=testFpga(); - break; - case DETECTOR_MEMORY_TEST: - ret=testRAM(); - break; - case DETECTOR_BUS_TEST: - retval=testBus(); - break; - case DETECTOR_SOFTWARE_TEST: - retval=testFpga(); - break; - case DIGITAL_BIT_TEST:// only for gotthard - n = receiveDataOnly(file_des,&ival,sizeof(ival)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - retval=FAIL; - } -#ifdef VERBOSE - printf("with value %d\n", ival); -#endif - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - break; - } - break; - default: - printf("Unknown digital test required %d\n",arg); - ret=FAIL; - retval=FAIL; - break; - } - -#ifdef VERBOSE - printf("digital test result is 0x%x\n", retval); -#endif - //Always returns force update such that the dynamic range is always updated on the client - - // if (differentClients==1 && ret==OK) - ret=FORCE_UPDATE; - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - /*return ok/fail*/ - return ret; - -} - -int write_register(int file_des) { - - int retval; - int ret=OK; - int arg[2]; - int addr, val; - int n; - u_int32_t address; - - sprintf(mess,"Can't write to register\n"); - - n = receiveDataOnly(file_des,arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - addr=arg[0]; - val=arg[1]; - -#ifdef VERBOSE - printf("writing to register 0x%x data 0x%x\n", addr, val); -#endif - - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } - - - if(ret!=FAIL){ - address=(addr<<11); - ret=bus_w(address,val); - if(ret==OK){ - retval=bus_r(address); - } - } - - -#ifdef VERBOSE - printf("Data set to 0x%x\n", retval); -#endif - if (retval==val) { - ret=OK; - if (differentClients) - ret=FORCE_UPDATE; - } else { - ret=FAIL; - sprintf(mess,"Writing to register 0x%x failed: wrote 0x%x but read 0x%x\n", addr, val, retval); - } - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - /*return ok/fail*/ - return ret; - -} - -int read_register(int file_des) { - - int retval; - int ret=OK; - int arg; - int addr; - int n; - u_int32_t address; - - sprintf(mess,"Can't read register\n"); - - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - addr=arg; - - - - //#ifdef VERBOSE - printf("reading register 0x%x\n", addr); - //#endif - - if(ret!=FAIL){ - address=(addr<<11); - retval=bus_r(address); - } - - - -#ifdef VERBOSE - printf("Returned value 0x%x\n", retval); -#endif - if (ret==FAIL) { - ret=FAIL; - printf("Reading register 0x%x failed\n", addr); - } else if (differentClients) - ret=FORCE_UPDATE; - - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - /*return ok/fail*/ - return ret; - -} - -int set_dac(int file_des) { - //default:all mods - int retval, retval1; - int ret=OK; - int arg[3]; - enum dacIndex ind; - int imod; - int n; - int val; - int mV=0; - sprintf(mess,"Can't set DAC\n"); - - n = receiveDataOnly(file_des,arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - ind=arg[0]; - imod=arg[1]; - mV=arg[3]; - n = receiveDataOnly(file_des,&val,sizeof(val)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - //#ifdef VERBOSE - printf("Setting DAC %d of module %d to %d , mode %d\n", ind, imod, val, mV); - //#endif - - if (imod>=getNModBoard()) - ret=FAIL; - if (imod<0) - imod=ALLMOD; - - - - -#ifdef MCB_FUNCS - - if (ret==OK) { - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else{ - if (ind<16) { - - if (mV) { - if (val>2500) - val=-1; - printf("%d mV is ",val); - if (val>0) - val=4095*val/2500; - printf("%d DACu\n", val); - } else if (val>4095) - val=-1; - - - retval=setDac(ind,val); - } - else if (ind==ADC_VPP) { - printf("Setting ADC VPP to %d\n",val); - if (val>4 || val<0) - printf("Cannot set ADC VPP to %d\n",val); - else { - setAdc(0x18,val); - adcvpp=val; - } - retval=adcvpp;; - - } else if (ind==HV_NEW ) - retval=setHighVoltage(val,0); - else - printf("**********No dac with index %d\n",ind); - } - } - if(ret==OK){ - if (ind<16) { - if (mV) { - - printf("%d DACu is ",retval); - retval1=2500*retval/16535; - printf("%d mV \n",retval1); - } else - retval1=retval; - } else - retval1=retval; - } -#endif - -#ifdef VERBOSE - printf("DAC set to %d V\n", retval); -#endif - - if(ret==FAIL) - printf("Setting dac %d of module %d: wrote %d but read %d\n", ind, imod, val, retval); - else{ - if (differentClients) - ret=FORCE_UPDATE; - } - - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - n += sendDataOnly(file_des,&retval1,sizeof(retval1)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - - /*return ok/fail*/ - return ret; - -} - - - -int get_adc(int file_des) { - //default: mod 0 - int retval; - int ret=OK; - int arg[2]; - enum dacIndex ind; - int imod; - int n; - int idac=0; - - sprintf(mess,"Can't read ADC\n"); - - - n = receiveDataOnly(file_des,arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - ind=arg[0]; - imod=arg[1]; - -#ifdef VERBOSE - printf("Getting ADC %d of module %d\n", ind, imod); -#endif - - if (imod>=getNModBoard() || imod<0) - ret=FAIL; - -#ifdef MCB_FUNCS - switch (ind) { - case TEMPERATURE_FPGA: - idac=TEMP_FPGA; - break; - case TEMPERATURE_ADC: - idac=TEMP_ADC; - break; - default: - printf("Unknown DAC index %d\n",ind); - sprintf(mess,"Unknown DAC index %d\n",ind); - ret=FAIL; - break; - } - - if (ret==OK) - retval=getTemperature(idac,imod); -#endif - -#ifdef VERBOSE - printf("ADC is %d V\n", retval); -#endif - if (ret==FAIL) { - printf("Getting adc %d of module %d failed\n", ind, imod); - } - - if (differentClients) - ret=FORCE_UPDATE; - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - /*return ok/fail*/ - return ret; - -} - -int set_channel(int file_des) { - int ret=OK; - sls_detector_channel myChan; - int retval; - int n; - - - sprintf(mess,"Can't set channel\n"); - -#ifdef VERBOSE - printf("Setting channel\n"); -#endif - ret=receiveChannel(file_des, &myChan); - if (ret>=0) - ret=OK; - else - ret=FAIL; -#ifdef VERBOSE - printf("channel number is %d, chip number is %d, module number is %d, register is %lld\n", myChan.chan,myChan.chip, myChan.module, myChan.reg); -#endif - - if (ret==OK) { - if (myChan.module>=getNModBoard()) - ret=FAIL; - if (myChan.chip>=NCHIP) - ret=FAIL; - if (myChan.chan>=NCHAN) - ret=FAIL; - if (myChan.module<0) - myChan.module=ALLMOD; - } - - - if (ret==OK) { - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { -#ifdef MCB_FUNCS - retval=initChannelbyNumber(myChan); -#endif - } - } - /* Maybe this is done inside the initialization funcs */ - //copyChannel(detectorChans[myChan.module][myChan.chip]+(myChan.chan), &myChan); - - - - if (differentClients==1 && ret==OK) - ret=FORCE_UPDATE; - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - - /*return ok/fail*/ - return ret; - -} - - - - -int get_channel(int file_des) { - - int ret=OK; - sls_detector_channel retval; - - int arg[3]; - int ichan, ichip, imod; - int n; - - sprintf(mess,"Can't get channel\n"); - - - - n = receiveDataOnly(file_des,arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - ichan=arg[0]; - ichip=arg[1]; - imod=arg[2]; - - if (ret==OK) { - ret=FAIL; - if (imod>=0 && imod=0 && ichip=0 && ichan=0) - ret=OK; - else - ret=FAIL; -#ifdef VERBOSE - printf("chip number is %d, module number is %d, register is %d, nchan %d\n",myChip.chip, myChip.module, myChip.reg, myChip.nchan); -#endif - - if (ret==OK) { - if (myChip.module>=getNModBoard()) - ret=FAIL; - if (myChip.module<0) - myChip.module=ALLMOD; - if (myChip.chip>=NCHIP) - ret=FAIL; - } - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { -#ifdef MCB_FUNCS - retval=initChipbyNumber(myChip); -#endif - } - /* Maybe this is done inside the initialization funcs */ - //copyChip(detectorChips[myChip.module]+(myChip.chip), &myChip); - - if (differentClients && ret==OK) - ret=FORCE_UPDATE; - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - return ret; -} - - -int get_chip(int file_des) { - - - int ret=OK; - sls_detector_chip retval; - int arg[2]; - int ichip, imod; - int n; - - - - n = receiveDataOnly(file_des,arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - ichip=arg[0]; - imod=arg[1]; - if (ret==OK) { - ret=FAIL; - if (imod>=0 && imod=0 && ichip=0) - ret=OK; - else - ret=FAIL; - - - //#ifdef VERBOSE - printf("module number is %d,register is %d, nchan %d, nchip %d, ndac %d, nadc %d, gain %f, offset %f\n",myModule.module, myModule.reg, myModule.nchan, myModule.nchip, myModule.ndac, myModule.nadc, myModule.gain,myModule.offset); - //#endif - - if (ret==OK) { - if (myModule.module>=getNModBoard()) { - ret=FAIL; - printf("Module number is too large %d\n",myModule.module); - } - if (myModule.module<0) - myModule.module=ALLMOD; - } - - if (ret==OK) { - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { -#ifdef MCB_FUNCS - retval=initModulebyNumber(myModule); - if(retval != myModule.reg) - ret = FAIL; -#endif - } - } - - if (differentClients==1 && ret==OK) - ret=FORCE_UPDATE; - - /* Maybe this is done inside the initialization funcs */ - //copyChip(detectorChips[myChip.module]+(myChip.chip), &myChip); - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - free(myDac); - if(myAdc != NULL) free(myAdc); - if(myChip != NULL) free(myChip); - if(myChan != NULL) free(myChan); - - - //setDynamicRange(dr); always 16 commented out - - return ret; -} - - - - -int get_module(int file_des) { - - int ret=OK; - int arg; - int imod; - int n; - sls_detector_module myModule; - int *myDac=malloc(NDAC*sizeof(int)); - int *myChip=NULL; - int *myChan=NULL; - int *myAdc=NULL; - //not allocating mychip,mychan for jungfrau to sace memory - - if (myDac) - myModule.dacs=myDac; - else { - sprintf(mess,"could not allocate dacs\n"); - ret=FAIL; - } - - - myModule.adcs=NULL; - myModule.chipregs=NULL; - myModule.chanregs=NULL; - myModule.ndac=NDAC; - myModule.nchip=NCHIP; - myModule.nchan=NCHAN*NCHIP; - myModule.nadc=NADC; - - - - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - imod=arg; - - if (ret==OK) { - ret=FAIL; - if (imod>=0 && imod0) { - dataret=FAIL; - sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+1)); - cprintf(RED,"%s\n",mess); - } else { - dataret=FINISHED; - sprintf(mess,"acquisition successfully finished\n"); - printf("%s",mess); - if (differentClients) - dataret=FORCE_UPDATE; - } -#endif - sendDataOnly(file_des,&dataret,sizeof(dataret)); - sendDataOnly(file_des,mess,sizeof(mess)); - return dataret; -} - - - - -int read_all(int file_des) { - while(read_frame(file_des)==OK) { -#ifdef VERBOSE - printf("frame read\n"); -#endif - ; - } -#ifdef VERBOSE - printf("Frames finished\n"); -#endif - return OK; -} - - - -int start_and_read_all(int file_des) { -#ifdef VERBOSE - printf("Starting and reading all frames\n"); -#endif - if (differentClients==1 && lockStatus==1) { - int dataret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - sendDataOnly(file_des,&dataret,sizeof(dataret)); - sendDataOnly(file_des,mess,sizeof(mess)); - return dataret; - - } - startStateMachine(); - read_all(file_des); -#ifdef VERBOSE - printf("Frames finished\n"); -#endif - return OK; -} - -int set_timer(int file_des) { - enum timerIndex ind; - int64_t tns; - int n; - int64_t retval; - int ret=OK; - - sprintf(mess,"can't set timer\n"); - - n = receiveDataOnly(file_des,&ind,sizeof(ind)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - n = receiveDataOnly(file_des,&tns,sizeof(tns)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - if (ret!=OK) { - printf(mess); - } - - -#ifdef VERBOSE - printf("setting timer %d to %lld ns\n",ind,tns); -#endif - - if (ret==OK) { - - if (differentClients==1 && lockStatus==1 && tns!=-1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - switch(ind) { - case FRAME_NUMBER: - retval=setFrames(tns); - break; - case ACQUISITION_TIME: - retval=setExposureTime(tns); - break; - case FRAME_PERIOD: - retval=setPeriod(tns); - break; - case DELAY_AFTER_TRIGGER: - retval=setDelay(tns); - break; - case GATES_NUMBER: - retval=setGates(tns); - break; - case PROBES_NUMBER: - sprintf(mess,"can't set timer for this detector\n"); - ret=FAIL; - break; - case CYCLES_NUMBER: - retval=setTrains(tns); - break; - default: - ret=FAIL; - sprintf(mess,"timer index unknown %d\n",ind); - break; - } - } - } - - if(ret == OK && (retval!=tns) && (tns != -1)){ - ret = FAIL; - sprintf(mess,"Setting timer %d of failed: wrote %lld but read %lld\n", ind, (long long int)tns, (long long int)retval); - cprintf(RED,"%s",mess); - }else if (ret!=OK) { - cprintf(RED,"%s",mess); - cprintf(RED,"set timer failed\n"); - } - - if (ret==OK && differentClients) - ret=FORCE_UPDATE; - - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { -#ifdef VERBOSE - printf("returning ok %d\n",(int)(sizeof(retval))); -#endif - - n = sendDataOnly(file_des,&retval,sizeof(retval)); - } - - return ret; - -} - - - - - - - - -int get_time_left(int file_des) { - - enum timerIndex ind; - int n; - int64_t retval; - int ret=OK; - - sprintf(mess,"can't get timer\n"); - n = receiveDataOnly(file_des,&ind,sizeof(ind)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - - //#ifdef VERBOSE - - printf("getting time left on timer %d \n",ind); - //#endif - - if (ret==OK) { - switch(ind) { - case FRAME_NUMBER: - printf("getting frames \n"); - retval=getFrames(); - break; - case ACQUISITION_TIME: - retval=getExposureTime();/** not implemented */ - break; - case FRAME_PERIOD: - retval=getPeriod(); - break; - case DELAY_AFTER_TRIGGER: - retval=getDelay(); - break; - case GATES_NUMBER: - retval=getGates();/** not implemented */ - break; - case PROBES_NUMBER: - retval=getProbes(); - break; - case CYCLES_NUMBER: - retval=getTrains(); - break; - case ACTUAL_TIME: - retval=getActualTime(); - break; - case MEASUREMENT_TIME: - retval=getMeasurementTime(); - break; - case FRAMES_FROM_START: - case FRAMES_FROM_START_PG: - retval=getFramesFromStart(); - break; - default: - ret=FAIL; - sprintf(mess,"timer index unknown %d\n",ind); - break; - } - } - - - if (ret!=OK) { - printf("get time left failed\n"); - } else if (differentClients) - ret=FORCE_UPDATE; - - //#ifdef VERBOSE - - printf("time left on timer %d is %lld\n",ind, retval); - //#endif - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } else - n = sendDataOnly(file_des,&retval,sizeof(retval)); - -#ifdef VERBOSE - - printf("data sent\n"); -#endif - - return ret; - - -} - -int set_dynamic_range(int file_des) { - - - - int dr; - int n; - int retval; - int ret=OK; - - sprintf(mess,"can't set dynamic range\n"); - - - n = receiveDataOnly(file_des,&dr,sizeof(dr)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - - if (differentClients==1 && lockStatus==1 && dr>=0) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - retval=setDynamicRange(dr); - } - - //if (dr>=0 && retval!=dr) ret=FAIL; - if (ret!=OK) { - sprintf(mess,"set dynamic range failed\n"); - } else { - if (differentClients) - ret=FORCE_UPDATE; - } - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { - n = sendDataOnly(file_des,&retval,sizeof(retval)); - } - return ret; -} - -int set_roi(int file_des) { - - int ret=OK; - int nroi=-1; - int n=0; - strcpy(mess,"Could not set/get roi\n"); - - n = receiveDataOnly(file_des,&nroi,sizeof(nroi)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - ret = FAIL; - strcpy(mess,"Not applicable/implemented for this detector\n"); - printf("Error:Set ROI-%s",mess); - - - if(ret==OK && differentClients){ - printf("Force update\n"); - ret=FORCE_UPDATE; - } - - /* send answer */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - n = sendDataOnly(file_des,mess,sizeof(mess)); - /*return ok/fail*/ - return ret; -} - -int get_roi(int file_des) { - return FAIL; -} - -int set_speed(int file_des) { - - enum speedVariable arg; - int val,n; - int ret=OK; - int retval=-1; - - n=receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - n=receiveDataOnly(file_des,&val,sizeof(val)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - if (ret==OK) { - - - if (val!=-1) { - if (differentClients==1 && lockStatus==1 && val>=0) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - switch (arg) { - case CLOCK_DIVIDER: - switch(val){ - case 0: - ret=FAIL; - sprintf(mess,"Full speed not implemented yet. Available options: 1 for half speed and 2 for quarter speed"); - break; - case 1: - case 2: - break; - default: - ret=FAIL; - sprintf(mess,"Unknown clock options %d. Available options: 1 for half speed and 2 for quarter speed",arg); - break; - } - setClockDivider(val); - break; - - case ADC_PHASE: - adcPhase(val); - break; - - default: - ret=FAIL; - sprintf(mess,"Unknown speed parameter %d",arg); - } - } - } - } - - - - if (ret==OK) { - switch (arg) { - case CLOCK_DIVIDER: - retval=getClockDivider(); - break; - - case ADC_PHASE: - retval=getPhase(); - break; - - default: - ret=FAIL; - sprintf(mess,"Unknown speed parameter %d",arg); - } - } - - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { - n = sendDataOnly(file_des,&retval,sizeof(retval)); - } - return ret; -} - - - -int set_readout_flags(int file_des) { - - enum readOutFlags arg; - int ret=FAIL; - - - receiveDataOnly(file_des,&arg,sizeof(arg)); - - sprintf(mess,"can't set readout flags for this detector\n"); - - sendDataOnly(file_des,&ret,sizeof(ret)); - sendDataOnly(file_des,mess,sizeof(mess)); - - return ret; -} - - - - - -int execute_trimming(int file_des) { - - int arg[3]; - int ret=FAIL; - enum trimMode mode; - - sprintf(mess,"can't set execute trimming for this detector\n"); - - receiveDataOnly(file_des,&mode,sizeof(mode)); - receiveDataOnly(file_des,arg,sizeof(arg)); - - - sendDataOnly(file_des,&ret,sizeof(ret)); - sendDataOnly(file_des,mess,sizeof(mess)); - - return ret; -} - - -int lock_server(int file_des) { - - - int n; - int ret=OK; - - int lock; - n = receiveDataOnly(file_des,&lock,sizeof(lock)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - printf("Error reading from socket (lock)\n"); - ret=FAIL; - } - if (lock>=0) { - if (lockStatus==0 || strcmp(lastClientIP,thisClientIP)==0 || strcmp(lastClientIP,"none")==0) - lockStatus=lock; - else { - ret=FAIL; - sprintf(mess,"Server already locked by %s\n", lastClientIP); - } - } - if (differentClients && ret==OK) - ret=FORCE_UPDATE; - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else - n = sendDataOnly(file_des,&lockStatus,sizeof(lockStatus)); - - return ret; - -} - -int set_port(int file_des) { - int n; - int ret=OK; - int sd=-1; - - enum portType p_type; /** data? control? stop? Unused! */ - int p_number; /** new port number */ - - n = receiveDataOnly(file_des,&p_type,sizeof(p_type)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - printf("Error reading from socket (ptype)\n"); - ret=FAIL; - } - - n = receiveDataOnly(file_des,&p_number,sizeof(p_number)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - printf("Error reading from socket (pnum)\n"); - ret=FAIL; - } - if (differentClients==1 && lockStatus==1 ) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - if (p_number<1024) { - sprintf(mess,"Too low port number %d\n", p_number); - printf("\n"); - ret=FAIL; - } - - printf("set port %d to %d\n",p_type, p_number); - - sd=bindSocket(p_number); - } - if (sd>=0) { - ret=OK; - if (differentClients ) - ret=FORCE_UPDATE; - } else { - ret=FAIL; - sprintf(mess,"Could not bind port %d\n", p_number); - printf("Could not bind port %d\n", p_number); - if (sd==-10) { - sprintf(mess,"Port %d already set\n", p_number); - printf("Port %d already set\n", p_number); - - } - } - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { - n = sendDataOnly(file_des,&p_number,sizeof(p_number)); - closeConnection(file_des); - exitServer(sockfd); - sockfd=sd; - - } - - return ret; - -} - -int get_last_client_ip(int file_des) { - int ret=OK; - int n; - if (differentClients ) - ret=FORCE_UPDATE; - n = sendDataOnly(file_des,&ret,sizeof(ret)); - n = sendDataOnly(file_des,lastClientIP,sizeof(lastClientIP)); - - return ret; - -} - - -int send_update(int file_des) { - - int ret=OK; - enum detectorSettings t; - int n; - int val; - size_t s; - int64_t retval, tns=-1; - n = sendDataOnly(file_des,lastClientIP,sizeof(lastClientIP)); - val = NMODX; - n = sendDataOnly(file_des,&val,sizeof(val)); - val = NMODY; - n = sendDataOnly(file_des,&val,sizeof(val)); - val = DYNAMIC_RANGE; - n = sendDataOnly(file_des,&val,sizeof(val)); - s = DATA_BYTES; - n = sendDataOnly(file_des,&s,sizeof(s)); - t=setSettings(GET_SETTINGS,-1); - n = sendDataOnly(file_des,&t,sizeof(t)); - /* thr=getThresholdEnergy(); - n = sendDataOnly(file_des,&thr,sizeof(thr));*/ - retval=setFrames(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t)); - retval=setExposureTime(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t)); - retval=setPeriod(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t)); - retval=setDelay(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t)); - retval=setGates(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t)); - /* retval=setProbes(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t));*/ - retval=setTrains(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t)); - - if (lockStatus==0) { - strcpy(lastClientIP,thisClientIP); - } - - return ret; - - -} -int update_client(int file_des) { - - int ret=OK; - - sendDataOnly(file_des,&ret,sizeof(ret)); - return send_update(file_des); - - - -} - - -int configure_mac(int file_des) { - - int ret=OK; - char arg[5][50]; - int n; - - int imod=0;//should be in future sent from client as -1, arg[2] - int ipad; - long long int imacadd; - long long int idetectormacadd; - int udpport; - int detipad; - int retval=-100; - - sprintf(mess,"Can't configure MAC\n"); - - - n = receiveDataOnly(file_des,arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - sscanf(arg[0], "%x", &ipad); - sscanf(arg[1], "%llx", &imacadd); - sscanf(arg[2], "%x", &udpport); - sscanf(arg[3], "%llx", &idetectormacadd); - sscanf(arg[4], "%x", &detipad); - - //#ifdef VERBOSE - int i; - printf("\nipadd %x\t",ipad); - printf("destination ip is %d.%d.%d.%d = 0x%x \n",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff,ipad); - printf("macad:%llx\n",imacadd); - for (i=0;i<6;i++) - printf("mac adress %d is 0x%x \n",6-i,(unsigned int)(((imacadd>>(8*i))&0xFF))); - printf("udp port:0x%x\n",udpport); - printf("detector macad:%llx\n",idetectormacadd); - for (i=0;i<6;i++) - printf("detector mac adress %d is 0x%x \n",6-i,(unsigned int)(((idetectormacadd>>(8*i))&0xFF))); - printf("detipad %x\n",detipad); - printf("\n"); - //#endif - - - - if (imod>=getNModBoard()) - ret=FAIL; - if (imod<0) - imod=ALLMOD; - - //#ifdef VERBOSE - printf("Configuring MAC of module %d at port %x\n", imod, udpport); - //#endif -#ifdef MCB_FUNCS - if (ret==OK){ - if(runBusy()){ - ret=stopStateMachine(); - if(ret==FAIL) - strcpy(mess,"could not stop detector acquisition to configure mac"); - } - - if(ret==OK) - configureMAC(ipad,imacadd,idetectormacadd,detipad,udpport); - } -#endif - if (ret==FAIL) - printf("configuring MAC of mod %d failed\n", imod); - else - printf("Configuremac successful of mod %d\n",imod); - - if (differentClients) - ret=FORCE_UPDATE; - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) - n += sendDataOnly(file_des,mess,sizeof(mess)); - else - n += sendDataOnly(file_des,&retval,sizeof(retval)); - /*return ok/fail*/ - return ret; - -} - - - -int load_image(int file_des) { - int retval; - int ret=OK; - int n; - enum imageType index; - short int ImageVals[NCHAN*NCHIP]; - - sprintf(mess,"Loading image failed\n"); - - n = receiveDataOnly(file_des,&index,sizeof(index)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - n = receiveDataOnly(file_des,ImageVals,DATA_BYTES); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - switch (index) { - case DARK_IMAGE : -#ifdef VERBOSE - printf("Loading Dark image\n"); -#endif - break; - case GAIN_IMAGE : -#ifdef VERBOSE - printf("Loading Gain image\n"); -#endif - break; - default: - printf("Unknown index %d\n",index); - sprintf(mess,"Unknown index %d\n",index); - ret=FAIL; - break; - } - - if (ret==OK) { - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else{ - retval=loadImage(index,ImageVals); - if (retval==-1) - ret = FAIL; - } - } - - if(ret==OK){ - if (differentClients) - ret=FORCE_UPDATE; - } - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - /*return ok/fail*/ - return ret; -} - - - -int set_master(int file_des) { - - enum masterFlags retval=GET_MASTER; - enum masterFlags arg; - int n; - int ret=OK; - // int regret=OK; - - - sprintf(mess,"can't set master flags\n"); - - - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - -#ifdef VERBOSE - printf("setting master flags to %d\n",arg); -#endif - - if (differentClients==1 && lockStatus==1 && arg!=GET_READOUT_FLAGS) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - retval=setMaster(arg); - - } - if (retval==GET_MASTER) { - ret=FAIL; - } - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { - n = sendDataOnly(file_des,&retval,sizeof(retval)); - } - return ret; -} - - - - - - -int set_synchronization(int file_des) { - - enum synchronizationMode retval=GET_MASTER; - enum synchronizationMode arg; - int n; - int ret=OK; - //int regret=OK; - - - sprintf(mess,"can't set synchronization mode\n"); - - - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } -#ifdef VERBOSE - printf("setting master flags to %d\n",arg); -#endif - - if (differentClients==1 && lockStatus==1 && arg!=GET_READOUT_FLAGS) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - //ret=setStoreInRAM(0); - // initChipWithProbes(0,0,0, ALLMOD); - retval=setSynchronization(arg); - } - if (retval==GET_SYNCHRONIZATION_MODE) { - ret=FAIL; - } - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { - n = sendDataOnly(file_des,&retval,sizeof(retval)); - } - return ret; -} - - - - - - -int read_counter_block(int file_des) { - - int ret=OK; - int n; - int startACQ; - //char *retval=NULL; - short int CounterVals[NCHAN*NCHIP]; - - sprintf(mess,"Read counter block failed\n"); - - n = receiveDataOnly(file_des,&startACQ,sizeof(startACQ)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - if (ret==OK) { - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else{ - ret=readCounterBlock(startACQ,CounterVals); -#ifdef VERBOSE - int i; - for(i=0;i<6;i++) - printf("%d:%d\t",i,CounterVals[i]); -#endif - } - } - - if(ret!=FAIL){ - if (differentClients) - ret=FORCE_UPDATE; - } - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,CounterVals,DATA_BYTES); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - /*return ok/fail*/ - return ret; -} - - - - - -int reset_counter_block(int file_des) { - - int ret=OK; - int n; - int startACQ; - - sprintf(mess,"Reset counter block failed\n"); - - n = receiveDataOnly(file_des,&startACQ,sizeof(startACQ)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - if (ret==OK) { - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else - ret=resetCounterBlock(startACQ); - } - - if(ret==OK){ - if (differentClients) - ret=FORCE_UPDATE; - } - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) - n += sendDataOnly(file_des,mess,sizeof(mess)); - - /*return ok/fail*/ - return ret; -} - - - - - - -int start_receiver(int file_des) { - int ret=FAIL; - int n; - strcpy(mess,"Not implemented for this detector\n"); - - /* send answer */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - n = sendDataOnly(file_des,mess,sizeof(mess)); - /*return ok/fail*/ - return ret; -} - - - - - - -int stop_receiver(int file_des) { - int ret = FAIL; - int n; - strcpy(mess,"Not implemented for this detector\n"); - - /* send answer */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - n = sendDataOnly(file_des,mess,sizeof(mess)); - /*return ok/fail*/ - return ret; -} - - - - - -int calibrate_pedestal(int file_des){ - - int ret=OK; - int retval=-1; - int n; - int frames; - - sprintf(mess,"Could not calibrate pedestal\n"); - - n = receiveDataOnly(file_des,&frames,sizeof(frames)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - if (ret==OK) { - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else - ret=calibratePedestal(frames); - } - - if(ret==OK){ - if (differentClients) - ret=FORCE_UPDATE; - } - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) - n += sendDataOnly(file_des,mess,sizeof(mess)); - else - n += sendDataOnly(file_des,&retval,sizeof(retval)); - - /*return ok/fail*/ - return ret; -} - - -int write_adc_register(int file_des) { - - int retval; - int ret=OK; - int arg[2]; - int addr, val; - int n; - - sprintf(mess,"Can't write to register\n"); - - n = receiveDataOnly(file_des,arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - addr=arg[0]; - val=arg[1]; - -#ifdef VERBOSE - printf("writing to register 0x%x data 0x%x\n", addr, val); -#endif - - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } - - - if(ret!=FAIL){ - ret=setAdc(addr,val); - if (ret==OK) - retval=val; - } - - -#ifdef VERBOSE - printf("Data set to 0x%x\n", retval); -#endif - if (retval==val) { - ret=OK; - if (differentClients) - ret=FORCE_UPDATE; - } else { - ret=FAIL; - sprintf(mess,"Writing to register 0x%x failed: wrote 0x%x but read 0x%x\n", addr, val, retval); - } - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - /*return ok/fail*/ - return ret; - -} - - - - - -int program_fpga(int file_des) { - int ret=OK; - int n; - sprintf(mess,"Program FPGA unsuccessful\n"); - char* fpgasrc = NULL; - FILE* fp = NULL; - size_t filesize = 0; - size_t unitprogramsize = 0; - size_t totalsize = 0; - - - //filesize - n = receiveDataOnly(file_des,&filesize,sizeof(filesize)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - totalsize = filesize; -#ifdef VERY_VERBOSE - printf("\n\n Total size is:%d\n",totalsize); -#endif - - //lock - if (ret==OK && differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - filesize = 0; - } - - //opening file pointer to flash and telling FPGA to not touch flash - if(ret == OK && startWritingFPGAprogram(&fp) != OK){ - sprintf(mess,"Could not write to flash. Error at startup.\n"); - cprintf(RED,"%s",mess); - ret=FAIL; - filesize = 0; - } - - //---------------- first ret ---------------- - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) - n += sendDataOnly(file_des,mess,sizeof(mess)); - //---------------- first ret ---------------- - - - //erasing flash - if(ret != FAIL){ - eraseFlash(); - fpgasrc = (char*)malloc(MAX_FPGAPROGRAMSIZE); - } - - - - //writing to flash part by part - while(ret != FAIL && filesize){ - - unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb - if(unitprogramsize > filesize) //less than 2mb - unitprogramsize = filesize; -#ifdef VERY_VERBOSE - printf("unit size to receive is:%d\n",unitprogramsize); - printf("filesize:%d currentpointer:%d\n",filesize,currentPointer); -#endif - - - //receive - n = receiveDataOnly(file_des,fpgasrc,unitprogramsize); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - - if (ret==OK) { - if(!(unitprogramsize - filesize)){ - fpgasrc[unitprogramsize]='\0'; - filesize-=unitprogramsize; - unitprogramsize++; - }else - filesize-=unitprogramsize; - - ret = writeFPGAProgram(fpgasrc,unitprogramsize,fp); - } - - - //---------------- middle rets ---------------- - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n += sendDataOnly(file_des,mess,sizeof(mess)); - cprintf(RED,"Failure: Breaking out of program receiving\n"); - } - //---------------- middle rets ---------------- - - - if(ret != FAIL){ - //print progress - printf("Writing to Flash:%d%%\r",(int) (((double)(totalsize-filesize)/totalsize)*100) ); - fflush(stdout); - } - - } - - - - printf("\n"); - - //closing file pointer to flash and informing FPGA - if(stopWritingFPGAprogram(fp) == FAIL){ - sprintf(mess,"Could not write to flash. Error at end.\n"); - cprintf(RED,"%s",mess); - ret=FAIL; - } - - if(ret!=FAIL){ - ret=FORCE_UPDATE; - } - - - //---------------- last ret ---------------- - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) - n += sendDataOnly(file_des,mess,sizeof(mess)); - //---------------- last ret ---------------- - - - //free resources - if(fpgasrc != NULL) - free(fpgasrc); - if(fp!=NULL) - fclose(fp); -#ifdef VERY_VERBOSE - printf("Done with program receiving command\n"); -#endif - /*return ok/fail*/ - return ret; -} - - - -int reset_fpga(int file_des) { - int ret=OK; - int n; - sprintf(mess,"Reset FPGA unsuccessful\n"); - - resetFPGA(); - initializeDetector(); - - ret = FORCE_UPDATE; - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) - n += sendDataOnly(file_des,mess,sizeof(mess)); - - /*return ok/fail*/ - return ret; -} - - - -int power_chip(int file_des) { - - int retval=-1; - int ret=OK; - int arg=-1; - int n; - - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - -#ifdef VERBOSE - printf("Power chip to %d\n", arg); -#endif - - if (differentClients==1 && lockStatus==1 && arg!=-1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - retval=powerChip(arg); -#ifdef VERBOSE - printf("Chip powered: %d\n",retval); -#endif - - if (retval==arg || arg<0) { - ret=OK; - } else { - ret=FAIL; - printf("Powering chip failed, wrote %d but read %d\n", arg, retval); - } - - } - if (ret==OK && differentClients==1) - ret=FORCE_UPDATE; - - /* send answer */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } else - n += sendDataOnly(file_des,&retval,sizeof(retval)); - - return ret; -} diff --git a/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.h b/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.h deleted file mode 100755 index 479e78a7e..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef SERVER_FUNCS_H -#define SERVER_FUNCS_H - - -#include "sls_detector_defs.h" -#include "communication_funcs.h" - -#include - -#define GOODBYE (-200) - - -int sockfd; - - -int function_table(); -int decode_function(int); -int init_detector(int); -int M_nofunc(int); -int exit_server(int); -int exec_command(int); - - - -// General purpose functions -int get_detector_type(int); -int set_number_of_modules(int); -int get_max_number_of_modules(int); - - -int set_external_signal_flag(int); -int set_external_communication_mode(int); -int get_id(int); -int digital_test(int); -int write_register(int); -int read_register(int); -int set_dac(int); -int get_adc(int); -int set_channel(int); -int get_channel(int); -int set_chip(int); -int get_chip(int); -int set_module(int); -int get_module(int); - -int get_threshold_energy(int); -int set_threshold_energy(int); -int set_settings(int); -int start_acquisition(int); -int stop_acquisition(int); -int start_readout(int); -int get_run_status(int); -int read_frame(int); -int read_all(int); -int start_and_read_all(int); -int set_timer(int); -int get_time_left(int); -int set_dynamic_range(int); -int set_roi(int); -int get_roi(int); -int set_speed(int); -int set_readout_flags(int); -int execute_trimming(int); -int lock_server(int); -int set_port(int); -int get_last_client_ip(int); -int send_update(int); -int update_client(int); - -int configure_mac(int); -int load_image(int); - -int set_master(int); -int set_synchronization(int); - -int read_counter_block(int); -int reset_counter_block(int); - -int start_receiver(int); -int stop_receiver(int); - - -int calibrate_pedestal(int); - -int set_roi(int); - -int write_adc_register(int);; - -int program_fpga(int); -int reset_fpga(int); -int power_chip(int); -#endif diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/slsDetectorFunctionList.c b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServerNewStructure/slsDetectorFunctionList.c rename to slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/slsDetectorFunctionList.h b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServerNewStructure/slsDetectorFunctionList.h rename to slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.h diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/slsDetectorServer.c b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer.c similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServerNewStructure/slsDetectorServer.c rename to slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer.c diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/slsDetectorServer_defs.h b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_defs.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServerNewStructure/slsDetectorServer_defs.h rename to slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_defs.h diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/slsDetectorServer_funcs.c b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_funcs.c similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServerNewStructure/slsDetectorServer_funcs.c rename to slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_funcs.c diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/slsDetectorServer_funcs.h b/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_funcs.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServerNewStructure/slsDetectorServer_funcs.h rename to slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_funcs.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/stop_server.c b/slsDetectorSoftware/jungfrauDetectorServer/stop_server.c deleted file mode 100755 index e3c8ff7e1..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServer/stop_server.c +++ /dev/null @@ -1,46 +0,0 @@ -/* A simple server in the internet domain using TCP - The port number is passed as an argument */ - - -#include "sls_detector_defs.h" - - -#include "communication_funcs.h" -#include "firmware_funcs.h" - - -int sockfd; - -int main(int argc, char *argv[]) -{ - int portno; - int retval=0; - - portno = DEFAULT_PORTNO; - - - bindSocket(portno); - if (getServerError()) - return -1; - - - - /* waits for connection */ - while(retval!=GOODBYE) { -#ifdef VERBOSE - printf("\n"); -#endif -#ifdef VERY_VERBOSE - printf("Stop server: waiting for client call\n"); -#endif - acceptConnection(); - retval=stopStateMachine(); - closeConnection(); - } - - exitServer(); - printf("Goodbye!\n"); - - return 0; -} - diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/Makefile b/slsDetectorSoftware/jungfrauDetectorServerNewStructure/Makefile deleted file mode 100755 index 8ff6779c8..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -CROSS = bfin-uclinux- -CC = $(CROSS)gcc -CFLAGS += -Wall -DJUNGFRAUD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE -LDLIBS += -lm -lstdc++ - -PROGS = jungfrauDetectorServer -DESTDIR ?= bin -INSTMODE = 0777 - -SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c -OBJS = $(SRC_CLNT:.c=.o) - -all: clean $(PROGS) - -boot: $(OBJS) - -$(PROGS): $(OBJS) - echo $(OBJS) - mkdir -p $(DESTDIR) - $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) - mv $(PROGS) $(DESTDIR) - rm *.gdb - -clean: - rm -rf $(DESTDIR)/$(PROGS) *.o - diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/Makefile.virtual b/slsDetectorSoftware/jungfrauDetectorServerNewStructure/Makefile.virtual deleted file mode 100644 index 8ee348341..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/Makefile.virtual +++ /dev/null @@ -1,25 +0,0 @@ -CC = gcc -CFLAGS += -Wall -DJUNGFRAUD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE -LDLIBS += -lm -lstdc++ - -PROGS = jungfrauDetectorServer -DESTDIR ?= bin -INSTMODE = 0777 - -SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c -OBJS = $(SRC_CLNT:.c=.o) - -all: clean $(PROGS) - -boot: $(OBJS) - -$(PROGS): $(OBJS) - echo $(OBJS) - mkdir -p $(DESTDIR) - $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) - mv $(PROGS) $(DESTDIR) - rm *.gdb - -clean: - rm -rf $(DESTDIR)/$(PROGS) *.o - diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/ansi.h b/slsDetectorSoftware/jungfrauDetectorServerNewStructure/ansi.h deleted file mode 120000 index a122db0ad..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/ansi.h +++ /dev/null @@ -1 +0,0 @@ -../../slsReceiverSoftware/include/ansi.h \ No newline at end of file diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/communication_funcs.c b/slsDetectorSoftware/jungfrauDetectorServerNewStructure/communication_funcs.c deleted file mode 120000 index 87a4f95d1..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/communication_funcs.c +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/communication_funcs.c \ No newline at end of file diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/communication_funcs.h b/slsDetectorSoftware/jungfrauDetectorServerNewStructure/communication_funcs.h deleted file mode 120000 index f220903b2..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/communication_funcs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/communication_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/gitInfo.txt b/slsDetectorSoftware/jungfrauDetectorServerNewStructure/gitInfo.txt deleted file mode 100644 index c64e4f71a..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/gitInfo.txt +++ /dev/null @@ -1,9 +0,0 @@ -Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer -URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git/jungfrauDetectorServer -Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git -Repsitory UUID: 230d6b36e9852214f4ba5ae7c92647f35000b24d -Revision: 56 -Branch: developer -Last Changed Author: Dhanya_Maliakal -Last Changed Rev: 1313 -Last Changed Date: 2016-11-30 10:36:34 +0100 diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/gitInfoJungfrau.h b/slsDetectorSoftware/jungfrauDetectorServerNewStructure/gitInfoJungfrau.h deleted file mode 100644 index 633eb8933..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/gitInfoJungfrau.h +++ /dev/null @@ -1,11 +0,0 @@ -//#define SVNPATH "" -#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git/jungfrauDetectorServer" -//#define SVNREPPATH "" -#define SVNREPUUID "230d6b36e9852214f4ba5ae7c92647f35000b24d" -//#define SVNREV 0x1313 -//#define SVNKIND "" -//#define SVNSCHED "" -#define SVNAUTH "Dhanya_Maliakal" -#define SVNREV 0x1313 -#define SVNDATE 0x20161130 -// diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/gitInfoJungfrauTmp.h b/slsDetectorSoftware/jungfrauDetectorServerNewStructure/gitInfoJungfrauTmp.h deleted file mode 100644 index 58e48f497..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/gitInfoJungfrauTmp.h +++ /dev/null @@ -1,11 +0,0 @@ -//#define SVNPATH "" -#define SVNURL "" -//#define SVNREPPATH "" -#define SVNREPUUID "" -//#define SVNREV "" -//#define SVNKIND "" -//#define SVNSCHED "" -#define SVNAUTH "" -#define SVNREV "" -#define SVNDATE "" -// diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/sls_detector_defs.h b/slsDetectorSoftware/jungfrauDetectorServerNewStructure/sls_detector_defs.h deleted file mode 120000 index c5062e03f..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/sls_detector_defs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/sls_detector_defs.h \ No newline at end of file diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/sls_detector_funcs.h b/slsDetectorSoftware/jungfrauDetectorServerNewStructure/sls_detector_funcs.h deleted file mode 120000 index 844b67129..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/sls_detector_funcs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/sls_detector_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/sls_receiver_defs.h b/slsDetectorSoftware/jungfrauDetectorServerNewStructure/sls_receiver_defs.h deleted file mode 120000 index 1de31caf5..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/sls_receiver_defs.h +++ /dev/null @@ -1 +0,0 @@ -../../slsReceiverSoftware/include/sls_receiver_defs.h \ No newline at end of file diff --git a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/sls_receiver_funcs.h b/slsDetectorSoftware/jungfrauDetectorServerNewStructure/sls_receiver_funcs.h deleted file mode 120000 index c2ea4ded9..000000000 --- a/slsDetectorSoftware/jungfrauDetectorServerNewStructure/sls_receiver_funcs.h +++ /dev/null @@ -1 +0,0 @@ -../../slsReceiverSoftware/include/sls_receiver_funcs.h \ No newline at end of file