jungfrau works

This commit is contained in:
Dhanya Maliakal
2015-11-27 15:56:29 +01:00
parent ac53cb2ae4
commit 0958a4544e
7 changed files with 137 additions and 38 deletions

View File

@ -6,10 +6,10 @@
CROSS = bfin-uclinux-
CC = $(CROSS)gcc
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1#-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1 -DJUNGFRAU_DHANYA #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER
PROGS= jungfrauDetectorServer
PROGS= jungfrauDetectorServerTest
INSTDIR= /tftpboot
INSTMODE= 0777
@ -27,6 +27,11 @@ test: clean jungfrauADCTEst
boot: $(OBJS)
jungfrauDetectorServerTest: $(OBJS)
echo $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
jungfrauDetectorServer: $(OBJS)
echo $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)

View File

@ -1211,7 +1211,7 @@ int64_t setFrames(int64_t value){
}
int64_t getFrames(){
printf("gf");
/*printf("gf");*/
return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG);
}
@ -1671,7 +1671,8 @@ int configureMAC(uint32_t destip,uint64_t destmac,uint64_t sourcemac,int source
//int configureMAC(int ipad,long long int macad,long long int detectormacad, int detipad, int ival, int udpport){
uint32_t sourceport = 0x7e9a; // 0xE185;
//setheader(0xF452142F3200,0x00ad29ae39fd,0x0a000264,0x0A00020d ,0x8436, 0x7e9a);
//setheader(0xF452142F3200,0x00ad29ae39fd,0x0a000264,0x0A00020d ,0x8436, 0x7e9a);
/* void setheader(uint64_t destmac, uint64_t sourcemac, uint32_t destip, uint32_t sourceip, uint32_t destport, */
/* uint32_t sourceport){ */
@ -1717,7 +1718,11 @@ ip.ip_destip = destip;
bus_w(RX_UDPMACL_AREG,(destmac)&0xFFFFFFFF);//rx_udpmacL_AReg_c
bus_w(DETECTORMACH_AREG,(sourcemac>>32)&0xFFFFFFFF);//detectormacH_AReg_c
bus_w(DETECTORMACL_AREG,(sourcemac)&0xFFFFFFFF);//detectormacL_AReg_c
#ifdef JUNGFRAU_DHANYA
bus_w(UDPPORTS_AREG,((sourceport&0xFFFF)<<16)+(destport&0xFFFF));//udpports_AReg_c
#else
bus_w(UDPPORTS_AREG,((destport&0xFFFF)<<16)+(sourceport&0xFFFF));//udpports_AReg_c
#endif
bus_w(IPCHKSUM_AREG,(checksum&0xFFFF));//ipchksum_AReg_c
bus_w(CONTROL_REG,GB10_RESET_BIT);
@ -2102,12 +2107,12 @@ u_int16_t* fifo_read_event(int ns)
{
int i=0;//, j=0;
/* volatile u_int16_t volatile *dum; */
volatile u_int16_t a;
volatile u_int32_t val;
volatile u_int16_t a;
volatile u_int32_t val;
// volatile u_int32_t volatile *dum;
// volatile u_int32_t a;
bus_w16(DUMMY_REG,0); //
bus_w16(DUMMY_REG,0); //
/* #ifdef TIMEDBG */
/* gettimeofday(&tse,NULL); */
/* #endif */
@ -2122,9 +2127,9 @@ u_int16_t* fifo_read_event(int ns)
printf("no frame found and acquisition finished - exiting\n");
printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
return NULL;
} else {
// printf("status idle, look at me %x status %x\n", bus_r(LOOK_AT_ME_REG),runState());
break;
} else {
// printf("status idle, look at me %x status %x\n", bus_r(LOOK_AT_ME_REG),runState());
break;
}
}
a = bus_r(LOOK_AT_ME_REG);
@ -2136,19 +2141,19 @@ u_int16_t* fifo_read_event(int ns)
/* // tsss=tss; */
/* gettimeofday(&tss,NULL); */
/* printf("look for data = %ld usec\n", (tss.tv_usec) - (tse.tv_usec)); */
/* #endif */
}
// printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
/* dma_memcpy(now_ptr,values ,dataBytes); */
/* #else */
bus_w16(DUMMY_REG,1<<8); // read strobe to all fifos
bus_w16(DUMMY_REG,0);
bus_w16(DUMMY_REG,0);
// i=0;//
/* for (i=0; i<32; i++) { */
/* /\* while (((adcDisableMask&(3<<((i)*2)))>>((i)*2))==3) { *\/ */
/* /\* i++; *\/ */
/* /\* if (i>15) *\/ */
@ -2158,12 +2163,12 @@ u_int16_t* fifo_read_event(int ns)
/* bus_w16(DUMMY_REG,i); */
/* } */
/* val=*values; */
// bus_w16(DUMMY_REG,0); //
for (i=0; i<16; i++) {
// bus_w16(DUMMY_REG,0); //
for (i=0; i<16; i++) {
// bus_w16(DUMMY_REG,i);
// bus_r16(DUMMY_REG);
/* dum=(((u_int16_t*)(now_ptr))+i); */
@ -2174,36 +2179,36 @@ u_int16_t* fifo_read_event(int ns)
// a=*values;//bus_r(FIFO_DATA_REG);
// if ((adcDisableMask&(3<<(i*2)))==0) {
*((u_int32_t*)now_ptr)=*values;//bus_r(FIFO_DATA_REG);
if (i!=0 || ns!=0) {
a=0;
while (*((u_int32_t*)now_ptr)==*((u_int32_t*)(now_ptr)-1) && a++<10) {
// printf("******************** %d: fifo %d: new %08x old %08x\n ",ns, i, *((u_int32_t*)now_ptr),*((u_int32_t*)(now_ptr)-1));
*((u_int32_t*)now_ptr)=*values;
// printf("%d-",i);
}
}
now_ptr+=4;
// }
// }
/* while (((adcDisableMask&(3<<((i+1)*2)))>>((i+1)*2))==3) { */
/* i++; */
/* } */
// if (((adcDisableMask&(3<<((i+1)*2)))>>((i+1)*2))!=3) {
bus_w16(DUMMY_REG,i+1);
// }
// *(((u_int16_t*)(now_ptr))+i)=bus_r16(FIFO_DATA_REG);
}
// bus_w16(DUMMY_REG,0); //
}
// bus_w16(DUMMY_REG,0); //
/* #ifdef TIMEDBG */
/* gettimeofday(&tss,NULL); */
/* printf("read data loop = %ld usec\n",(tss.tv_usec) - (tse.tv_usec)); */
/* #endif */
#ifdef VERBOSE
printf("*");

View File

@ -1854,7 +1854,35 @@ int get_run_status(int file_des) {
retval= runState();
printf("\n\nSTATUS=%08x\n",retval);
#ifdef JUNGFRAU_DHANYA
if(!(retval&RUN_BUSY_BIT)){
if((retval&READMACHINE_BUSY_BIT) ){
printf("-----------------------------------READ MACHINE BUSY--------------------------\n");
s=TRANSMITTING;
}
//and readbusy=0,idle
else if((!(retval&0xffff))||(retval==SOME_FIFO_FULL_BIT)){
printf("-----------------------------------IDLE--------------------------------------\n");
s=IDLE;
} else {
printf("-----------------------------------Unknown status %08x--------------------------------------\n", retval);
s=ERROR;
ret=FAIL;
}
}
//if runbusy=1
else {
if (retval&WAITING_FOR_TRIGGER_BIT){
printf("-----------------------------------WAITING-----------------------------------\n");
s=WAITING;
}
else{
printf("-----------------------------------RUNNING-----------------------------------\n");
s=RUNNING;
}
}
#else
//error
if(retval&SOME_FIFO_FULL_BIT){
printf("-----------------------------------ERROR--------------------------------------x%0x\n",retval);
@ -1900,7 +1928,7 @@ int get_run_status(int file_des) {
}
}
#endif
if (ret!=OK) {
@ -1931,7 +1959,8 @@ int read_frame(int file_des) {
if (differentClients==1 && lockStatus==1) {
dataret=FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
sprintf(mess,"Detector locked by %s\n",lastClientIP);
printf("Warning: %s\n",mess);
sendDataOnly(file_des,&dataret,sizeof(dataret));
sendDataOnly(file_des,mess,sizeof(mess));
#ifdef VERBOSE
@ -1940,6 +1969,29 @@ int read_frame(int file_des) {
return dataret;
}
#ifdef JUNGFRAU_DHANYA1
while(runBusy()){
usleep(0);
if (getFrames() <= -1) {
printf("no frames left, but still busy\n");
}
}
if (getFrames() > -1) {
dataret=FAIL;
sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()));
printf("Warning: %s\n",mess);
}else{
dataret = FINISHED;
sprintf(mess,"acquisition successfully finished\n");
printf("%s\n",mess);
}
sendDataOnly(file_des,&dataret,sizeof(dataret));
sendDataOnly(file_des,mess,sizeof(mess));
//dataret is never ok to send databytes for jungfrau (not reading from fifo)
#else
p=fifo_read_frame();
if (p) {
nframes++;
@ -1971,6 +2023,10 @@ int read_frame(int file_des) {
sendDataOnly(file_des,&dataret,sizeof(dataret));
sendDataOnly(file_des,mess,sizeof(mess));
}
#endif
return dataret;
}