some changes for better testing in eiger server, including using set receiver, and changed to top/bottom instead of master slave

This commit is contained in:
Maliakal Dhanya 2014-11-28 14:26:19 +01:00
parent ceb2d28281
commit 4649de2742
11 changed files with 346 additions and 246 deletions

View File

@ -185,7 +185,7 @@ int Beb_InitBebInfos(){//file name at some point
int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig, char* src_mac, char* src_ip,unsigned int src_port){
//so that the values can be reset externally for now....
unsigned int i = Beb_GetBebInfoIndex(beb_number);
unsigned int i = 1;/*Beb_GetBebInfoIndex(beb_number);*/
/******* if(!i) return 0;****************************/ //i must be greater than 0, zero is the global send
BebInfo_SetHeaderInfo(&beb_infos[i],ten_gig,src_mac,src_ip,src_port);
@ -262,9 +262,10 @@ unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb){
unsigned int i;
for(i=1;i<bebInfoSize;i++)
if(beb_numb==BebInfo_GetBebNumber(&beb_infos[i])){
printf("found beb index:%d, for beb number:%d\n",i,beb_numb);
printf("*****found beb index:%d, for beb number:%d\n",i,beb_numb);
return i;
}
printf("*****Returning 0\n");
return 0;
}
@ -324,7 +325,8 @@ int Beb_SetByteOrder(){
int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, char* dst_mac, char* dst_ip, unsigned int dst_port){
unsigned int i = Beb_GetBebInfoIndex(beb_number);
unsigned int i = 1;/*Beb_GetBebInfoIndex(beb_number);*/
/***********************************if(!i) return 0; *************************************///i must be greater than 0, zero is the global send
Beb_send_ndata = 14;
@ -341,7 +343,7 @@ int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header
int Beb_SetHeaderData(unsigned int beb_number, int ten_gig, char* dst_mac, char* dst_ip, unsigned int dst_port){
unsigned int i = Beb_GetBebInfoIndex(beb_number);
unsigned int i = 1;/*Beb_GetBebInfoIndex(beb_number);*/
/***********************************if(!i) return 0; *************************************///i must be greater than 0, zero is the global send
return Beb_SetHeaderData1(BebInfo_GetSrcMAC(&beb_infos[i],ten_gig),BebInfo_GetSrcIP(&beb_infos[i],ten_gig),BebInfo_GetSrcPort(&beb_infos[i],ten_gig),dst_mac,dst_ip,dst_port);
}
@ -473,7 +475,7 @@ void Beb_AdjustIPChecksum(struct udp_header_type *ip){
int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty){
unsigned int i = Beb_GetBebInfoIndex(beb_number); //zero is the global send
unsigned int i = 1;/*Beb_GetBebInfoIndex(beb_number); //zero is the global send*/
Beb_send_ndata = 3;
if(left_right == 1) Beb_send_data[0] = 0x00040000;

View File

@ -316,7 +316,7 @@ int Feb_Control_ReadSetUpFileToAddModules(char* file_name){
exit(0);
}
printf ("str:%s len:%d i0:%d i1:%d i2:%d\n", str, strlen(str),i0,i1,i2);
if(!Feb_Control_AddModule1(i0,i1,i2,0)){
if(!Feb_Control_AddModule1(i0,1,i1,i2,0)){
printf("Error adding module, parameter was assigned twice in setup file: %s.\n",file_name);
exit(0);
}
@ -329,26 +329,11 @@ int Feb_Control_ReadSetUpFileToAddModules(char* file_name){
}
printf ("str:%s len:%d i0:%d i1:%d i2:%d\n", str, strlen(str),i0,i1,i2);
/**Added by dhanya*/
if(i1 == 0){
/*Feb_Control_AddModule1(0,0xff,0,1);//global send
Feb_Control_PrintModuleList();*/
if(!Feb_Control_AddModule1(i0,i1,i2,i2,1)){
printf("Error adding module, parameter was assigned twice in setup file: %s.\n",file_name);
exit(0);
}
if(!Feb_Control_AddModule1(i0,i2,0,1)){
printf("Error adding module, parameter was assigned twice in setup file: %s.\n",file_name);
exit(0);
}
}else{
/* Feb_Control_AddModule1(0,0,0xff,1);//global send
Feb_Control_PrintModuleList();*/
if(!Feb_Control_AddModule1(i0,0,i2,1)){
printf("Error adding module, parameter was assigned twice in setup file: %s.\n",file_name);
exit(0);
}
}
//memaddress++;
Feb_Control_PrintModuleList();
@ -432,9 +417,9 @@ int Feb_Control_CheckModuleAddresses(struct Module* m){
}
int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address){
return Feb_Control_AddModule1(module_number,top_address,0,1);
return Feb_Control_AddModule1(module_number,0,top_address,0,1);
}
int Feb_Control_AddModule1(unsigned int module_number, unsigned int top_address, unsigned int bottom_address, int half_module){ //bot_address 0 for half module
int Feb_Control_AddModule1(unsigned int module_number, int bottom_enable, unsigned int top_address, unsigned int bottom_address, int half_module){ //bot_address 0 for half module
int parameters_ok = 1;
unsigned int pre_module_index = 0;
if(Feb_Control_GetModuleIndex(module_number,&pre_module_index)){
@ -452,7 +437,7 @@ int Feb_Control_AddModule1(unsigned int module_number, unsigned int top_address,
/* if((half_module)&& (top_address != 1)) Module_Module(m,module_number,top_address);
else if(half_module) Module_ModuleBottom(m,module_number,top_address);*/
if ((half_module)&& (!bottom_address)) Module_Module(m,module_number,top_address);
if ((half_module)&& (!bottom_enable)) Module_Module(m,module_number,top_address);
else if (half_module) Module_ModuleBottom(m,module_number,bottom_address);
else Module_Module1(m,module_number,top_address,bottom_address);
@ -1100,16 +1085,18 @@ unsigned int Feb_Control_AddressToAll(){printf("in Feb_Control_AddressToAll()\n"
if(moduleSize==0) return 0;
if(Module_BottomAddressIsValid(&modules[1])){
/*
if(Module_BottomAddressIsValid(&modules[1])){
printf("************* bottom\n");
//if(Feb_Control_am_i_master)
return Module_GetBottomLeftAddress(&modules[1])|Module_GetBottomRightAddress(&modules[1]);
// else return 0;
}
printf("************* top\n");
// if(Feb_Control_am_i_master)
*/
//return Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1]);
return Module_GetTopLeftAddress(&modules[0])|Module_GetTopRightAddress(&modules[0]);
// else return 0;
}
@ -1165,7 +1152,12 @@ int Feb_Control_AcquisitionInProgress(){
}else{
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[ind]),&status_reg_r)))
{printf("ERROR: Trouble reading Status register. top right address\n");return 0;}
{printf("ERROR: Trouble reading Status register. top right address\n");
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[0]),&status_reg_r)))
printf("ERROR: error with normal register\n");
else
printf("**********NO error reading normal register\n");
return 0;}
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopLeftAddress(&modules[ind]),&status_reg_l)))
{printf("ERROR: Trouble reading Status register. top left address\n");return 0;}
}
@ -1494,11 +1486,64 @@ int Feb_Control_WriteNRead(char* message, int length, int max_length){
}
*/
int Feb_Control_PrepareForAcquisition(){//return 1;
static unsigned int reg_nums[20];
static unsigned int reg_vals[20];
Feb_Control_PrintAcquisitionSetup();
// if(!Reset()||!ResetDataStream()){
if(!Feb_Control_Reset()){
printf("Trouble reseting daq or data stream...\n");;
return 0;
}
if(!Feb_Control_SetStaticBits1(Feb_Control_staticBits&(DAQ_STATIC_BIT_M4|DAQ_STATIC_BIT_M8))){
printf("Trouble setting static bits ...\n");;
return 0;
}
if(!Feb_Control_SendBitModeToBebServer()){
printf("Trouble sending static bits to server ...\n");;
return 0;
}
if(!Feb_Control_ResetChipCompletely()){
printf("Trouble resetting chips ...\n");;
return 0;
}
reg_nums[0]=DAQ_REG_CTRL;
reg_vals[0]=0;
reg_nums[1]=DAQ_REG_NEXPOSURES;
reg_vals[1]=Feb_Control_nimages;
reg_nums[2]=DAQ_REG_EXPOSURE_TIMER;
reg_vals[2]=Feb_Control_ConvertTimeToRegister(Feb_Control_exposure_time_in_sec);
reg_nums[3]=DAQ_REG_EXPOSURE_REPEAT_TIMER;
reg_vals[3]=Feb_Control_ConvertTimeToRegister(Feb_Control_exposure_period_in_sec);
reg_nums[4]=DAQ_REG_CHIP_CMDS;
reg_vals[4]=(Feb_Control_acquireNReadoutMode|Feb_Control_triggerMode|Feb_Control_externalEnableMode|Feb_Control_subFrameMode);
// if(!Feb_Interface_WriteRegisters((Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1])),20,reg_nums,reg_vals,0,0)){
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),5,reg_nums,reg_vals,0,0)){
printf("Trouble starting acquisition....\n");;
return 0;
}
//*/
/* if(!Feb_Control_am_i_master)
Feb_Control_StartAcquisition();*/
return 1;
}
int Feb_Control_StartAcquisition(){printf("****** starting acquisition********* \n");
static unsigned int reg_nums[20];
static unsigned int reg_vals[20];
/*
Feb_Control_PrintAcquisitionSetup();
// if(!Reset()||!ResetDataStream()){
@ -1531,37 +1576,33 @@ int Feb_Control_StartAcquisition(){printf("****** starting acquisition*********
reg_vals[2]=Feb_Control_ConvertTimeToRegister(Feb_Control_exposure_time_in_sec);
reg_nums[3]=DAQ_REG_EXPOSURE_REPEAT_TIMER;
reg_vals[3]=Feb_Control_ConvertTimeToRegister(Feb_Control_exposure_period_in_sec);
///*
*/
/*
reg_nums[4]=DAQ_REG_CHIP_CMDS;
reg_vals[4]=(Feb_Control_acquireNReadoutMode|Feb_Control_triggerMode|Feb_Control_externalEnableMode|Feb_Control_subFrameMode);
*/
/*
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),4,reg_nums,reg_vals,0,0)){
printf("Trouble starting acquisition....\n");;
return 0;
}
unsigned int masterHalfModuleMode = 0;
reg_nums[0]=DAQ_REG_CHIP_CMDS;
reg_vals[0]=(masterHalfModuleMode|Feb_Control_acquireNReadoutMode|Feb_Control_triggerMode|Feb_Control_externalEnableMode|Feb_Control_subFrameMode);
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),1,reg_nums,reg_vals,0,0)){
printf("Trouble writing commands....\n");;
return 0;
}
/*
masterHalfModuleMode = 0x80000000;
reg_nums[0]=DAQ_REG_CHIP_CMDS;
reg_vals[0]=(masterHalfModuleMode|Feb_Control_acquireNReadoutMode|Feb_Control_triggerMode|Feb_Control_externalEnableMode|Feb_Control_subFrameMode);
if(!Feb_Interface_WriteRegisters((Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1])),1,reg_nums,reg_vals,0,0)){
printf("Trouble writing commands....\n");;
return 0;
}
*/
//if(!Feb_Interface_WriteRegisters((Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1])),1,reg_nums,reg_vals,0,0)){
///*
int i;
for(i=0;i<14;i++){
reg_nums[i]=DAQ_REG_CTRL;
@ -1574,12 +1615,22 @@ int Feb_Control_StartAcquisition(){printf("****** starting acquisition*********
printf("Trouble starting acquisition....\n");;
return 0;
}
*/
///*
int i;
for(i=0;i<14;i++){
reg_nums[i]=DAQ_REG_CTRL;
reg_vals[i]=0;
}
reg_nums[14]=DAQ_REG_CTRL;
reg_vals[14]=ACQ_CTRL_START;
//*/
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),15,reg_nums,reg_vals,0,0)){
printf("Trouble starting acquisition....\n");;
return 0;
}
//*/
/*
reg_nums[4]=DAQ_REG_CHIP_CMDS;
reg_vals[4]=(Feb_Control_acquireNReadoutMode|Feb_Control_triggerMode|Feb_Control_externalEnableMode|Feb_Control_subFrameMode);
int i;
for(i=5;i<19;i++){
reg_nums[i]=DAQ_REG_CTRL;
@ -1588,12 +1639,13 @@ int Feb_Control_StartAcquisition(){printf("****** starting acquisition*********
reg_nums[19]=DAQ_REG_CTRL;
reg_vals[19]=ACQ_CTRL_START;
// if(!Feb_Interface_WriteRegisters((Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1])),20,reg_nums,reg_vals,0,0)){
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),20,reg_nums,reg_vals,0,0)){
printf("Trouble starting acquisition....\n");;
return 0;
}
printf("Trouble starting acquisition....\n");;
return 0;
}
*/
//*/
return 1;
}

View File

@ -77,7 +77,7 @@ void Feb_Control_Set_Master();
int Feb_Control_CheckModuleAddresses(struct Module* m);
int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address);
/*int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address, unsigned int bottom_address, int half_module=0);*/
int Feb_Control_AddModule1(unsigned int module_number, unsigned int top_address, unsigned int bottom_address, int half_module);
int Feb_Control_AddModule1(unsigned int module_number, int bottom_enable, unsigned int top_address, unsigned int bottom_address, int half_module);
int Feb_Control_GetDACNumber(char* s, unsigned int* n);
int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch, unsigned int* value);
@ -147,6 +147,8 @@ void Feb_Control_Set_Master();
int Feb_Control_Reset();
int Feb_Control_PrepareForAcquisition();
int Feb_Control_StartAcquisition();
int Feb_Control_StopAcquisition();
int Feb_Control_AcquisitionInProgress();

View File

@ -17,23 +17,23 @@
Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr){
// printf("\n v 1 \n");
printf("Initialize PLB LL FIFOs\n");
ll->ll_fifo_base=0;
ll->ll_fifo_ctrl_reg=0;
if(Local_Init(ll,ll_fifo_badr)){
Local_Reset(ll);
printf("\tFIFO Status : 0x%08x\n",Local_StatusVector(ll));
}else printf("\tError LocalLink Mappping : 0x%08x\n",ll_fifo_badr);
// printf("\n v 1 \n");
printf("Initialize PLB LL FIFOs\n");
ll->ll_fifo_base=0;
ll->ll_fifo_ctrl_reg=0;
if(Local_Init(ll,ll_fifo_badr)){
Local_Reset(ll);
printf("\tFIFO Status : 0x%08x\n",Local_StatusVector(ll));
}else printf("\tError LocalLink Mappping : 0x%08x\n",ll_fifo_badr);
printf("\n\n");
printf("\n\n");
}
/*~LocalLinkInterface(){};*/
Local_LocalLinkInterface(struct LocalLinkInterface* ll){
printf("Initialize new memory\n");
}
printf("Initialize new memory\n");
}
int Local_InitNewMemory (struct LocalLinkInterface* ll,unsigned int addr, int ifg){
unsigned int CSP0BASE;
@ -63,218 +63,218 @@ int Local_InitNewMemory (struct LocalLinkInterface* ll,unsigned int addr, int if
printf("ifg_control=%02x\n",*ptr1);
*ptr1=ifg;
*ptr1=ifg;
printf("ifg_control new=%02x\n",*ptr1);
close(fd);
*/
*/
return 1;
}
int Local_Init(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr){
int fd;
void *plb_ll_fifo_ptr;
int fd;
void *plb_ll_fifo_ptr;
if ((fd=open("/dev/mem", O_RDWR)) < 0){
fprintf(stderr, "Could not open /dev/mem\n");
return 0;
}
if ((fd=open("/dev/mem", O_RDWR)) < 0){
fprintf(stderr, "Could not open /dev/mem\n");
return 0;
}
plb_ll_fifo_ptr = mmap(0, getpagesize(), PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, ll_fifo_badr);
close(fd);
plb_ll_fifo_ptr = mmap(0, getpagesize(), PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, ll_fifo_badr);
close(fd);
if (plb_ll_fifo_ptr == MAP_FAILED){
perror ("mmap");
return 0;
}
if (plb_ll_fifo_ptr == MAP_FAILED){
perror ("mmap");
return 0;
}
ll->ll_fifo_base = (xfs_u32) plb_ll_fifo_ptr;
ll->ll_fifo_ctrl_reg = 0;
ll->ll_fifo_base = (xfs_u32) plb_ll_fifo_ptr;
ll->ll_fifo_ctrl_reg = 0;
return 1;
return 1;
}
int Local_Reset(struct LocalLinkInterface* ll){
return Local_Reset1(ll,PLB_LL_FIFO_CTRL_RESET_STD);
return Local_Reset1(ll,PLB_LL_FIFO_CTRL_RESET_STD);
}
int Local_Reset1(struct LocalLinkInterface* ll,unsigned int rst_mask){
ll->ll_fifo_ctrl_reg |= rst_mask;
printf("\tCTRL Register bits: 0x%08x\n",ll->ll_fifo_ctrl_reg);
ll->ll_fifo_ctrl_reg |= rst_mask;
printf("\tCTRL Register bits: 0x%08x\n",ll->ll_fifo_ctrl_reg);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
ll->ll_fifo_ctrl_reg &= (~rst_mask);
ll->ll_fifo_ctrl_reg &= (~rst_mask);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
// printf("FIFO CTRL Address: 0x%08x\n FIFO CTRL Register: 0x%08x\n",PLB_LL_FIFO_REG_CTRL,plb_ll_fifo[PLB_LL_FIFO_REG_CTRL]);
return 1;
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
// printf("FIFO CTRL Address: 0x%08x\n FIFO CTRL Register: 0x%08x\n",PLB_LL_FIFO_REG_CTRL,plb_ll_fifo[PLB_LL_FIFO_REG_CTRL]);
return 1;
}
unsigned int Local_StatusVector(struct LocalLinkInterface* ll){
return HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
return HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
}
int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer){
// note: buffer must be word (4 byte) aligned
// frame_len in byte
int vacancy=0;
int i;
int words_send = 0;
int last_word;
unsigned int *word_ptr;
unsigned int fifo_ctrl;
xfs_u32 status;
// note: buffer must be word (4 byte) aligned
// frame_len in byte
int vacancy=0;
int i;
int words_send = 0;
int last_word;
unsigned int *word_ptr;
unsigned int fifo_ctrl;
xfs_u32 status;
if (buffer_len < 1) return -1;
if (buffer_len < 1) return -1;
last_word = (buffer_len-1)/4;
word_ptr = (unsigned int *)buffer;
last_word = (buffer_len-1)/4;
word_ptr = (unsigned int *)buffer;
while (words_send <= last_word)
{
while (!vacancy)//wait for Fifo to be empty again
{
status = HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
if((status & PLB_LL_FIFO_STATUS_ALMOSTFULL) == 0) vacancy = 1;
}
//Just to know: #define PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS 100
for (i=0; ((i<PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS) && (words_send <= last_word)); i++)
while (words_send <= last_word)
{
fifo_ctrl = 0;
if (words_send == 0)
{
fifo_ctrl = PLB_LL_FIFO_CTRL_LL_SOF;//announce the start of file
}
while (!vacancy)//wait for Fifo to be empty again
{
status = HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
if((status & PLB_LL_FIFO_STATUS_ALMOSTFULL) == 0) vacancy = 1;
}
if (words_send == last_word)
{
fifo_ctrl |= (PLB_LL_FIFO_CTRL_LL_EOF | (( (buffer_len-1)<<PLB_LL_FIFO_CTRL_LL_REM_SHIFT) & PLB_LL_FIFO_CTRL_LL_REM) );
}
Local_ctrl_reg_write_mask(ll,PLB_LL_FIFO_CTRL_LL_MASK,fifo_ctrl);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_FIFO,word_ptr[words_send++]);
//Just to know: #define PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS 100
for (i=0; ((i<PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS) && (words_send <= last_word)); i++)
{
fifo_ctrl = 0;
if (words_send == 0)
{
fifo_ctrl = PLB_LL_FIFO_CTRL_LL_SOF;//announce the start of file
}
if (words_send == last_word)
{
fifo_ctrl |= (PLB_LL_FIFO_CTRL_LL_EOF | (( (buffer_len-1)<<PLB_LL_FIFO_CTRL_LL_REM_SHIFT) & PLB_LL_FIFO_CTRL_LL_REM) );
}
Local_ctrl_reg_write_mask(ll,PLB_LL_FIFO_CTRL_LL_MASK,fifo_ctrl);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_FIFO,word_ptr[words_send++]);
}
}
}
return buffer_len;
return buffer_len;
}
int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer){
static unsigned int buffer_ptr = 0;
// note: buffer must be word (4 byte) aligned
// frame_len in byte
int len;
unsigned int *word_ptr;
unsigned int status;
volatile unsigned int fifo_val;
int sof = 0;
static unsigned int buffer_ptr = 0;
// note: buffer must be word (4 byte) aligned
// frame_len in byte
int len;
unsigned int *word_ptr;
unsigned int status;
volatile unsigned int fifo_val;
int sof = 0;
word_ptr = (unsigned int *)buffer;
do
{
status = HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
if (!(status & PLB_LL_FIFO_STATUS_EMPTY))
word_ptr = (unsigned int *)buffer;
do
{
if (status & PLB_LL_FIFO_STATUS_LL_SOF)
{
if (buffer_ptr)
{
buffer_ptr = 0;
return -1; // buffer overflow
}
// printf(">>>> SOF\n\r");
buffer_ptr = 0;
sof = 1;
}
status = HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
fifo_val = HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_FIFO); //read from fifo
if ((buffer_ptr > 0) || sof)
{
if ( (buffer_len >> 2) > buffer_ptr)
if (!(status & PLB_LL_FIFO_STATUS_EMPTY))
{
word_ptr[buffer_ptr++] = fifo_val; //write to buffer
}
else
{
buffer_ptr = 0;
return -2; // buffer overflow
}
if (status & PLB_LL_FIFO_STATUS_LL_SOF)
{
if (buffer_ptr)
{
buffer_ptr = 0;
return -1; // buffer overflow
}
// printf(">>>> SOF\n\r");
buffer_ptr = 0;
sof = 1;
}
if (status & PLB_LL_FIFO_STATUS_LL_EOF)
{
len = (buffer_ptr << 2) -3 + ( (status & PLB_LL_FIFO_STATUS_LL_REM)>>PLB_LL_FIFO_STATUS_LL_REM_SHIFT );
// printf(">>>>status=0x%08x EOF len = %d \n\r\n\r",status, len);
buffer_ptr = 0;
return len;
}
fifo_val = HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_FIFO); //read from fifo
}
if ((buffer_ptr > 0) || sof)
{
if ( (buffer_len >> 2) > buffer_ptr)
{
word_ptr[buffer_ptr++] = fifo_val; //write to buffer
}
else
{
buffer_ptr = 0;
return -2; // buffer overflow
}
if (status & PLB_LL_FIFO_STATUS_LL_EOF)
{
len = (buffer_ptr << 2) -3 + ( (status & PLB_LL_FIFO_STATUS_LL_REM)>>PLB_LL_FIFO_STATUS_LL_REM_SHIFT );
// printf(">>>>status=0x%08x EOF len = %d \n\r\n\r",status, len);
buffer_ptr = 0;
return len;
}
}
}
}
}
while(!(status & PLB_LL_FIFO_STATUS_EMPTY));
while(!(status & PLB_LL_FIFO_STATUS_EMPTY));
return 0;
return 0;
}
int Local_ctrl_reg_write_mask(struct LocalLinkInterface* ll,unsigned int mask, unsigned int val){
// printf("Fifo CTRL Reg(1): 0x%08x\n",plb_ll_fifo_ctrl_reg);
ll->ll_fifo_ctrl_reg &= (~mask);
//printf("Fifo CTRL Reg(2): 0x%08x\n",plb_ll_fifo_ctrl_reg);
ll->ll_fifo_ctrl_reg |= ( mask & val);
// printf("Fifo CTRL Reg: 0x%08x\n",plb_ll_fifo_ctrl_reg);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
// printf("Fifo STAT Reg: 0x%08x\n", plb_ll_fifo[PLB_LL_FIFO_REG_STATUS]);
return 1;
// printf("Fifo CTRL Reg(1): 0x%08x\n",plb_ll_fifo_ctrl_reg);
ll->ll_fifo_ctrl_reg &= (~mask);
//printf("Fifo CTRL Reg(2): 0x%08x\n",plb_ll_fifo_ctrl_reg);
ll->ll_fifo_ctrl_reg |= ( mask & val);
// printf("Fifo CTRL Reg: 0x%08x\n",plb_ll_fifo_ctrl_reg);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
// printf("Fifo STAT Reg: 0x%08x\n", plb_ll_fifo[PLB_LL_FIFO_REG_STATUS]);
return 1;
}
int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer){
int len;
unsigned int rec_buff_len = 4096;
unsigned int rec_buffer[4097];
int len;
unsigned int rec_buff_len = 4096;
unsigned int rec_buffer[4097];
Local_Write(ll,buffer_len,buffer);
usleep(10000);
Local_Write(ll,buffer_len,buffer);
usleep(10000);
do{
len = Local_Read(ll,rec_buff_len,rec_buffer);
printf("receive length: %i\n",len);
do{
len = Local_Read(ll,rec_buff_len,rec_buffer);
printf("receive length: %i\n",len);
if (len > 0){
rec_buffer[len]=0;
printf((char*) rec_buffer);
printf("\n");
}
} while(len > 0);
if (len > 0){
rec_buffer[len]=0;
printf((char*) rec_buffer);
printf("\n");
}
} while(len > 0);
printf("\n\n\n\n");
return 1;
printf("\n\n\n\n");
return 1;
}
void Local_llfifo_print_frame(struct LocalLinkInterface* ll,unsigned char* fbuff, int len){
int i;
printf("\n\r----Frame of len : %d Byte\n\r",len);
for(i=0;i<len;i++){
printf("0x%02x ",fbuff[i] );
if ((i&0xf) == 0x7) printf(" ");
if ((i&0xf) == 0xf) printf("\n\r");
}
printf("\n\r");
printf("\n\r----Frame of len : %d Byte\n\r",len);
for(i=0;i<len;i++){
printf("0x%02x ",fbuff[i] );
if ((i&0xf) == 0x7) printf(" ");
if ((i&0xf) == 0xf) printf("\n\r");
}
printf("\n\r");
}

View File

@ -54,7 +54,8 @@ int default_dac_values[16] = {0,2000,2000,1250,700,1278,500,500,2000,500,500,550
enum masterFlags masterMode=NO_MASTER;
enum masterFlags trialMasterMode=NO_MASTER;
int bottom = 0;
//enum masterFlags trialMasterMode=NO_MASTER;
int initDetector(){
int imod,i,n;
@ -137,20 +138,25 @@ int initDetector(){
Feb_Control_SetTestModeVariable(0);
Feb_Control_CheckSetup();
//if(!Feb_Control_IsBottomModule()){
//top or bottom
bottom = Feb_Control_IsBottomModule();
if(bottom)
printf("BOTTOM ***************\n");
else
printf("TOP ***************\n");
//if(getDetectorNumber()==0xbeb031){
printf("************** master ********************\n");
trialMasterMode = IS_MASTER;
Feb_Control_Set_Master();
//}
// printf("************** master ********************\n");
// trialMasterMode = IS_MASTER;
//Feb_Control_Set_Master();
// }
//else printf("************** slave ********************\n");
if(Feb_Control_IsBottomModule())
printf("BOTTOM ***************\n");
else
printf("TOP ***************\n");
return 1;
}
@ -469,38 +475,64 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
}
int startReceiver(int d){
//if(trialMasterMode == IS_MASTER)
if(!bottom)
Feb_Control_PrepareForAcquisition();
return OK;
}
int startStateMachine(){
int ret;
if(trialMasterMode == IS_MASTER){
int ret;int i=0;
//if(trialMasterMode == IS_MASTER){
if(!bottom){
printf("Going to start acquisition\n");
Feb_Control_StartAcquisition();
}
//if(trialMasterMode == IS_MASTER){
//do not read status here, cannot get images then
////if(trialMasterMode == IS_MASTER){
printf("requesting images\n");
ret = startReadOut();
//}
if(trialMasterMode == IS_MASTER){
/*for(i=0;i<3;i++)
usleep(1000000);*/
while(getRunStatus() == IDLE);
printf("Acquiring..\n");
}
printf("Returning\n");
////}
//if(trialMasterMode == IS_MASTER){
if(!bottom){
return ret;
/*
if(getRunStatus() == IDLE){
for(i=0;i<100000;i++){
usleep(1000);
if(getRunStatus() != IDLE){
printf("*****i=%d\n",i);
break;
}
}
//while(getRunStatus() == IDLE);
//}
printf("*****Acquiring...\n");
}
*/
while(getRunStatus() == IDLE);
printf("*****Acquiring...\n");
}
printf("****Returning\n");
return ret;
}
int stopStateMachine(){
if(trialMasterMode == IS_MASTER){
//if(trialMasterMode == IS_MASTER){
printf("Going to stop acquisition\n");
if(Feb_Control_StopAcquisition())
return OK;
}else return OK;
//}else return OK;
return FAIL;
}
@ -529,16 +561,16 @@ int startReadOut(){
enum runStatus getRunStatus(){
if(trialMasterMode == IS_MASTER){
//if(trialMasterMode == IS_MASTER){
int i = Feb_Control_AcquisitionInProgress();
if(i== 0){
//printf("IDLE\n");
return IDLE;
}else{
//printf("RUNNING\n");
printf("RUNNING\n");
return RUNNING;
}
}
//}else printf("***** not master*** \n");
return IDLE;
}
@ -548,7 +580,7 @@ enum runStatus getRunStatus(){
char *readFrame(int *ret, char *mess){
if(!Feb_Control_WaitForFinishedFlag(5000))
printf("error in waiting for finished flag\n");
printf("acquisition finished\n");
printf("Acquisition finished\n");
*ret = (int)FINISHED;
return NULL;

View File

@ -1,4 +1,11 @@
/* ONLY THOSE ARE USED IN THIS SOFTWARE. If one of those is modified in xilinx compilation, this file should be replaced with updated values
XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR
XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_RIGHT_BASEADDR
XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_LEFT_BASEADDR
XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR
XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
*/
/*******************************************************************
*
* CAUTION: This file is automatically generated by libgen.

View File

@ -1496,6 +1496,8 @@ int multiSlsDetector::startAndReadAllNoWait(){
ret1=FAIL;
}
}
i=thisMultiDetector->masterPosition;
if (thisMultiDetector->masterPosition>=0) {
if (detectors[i]) {

View File

@ -6190,7 +6190,7 @@ int slsDetector::startReceiver(){
setErrorMask((getErrorMask())|(COULDNOT_START_RECEIVER));
}
}
if((ret==OK)&& (thisDetector->myDetectorType != EIGER))
if((ret==OK))//&& (thisDetector->myDetectorType != EIGER))
ret=detectorSendToReceiver(true);
return ret;

View File

@ -107,6 +107,8 @@ int calibratePedestal(int frames);
#endif
int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod);
int calculateDataBytes();
@ -127,6 +129,7 @@ enum masterFlags setMaster(enum masterFlags arg);
enum synchronizationMode setSynchronization(enum synchronizationMode arg);
#ifdef EIGERD
int startReceiver(int d);
void setExternalGating(int enable[]);
void setAllTrimbits(int val);
int getAllTrimbits();

View File

@ -2278,9 +2278,9 @@ int get_run_status(int file_des) {
#ifdef VERBOSE
printf("Getting status\n");
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
s= getRunStatus();printf("status:%d\n");
#endif
//#ifdef SLS_DETECTOR_FUNCTION_LIST
s= getRunStatus();printf("status:%x\n",s);
//#endif
if (ret!=OK) {
printf("get status failed\n");
@ -3269,10 +3269,7 @@ int start_receiver(int file_des) {
strcpy(mess,"Could not start receiver\n");
/* execute action if the arguments correctly arri ved*/
#ifndef GOTTHARDD
ret = FAIL;
strcpy(mess,"Not applicable/implemented for this detector\n");
#else
#if defined(GOTTHARDD) || defined(EIGERD)
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (lockStatus==1 && differentClients==1){//necessary???
sprintf(mess,"Detector locked by %s\n", lastClientIP);
@ -3282,6 +3279,9 @@ int start_receiver(int file_des) {
ret = startReceiver(1);
#endif
#else
ret = FAIL;
strcpy(mess,"Not applicable/implemented for this detector\n");
#endif
if(ret==OK && differentClients){