diff --git a/slsDetectorSoftware/gotthardDetectorServer/Makefile b/slsDetectorSoftware/gotthardDetectorServer/Makefile index d0c04cf0a..976c997df 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/Makefile +++ b/slsDetectorSoftware/gotthardDetectorServer/Makefile @@ -6,7 +6,7 @@ CROSS = bfin-uclinux- CC = $(CROSS)gcc -CFLAGS += -Wall -DMCB_FUNCS -DVERBOSE #-DVERYVERBOSE #-DVIRTUAL +CFLAGS += -Wall -DMCB_FUNCS #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #INCLUDES= /usr/src/kernels/2.6.18-238.12.1.el5-i686/include #/home/l_maliakal_d/bfin/blackfin-linux-dist/linux-2.6.x/include diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c index ff5948a90..0d77fd9fb 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c @@ -880,6 +880,24 @@ int64_t getMeasurementTime(){ + +int loadImage(int index, short int ImageVals[]){ + u_int32_t address; + switch (index) { + case DARK_IMAGE : + address = DARK_IMAGE_REG; + break; + case GAIN_IMAGE : + address = GAIN_IMAGE_REG; + break; + } + int *ptr=(u_int16_t*)(CSP0BASE+address*2); + dma_memcpy(ptr,ImageVals ,2560); + return 0; +} + + + int64_t getProbes(){ u_int32_t shiftin=bus_r(GET_SHIFT_IN_REG); u_int32_t np=(shiftin >>PROBES_OFF) & PROBES_MASK; @@ -1185,9 +1203,9 @@ int configureMAC(int ipad,long long int macad,long long int servermacad,int ival while (sum>>16) sum = (sum & 0xffff) + (sum >> 16);// Fold 32-bit sum to 16 bits checksum = (~sum)&0xffff; mac_conf_regs->ip.ip_chksum = checksum; -#ifdef VERBOSE + //#ifdef VERBOSE printf("IP header checksum is 0x%x s\n",checksum); -#endif + //#endif mac_conf_regs->udp.udp_srcport = 0xE185; mac_conf_regs->udp.udp_destport = 0xC351; diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h index 3bef1d5a7..9a4de9b59 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h +++ b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h @@ -91,6 +91,8 @@ int64_t setProgress(); int64_t getActualTime(); int64_t getMeasurementTime(); +int loadImage(int index, short int ImageVals[]); + u_int32_t runBusy(void); u_int32_t runState(void); u_int32_t dataPresent(void); diff --git a/slsDetectorSoftware/gotthardDetectorServer/registers_g.h b/slsDetectorSoftware/gotthardDetectorServer/registers_g.h index bcd26202b..06d7f2f17 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/registers_g.h +++ b/slsDetectorSoftware/gotthardDetectorServer/registers_g.h @@ -94,6 +94,13 @@ + +//image +#define DARK_IMAGE_REG 0x81<<11 +#define GAIN_IMAGE_REG 0x82<<11 + + + //not used so far #define SPEED_REG 0x006000 #define SET_NBITS_REG 0x008000 diff --git a/slsDetectorSoftware/gotthardDetectorServer/server.c b/slsDetectorSoftware/gotthardDetectorServer/server.c index 58e7962a0..71d0777b2 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/server.c +++ b/slsDetectorSoftware/gotthardDetectorServer/server.c @@ -69,9 +69,9 @@ int main(int argc, char *argv[]) printf("Conenction accepted\n"); #endif retval=decode_function(fd); - //#ifdef VERY_VERBOSE +#ifdef VERY_VERBOSE printf("function executed\n"); - //#endif +#endif closeConnection(fd); #ifdef VERY_VERBOSE printf("connection closed\n"); diff --git a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c index 509102477..1092b5a74 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c @@ -160,6 +160,7 @@ int function_table() { 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; #ifdef VERBOSE /* for (i=0;i<256;i++){ printf("function %d located at %x\n",i,flist[i]); @@ -933,7 +934,7 @@ int set_dac(int file_des) { } if (ret==OK) { - if (differentClients==1 && lockStatus==1 && val!=-1) { + if (differentClients==1 && lockStatus==1) { ret=FAIL; sprintf(mess,"Detector locked by %s\n",lastClientIP); } else{ @@ -2781,3 +2782,77 @@ int configure_mac(int file_des) { return ret; } + + + +int load_image(int file_des) { + int retval; + int ret=OK; + int n; + int index; + short int ImageVals[1280]; + + sprintf(mess,"Can't load image\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,sizeof(ImageVals)); + 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 Dark image\n"); +#endif + break; + default: + printf("Unknown index %d\n",index); + sprintf(mess,"Unknown index %d\n",index); + ret=FAIL; + } + + printf("%d\n%d\n",ImageVals[0],ImageVals[1]); + + 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==FAIL) + printf("Loading image failed\n"); + 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; +} diff --git a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.h b/slsDetectorSoftware/gotthardDetectorServer/server_funcs.h index 3696e4468..9ef304923 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.h +++ b/slsDetectorSoftware/gotthardDetectorServer/server_funcs.h @@ -75,4 +75,6 @@ int update_client(int); int send_update(int); int configure_mac(int); +int load_image(int); + #endif