diff --git a/slsDetectorSoftware/gotthardDetectorServer/Makefile b/slsDetectorSoftware/gotthardDetectorServer/Makefile index 4b0bc3ab5..ca169b4fd 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/Makefile +++ b/slsDetectorSoftware/gotthardDetectorServer/Makefile @@ -5,7 +5,7 @@ CROSS = bfin-uclinux- CC = $(CROSS)gcc -CFLAGS += -Wall -DMCB_FUNCS -DVERBOSE -DVERYVERBOSE #-DVIRTUAL +CFLAGS += -Wall -DMCB_FUNCS# -DVERBOSE -DVERYVERBOSE #-DVIRTUAL PROGS= gotthardDetectorServer diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c index 75ce12d6a..04d47cf32 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c @@ -1513,7 +1513,8 @@ int configureMAC(int ipad,long long int macad,long long int servermacad,int ival u_int32_t runBusy(void) { - return bus_r(STATUS_REG)&RUN_BUSY_BIT; + + return (bus_r(STATUS_REG)&RUN_BUSY_BIT); } u_int32_t dataPresent(void) { @@ -1531,6 +1532,9 @@ u_int32_t runState(void) { #ifdef VERBOSE printf("status %04x\n",s); #endif + +/* if (s==0x62001) + exit(-1);*/ return s; } @@ -1674,26 +1678,39 @@ u_int32_t* fifo_read_event() #ifdef VERBOSE printf("before looping\n"); #endif - while(bus_r(LOOK_AT_ME_REG)==0) { -#ifdef VERBOSE - printf("Waiting for data status %x\n",runState()); -#endif - if (runBusy()==0) { - if (bus_r(LOOK_AT_ME_REG)==0) { -#ifdef VERBOSE - printf("no frame found - exiting "); - printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG)); -#endif - return NULL; - } else { + volatile u_int32_t t = bus_r(LOOK_AT_ME_REG); #ifdef VERBOSE - printf("no frame found %x status %x\n", bus_r(LOOK_AT_ME_REG),runState()); + printf("lookatmereg=x%x\n",t); #endif - break; - } - } - } + while ((t&0x1)==0) + { + t = bus_r(LOOK_AT_ME_REG); + if (!runBusy()) + return NULL; + } + + +/* while(bus_r(LOOK_AT_ME_REG)==0) { */ +/* #ifdef VERBOSE */ +/* printf("Waiting for data status %x\n",runState()); */ +/* #endif */ +/* // if (runBusy()==0) { */ +/* if (bus_r(LOOK_AT_ME_REG)==0) { */ +/* #ifdef VERBOSE */ +/* printf("no frame found - exiting "); */ +/* printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG)); */ + +/* #endif */ +/* return NULL; */ +/* } else { */ +/* #ifdef VERBOSE */ +/* printf("no frame found %x status %x\n", bus_r(LOOK_AT_ME_REG),runState()); */ +/* #endif */ +/* break; */ +/* } */ +/* //} */ +/* } */ #ifdef VERBOSE printf("before readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG)); #endif @@ -1701,21 +1718,7 @@ u_int32_t* fifo_read_event() dma_memcpy(now_ptr,values ,dataBytes); //memcpy(now_ptr,values ,dataBytes); -/* struct timeval t1,t2; - long long t; - gettimeofday(&t1,NULL); - if(geteuid()==0){ - struct sched_param sp; - memset(&sp,0,sizeof(sp)); - sp.sched_priority= sched_get_priority_max(SCHED_FIFO); - sched_setscheduler(0,SCHED_FIFO,&sp); - mlockall(MCL_CURRENT | MCL_FUTURE); - } - gettimeofday(&t2,NULL); - memmove(now_ptr,values ,dataBytes); - t = ((t2.tv_sec * 1000000) + t2.tv_usec) - ((t1.tv_sec * 1000000) + t1.tv_usec); - printf("\n*********Call took %lld us*******\n", t); -*/ + #ifdef VERYVERBOSE diff --git a/slsDetectorSoftware/gotthardDetectorServer/registers_g.h b/slsDetectorSoftware/gotthardDetectorServer/registers_g.h index 60f5eeab3..6f1f07a15 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/registers_g.h +++ b/slsDetectorSoftware/gotthardDetectorServer/registers_g.h @@ -149,13 +149,13 @@ #define DELAYAFTER_BIT 0x00000020 #define EXPOSING_BIT 0x00000040 #define COUNT_ENABLE_BIT 0x00000080 -#define RUNSTATE_0_BIT 0x00000100 -#define RUNSTATE_1_BIT 0x00000200 -#define RUNSTATE_2_BIT 0x00000400 +#define READSTATE_0_BIT 0x00000100 +#define READSTATE_1_BIT 0x00000200 +#define READSTATE_2_BIT 0x00000400 -#define READSTATE_0_BIT 0x00001000 -#define READSTATE_1_BIT 0x00002000 -#define READSTATE_2_BIT 0x00004000 +#define RUNSTATE_0_BIT 0x00001000 +#define RUNSTATE_1_BIT 0x00002000 +#define RUNSTATE_2_BIT 0x00004000 #define SOME_FIFO_FULL_BIT 0x00008000 // error! #define ALL_FIFO_EMPTY_BIT 0x00010000 // data ready #define RUNMACHINE_BUSY_BIT 0x00020000 diff --git a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c index 6e9ac7276..04fcb1c3d 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c @@ -1855,27 +1855,28 @@ int get_run_status(int file_des) { retval= runState(); printf("\n\nSTATUS=%08x\n",retval); - //if runbusy=0 - if(!(retval&0x00020000)){ + //error + if(retval&0x8000){ + printf("-----------------------------------ERROR--------------------------------------x%0x\n",retval); + s=ERROR; + } + //runbusy=0 + else if(!(retval&0x20000)){ //and readbusy=1, its last frame read - if(retval&0x00040000){ + if(retval&0x40000){ printf("-----------------------------------LAST FRAME READ--------------------------\n"); s=TRANSMITTING; } //and readbusy=0,idle - else if(!(retval&0x000FFFFF)){ - //if(!(retval&0x00000001)){ + else if(!(retval&0xFFFFF)){ + //if(!(retval&0x00000001)){ printf("-----------------------------------IDLE--------------------------------------\n"); s=IDLE; } - else { - printf("-----------------------------------ERROR--------------------------------------x%0x\n",retval); - s=ERROR; - } } //if runbusy=1 else { - if (retval&0x00000008){ + if (retval&0x8){ printf("-----------------------------------WAITING-----------------------------------\n"); s=WAITING; } @@ -1931,7 +1932,9 @@ int read_frame(int file_des) { sprintf(mess,"Detector locked by %s\n",lastClientIP); sendDataOnly(file_des,&dataret,sizeof(dataret)); sendDataOnly(file_des,mess,sizeof(mess)); +#ifdef VERBOSE printf("dataret %d\n",dataret); +#endif return dataret; } @@ -1946,8 +1949,8 @@ int read_frame(int file_des) { sendDataOnly(file_des,dataretval,dataBytes); #ifdef VERBOSE printf("sent %d bytes \n",dataBytes); -#endif printf("dataret OK\n"); +#endif return OK; } else { //might add delay????