x y z and id are written to the udp header for eiger

This commit is contained in:
Dhanya Maliakal 2017-09-26 16:39:02 +02:00
parent 663fd557ff
commit 986826cbe9
13 changed files with 135 additions and 32 deletions

View File

@ -17,7 +17,6 @@
#include "xfs_types.h"
#include "xparameters.h"
#include "FebRegisterDefs.h"
@ -49,6 +48,8 @@
int Beb_activated = 1;
uint32_t Beb_detid = 0;
void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num){
@ -144,7 +145,6 @@ void Beb_Beb(){
// Local_LocalLinkInterface1(ll_beb,XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR);
// Beb_SetByteOrder();
}
@ -1124,9 +1124,88 @@ int Beb_GetBebFPGATemp()
}
void Beb_SetDetectorNumber(uint32_t detid) {
if(!Beb_activated)
return;
uint32_t swapid = Beb_swap_uint16(detid);
//cprintf(GREEN, "detector id %d swapped %d\n", detid, swapid);
u_int32_t* csp0base=0;
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_TEST_BASEADDR);
if(fd < 0){
cprintf(BG_RED,"Set Detector ID FAIL\n");
return;
}else{
uint32_t value = Beb_Read32(csp0base, UDP_HEADER_A_OFST);
value &= UDP_HEADER_X_MSK; // to keep previous x value
Beb_Write32(csp0base, UDP_HEADER_A_OFST, value | ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_OFST);
if((value & UDP_HEADER_ID_MSK) != ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK))
cprintf(BG_RED,"Set Detector ID FAIL\n");
Beb_close(fd,csp0base);
}
printf("detector id %d has been set in udp header\n", detid);
}
int Beb_SetDetectorPosition(int pos[]) {
if(!Beb_activated)
return OK;
pos[0] = Beb_swap_uint16(pos[0]);
pos[1] = Beb_swap_uint16(pos[1]);
pos[2] = Beb_swap_uint16(pos[2]);
int ret = FAIL;
//mapping new memory to read master top module configuration
u_int32_t* csp0base=0;
//open file pointer
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_TEST_BASEADDR);
if(fd < 0){
cprintf(BG_RED,"Set Detector Position FAIL\n");
return FAIL;
}else{
uint32_t value = 0;
ret = OK;
// x
value = Beb_Read32(csp0base, UDP_HEADER_A_OFST);
value &= UDP_HEADER_ID_MSK; // to keep previous id value
Beb_Write32(csp0base, UDP_HEADER_A_OFST, value | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_OFST);
if((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK))
ret = FAIL;
// y
// overwriting z anyway, so no need to look at previous z value
Beb_Write32(csp0base, UDP_HEADER_B_OFST, ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_OFST);
if(value != ((pos[1] << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
ret = FAIL;
// z
value = Beb_Read32(csp0base, UDP_HEADER_B_OFST);
value &= UDP_HEADER_Y_MSK; // to keep previous y value
Beb_Write32(csp0base, UDP_HEADER_B_OFST, value | ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_OFST);
if((value & UDP_HEADER_Z_MSK) != ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK))
ret = FAIL;
//close file pointer
Beb_close(fd,csp0base);
}
if (ret == OK)
printf("Position set to [%d, %d, %d]\n", Beb_swap_uint16(pos[0]), Beb_swap_uint16(pos[1]), Beb_swap_uint16(pos[2]));
return ret;
}
uint16_t Beb_swap_uint16( uint16_t val) {
return (val << 8) | (val >> 8 );
}
int Beb_open(u_int32_t** csp0base, u_int32_t offset){

View File

@ -89,6 +89,10 @@ struct BebInfo{
int Beb_GetBebFPGATemp();
void Beb_SetDetectorNumber(uint32_t detid);
int Beb_SetDetectorPosition(int pos[]);
uint16_t Beb_swap_uint16( uint16_t val);
int Beb_open(u_int32_t** csp0base, u_int32_t offset);
u_int32_t Beb_Read32 (u_int32_t* baseaddr, u_int32_t offset);
u_int32_t Beb_Write32 (u_int32_t* baseaddr, u_int32_t offset, u_int32_t data);

View File

@ -181,8 +181,17 @@
#define TEN_GIGA_RIGHT_TXN_DELAY_COUNTER 0x1c4
#define TEN_GIGA_RIGHT_FRAME_DELAY_COUNTER 0x1e4
// udp header (position, id)
#define UDP_HEADER_A_OFST 0x00C0
#define UDP_HEADER_B_OFST 0x00E0
#define UDP_HEADER_X_OFST (0)
#define UDP_HEADER_X_MSK (0xFFFF << UDP_HEADER_X_OFST)
#define UDP_HEADER_ID_OFST (16)
#define UDP_HEADER_ID_MSK (0xFFFF << UDP_HEADER_ID_OFST)
#define UDP_HEADER_Z_OFST (0)
#define UDP_HEADER_Z_MSK (0xFFFF << UDP_HEADER_Z_OFST)
#define UDP_HEADER_Y_OFST (16)
#define UDP_HEADER_Y_MSK (0xFFFF << UDP_HEADER_Y_OFST)

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
Repsitory UUID: 3c1eb747d1930d6d38030a5a607f72d3b58a7a21
Revision: 301
Branch: virtualclass
Repsitory UUID: 1701b20218363d885a7dc62f92591c7e1f4e2f1c
Revision: 304
Branch: developer
Last Changed Author: Dhanya_Maliakal
Last Changed Rev: 1549
Last Changed Date: 2017-08-30 15:06:49.000000002 +0200 ./Makefile.virtual
Last Changed Rev: 1589
Last Changed Date: 2017-09-26 09:25:28.000000002 +0200 ./Beb.c

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git"
//#define SVNREPPATH ""
#define SVNREPUUID "8b025fcf83af16926960d0d03c6b0c9562fdc74c"
//#define SVNREV 0x1584
#define SVNREPUUID "1701b20218363d885a7dc62f92591c7e1f4e2f1c"
//#define SVNREV 0x1589
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Dhanya_Maliakal"
#define SVNREV 0x1584
#define SVNDATE 0x20170921
#define SVNREV 0x1589
#define SVNDATE 0x20170926
//

View File

@ -61,6 +61,8 @@ enum masterFlags masterMode=IS_SLAVE;
int top = 0;
int master = 0;
int normal = 0;
uint32_t detid = 0;
@ -152,15 +154,7 @@ u_int64_t getFirmwareVersion() {
u_int32_t getDetectorNumber(){
u_int32_t res=0;
//execute and get address
char output[255];
FILE* sysFile = popen("more /home/root/executables/detid.txt", "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
sscanf(output,"%u",&res);
printf("detector id: %u\n",res);
return res;
return detid;
}
@ -234,6 +228,7 @@ void initControlServer(){
}
printf("FEB Initialization done\n");
Beb_Beb();
Beb_SetDetectorNumber(getDetectorNumber());
printf("BEB Initialization done\n");
@ -264,6 +259,14 @@ void getModuleConfiguration(){
else printf("*************** SLAVE ***************\n");
if(normal) printf("*************** NORMAL ***************\n");
else printf("*************** SPECIAL ***************\n");
// read detector id
char output[255];
FILE* sysFile = popen(IDFILECOMMAND, "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
sscanf(output,"%u",&detid);
printf("detector id: %u\n",detid);
}
@ -663,7 +666,7 @@ int setThresholdEnergy(int ev, int imod){
/* parameters - dac, adc, hv */
void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){
printf("Going to set dac %d to %d of imod %d with mv mode %d \n", (int)ind, val, imod, mV);
if(ind == VTHRESHOLD){
int ret[5];
setDAC(VCMP_LL,val,imod,mV,retval);
@ -912,6 +915,10 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
int setDetectorPosition(int pos[]) {
return Beb_SetDetectorPosition(pos);
}

View File

@ -78,7 +78,7 @@ int normal = 0;
/* basic tests */
void checkFirmwareCompatibility(){
void checkFirmwareCompatibility(int flag){
cprintf(BLUE,"\n\n"
"********************************************************\n"
"***************** EIGER Virtual Server *****************\n"
@ -589,7 +589,9 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
int setDetectorPosition(int pos[]) {
return OK;
}

View File

@ -12,7 +12,8 @@
#include <stdint.h>
#define GOODBYE (-200)
#define REQUIRED_FIRMWARE_VERSION (16)
#define REQUIRED_FIRMWARE_VERSION (21)
#define IDFILECOMMAND "more /home/root/executables/detid.txt"
/* Enums */
enum CLK_SPEED_INDEX {FULL_SPEED, HALF_SPEED, QUARTER_SPEED};

View File

@ -6414,8 +6414,8 @@ int slsDetector::configureMAC(){
bool sendpos = 0;
int pos[3]={0,0,0};
// only jungfrau send x, y and z in detector udp header
if (thisDetector->myDetectorType == JUNGFRAU) {
// only jungfrau and eiger, send x, y and z in detector udp header
if (thisDetector->myDetectorType == JUNGFRAU || thisDetector->myDetectorType == EIGER) {
sendpos = true;
int max = parentDet->getNumberOfDetectors(X);
if(!posId) {

View File

@ -152,7 +152,7 @@ long int calcChecksum(int sourceip, int destip);
#ifndef MYTHEND
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival);
#endif
#ifdef JUNGFRAUD
#if defined(JUNGFRAUD) || defined(EIGERD)
int setDetectorPosition(int pos[]);
#endif

View File

@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
extern int sockfd;

View File

@ -3408,7 +3408,7 @@ int configure_mac(int file_des) {
char arg[6][50];
memset(arg,0,sizeof(arg));
n = receiveData(file_des,arg,sizeof(arg),OTHER);
#ifdef JUNGFRAUD
#if defined(JUNGFRAUD) || defined(EIGERD)
int pos[3]={0,0,0};
n = receiveData(file_des,pos,sizeof(pos),INT32);
#endif
@ -3461,7 +3461,7 @@ int configure_mac(int file_des) {
printf("\n");
printf("Configuring MAC of module %d at port %x\n", imod, udpport);
#ifdef JUNGFRAUD
#if defined(JUNGFRAUD) || defined(EIGERD)
printf("Position: [%d,%d,%d]\n", pos[0],pos[1],pos[2]);
#endif
#endif
@ -3481,7 +3481,7 @@ int configure_mac(int file_des) {
}
else {
printf("Configure MAC successful\n");
#ifdef JUNGFRAUD
#if defined(JUNGFRAUD) || defined(EIGERD)
ret = setDetectorPosition(pos);
if (ret == FAIL) {
sprintf(mess,"could not set detector position\n");