mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-11 12:27:14 +02:00
added the dark and gain image funcitions
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@120 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
CROSS = bfin-uclinux-
|
CROSS = bfin-uclinux-
|
||||||
CC = $(CROSS)gcc
|
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
|
#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
|
#/home/l_maliakal_d/bfin/blackfin-linux-dist/linux-2.6.x/include
|
||||||
|
@ -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(){
|
int64_t getProbes(){
|
||||||
u_int32_t shiftin=bus_r(GET_SHIFT_IN_REG);
|
u_int32_t shiftin=bus_r(GET_SHIFT_IN_REG);
|
||||||
u_int32_t np=(shiftin >>PROBES_OFF) & PROBES_MASK;
|
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
|
while (sum>>16) sum = (sum & 0xffff) + (sum >> 16);// Fold 32-bit sum to 16 bits
|
||||||
checksum = (~sum)&0xffff;
|
checksum = (~sum)&0xffff;
|
||||||
mac_conf_regs->ip.ip_chksum = checksum;
|
mac_conf_regs->ip.ip_chksum = checksum;
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
printf("IP header checksum is 0x%x s\n",checksum);
|
printf("IP header checksum is 0x%x s\n",checksum);
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
mac_conf_regs->udp.udp_srcport = 0xE185;
|
mac_conf_regs->udp.udp_srcport = 0xE185;
|
||||||
mac_conf_regs->udp.udp_destport = 0xC351;
|
mac_conf_regs->udp.udp_destport = 0xC351;
|
||||||
|
@ -91,6 +91,8 @@ int64_t setProgress();
|
|||||||
int64_t getActualTime();
|
int64_t getActualTime();
|
||||||
int64_t getMeasurementTime();
|
int64_t getMeasurementTime();
|
||||||
|
|
||||||
|
int loadImage(int index, short int ImageVals[]);
|
||||||
|
|
||||||
u_int32_t runBusy(void);
|
u_int32_t runBusy(void);
|
||||||
u_int32_t runState(void);
|
u_int32_t runState(void);
|
||||||
u_int32_t dataPresent(void);
|
u_int32_t dataPresent(void);
|
||||||
|
@ -94,6 +94,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//image
|
||||||
|
#define DARK_IMAGE_REG 0x81<<11
|
||||||
|
#define GAIN_IMAGE_REG 0x82<<11
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//not used so far
|
//not used so far
|
||||||
#define SPEED_REG 0x006000
|
#define SPEED_REG 0x006000
|
||||||
#define SET_NBITS_REG 0x008000
|
#define SET_NBITS_REG 0x008000
|
||||||
|
@ -69,9 +69,9 @@ int main(int argc, char *argv[])
|
|||||||
printf("Conenction accepted\n");
|
printf("Conenction accepted\n");
|
||||||
#endif
|
#endif
|
||||||
retval=decode_function(fd);
|
retval=decode_function(fd);
|
||||||
//#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
printf("function executed\n");
|
printf("function executed\n");
|
||||||
//#endif
|
#endif
|
||||||
closeConnection(fd);
|
closeConnection(fd);
|
||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
printf("connection closed\n");
|
printf("connection closed\n");
|
||||||
|
@ -160,6 +160,7 @@ int function_table() {
|
|||||||
flist[F_GET_LAST_CLIENT_IP]=&get_last_client_ip;
|
flist[F_GET_LAST_CLIENT_IP]=&get_last_client_ip;
|
||||||
flist[F_UPDATE_CLIENT]=&update_client;
|
flist[F_UPDATE_CLIENT]=&update_client;
|
||||||
flist[F_CONFIGURE_MAC]=&configure_mac;
|
flist[F_CONFIGURE_MAC]=&configure_mac;
|
||||||
|
flist[F_LOAD_IMAGE]=&load_image;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
/* for (i=0;i<256;i++){
|
/* for (i=0;i<256;i++){
|
||||||
printf("function %d located at %x\n",i,flist[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 (ret==OK) {
|
||||||
if (differentClients==1 && lockStatus==1 && val!=-1) {
|
if (differentClients==1 && lockStatus==1) {
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||||
} else{
|
} else{
|
||||||
@ -2781,3 +2782,77 @@ int configure_mac(int file_des) {
|
|||||||
return ret;
|
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;
|
||||||
|
}
|
||||||
|
@ -75,4 +75,6 @@ int update_client(int);
|
|||||||
int send_update(int);
|
int send_update(int);
|
||||||
int configure_mac(int);
|
int configure_mac(int);
|
||||||
|
|
||||||
|
int load_image(int);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user