jungfrau server works

This commit is contained in:
2018-11-02 13:50:00 +01:00
parent 92123069ce
commit b43be57b6e
33 changed files with 561 additions and 649 deletions

View File

@ -18,13 +18,10 @@ target_link_libraries(slsMultiReceiver
pthread pthread
zmq zmq
rt rt
${HDF5_LIBRARIES}
) )
if (HDF5_FOUND) if (HDF5_FOUND)
target_link_libraries(slsMultiReceiver target_link_libraries(slsMultiReceiver ${HDF5_LIBRARIES})
${HDF5_LIBRARIES}
)
endif () endif ()

View File

@ -1,13 +1,8 @@
#include "xfs_types.h"
#include "xparameters.h"
#include "FebRegisterDefs.h"
#include "logger.h" #include "logger.h"
#include "Beb.h" #include "Beb.h"
#include "FebRegisterDefs.h"
#include "xparameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> #include <sys/mman.h>

View File

@ -1,18 +1,15 @@
#include "FebRegisterDefs.h"
#include "FebControl.h" #include "FebControl.h"
#include "Beb.h" #include "FebRegisterDefs.h"
#include "slsDetectorServer_defs.h" #include "slsDetectorServer_defs.h"
#include "logger.h" #include "logger.h"
#include "Beb.h"
#include <netdb.h>
#include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <termios.h> // POSIX terminal control definitions(CS8, CREAD, CLOCAL..) #include <termios.h> // POSIX terminal control definitions(CS8, CREAD, CLOCAL..)
#include <errno.h> #include <errno.h>
#include <sys/mman.h>
#include <fcntl.h> #include <fcntl.h>

View File

@ -1,8 +1,6 @@
#pragma once #pragma once
#include "FebInterface.h" #include "FebInterface.h"
#include <netinet/in.h> #include <netinet/in.h>
#include <stdlib.h>
struct Module{ struct Module{

View File

@ -3,8 +3,6 @@
#include "xparameters.h" #include "xparameters.h"
#include "logger.h" #include "logger.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>

View File

@ -1,10 +1,4 @@
/**
* @author Ian Johnson
* @version 1.0
*/
//daq register definitions //daq register definitions
#define DAQ_REG_CTRL 1 #define DAQ_REG_CTRL 1
#define DAQ_REG_CHIP_CMDS 2 #define DAQ_REG_CHIP_CMDS 2

View File

@ -1,9 +1,7 @@
#include "LocalLinkInterface.h" #include "LocalLinkInterface.h"
#include "HardwareMMappingDefs.h" #include "HardwareMMappingDefs.h"
#include "logger.h" #include "logger.h"
#include "ansi.h"
#include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <fcntl.h> #include <fcntl.h>

View File

@ -8,7 +8,7 @@ DESTDIR ?= bin
INSTMODE = 0777 INSTMODE = 0777
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c FebControl.c Beb.c HardwareIO.c LocalLinkInterface.c FebInterface.c SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c HardwareIO.c LocalLinkInterface.c FebInterface.c FebControl.c Beb.c
OBJS = $(SRC_CLNT:.c=.o) OBJS = $(SRC_CLNT:.c=.o)

View File

@ -1,14 +1,13 @@
#include "slsDetectorFunctionList.h" #include "slsDetectorFunctionList.h"
#include "gitInfoEiger.h" #include "gitInfoEiger.h"
#include "versionAPI.h"
#include "logger.h"
#ifndef VIRTUAL #ifndef VIRTUAL
#include "FebControl.h" #include "FebControl.h"
#include "Beb.h" #include "Beb.h"
#include "versionAPI.h"
#endif #endif
#include "logger.h"
#include <stdio.h>
#include <unistd.h> //to gethostname #include <unistd.h> //to gethostname
#include <string.h> #include <string.h>
#ifdef VIRTUAL #ifdef VIRTUAL
@ -20,6 +19,11 @@
extern int debugflag; extern int debugflag;
extern int isControlServer; extern int isControlServer;
int firmware_compatibility = OK;
int firmware_check_done = 0;
char firmware_message[MAX_STR_LENGTH];
const char* dac_names[16] = {"SvP","Vtr","Vrf","Vrs","SvN","Vtgstv","Vcmp_ll","Vcmp_lr","cal","Vcmp_rl","rxb_rb","rxb_lb","Vcmp_rr","Vcp","Vcn","Vis"}; const char* dac_names[16] = {"SvP","Vtr","Vrf","Vrs","SvN","Vtgstv","Vcmp_ll","Vcmp_lr","cal","Vcmp_rl","rxb_rb","rxb_lb","Vcmp_rr","Vcp","Vcn","Vis"};
int default_tau_from_file= -1; int default_tau_from_file= -1;
enum detectorSettings thisSettings; enum detectorSettings thisSettings;
@ -42,12 +46,6 @@ int normal = 0;
uint32_t detid = 0; uint32_t detid = 0;
#endif #endif
int firmware_compatibility = OK;
int firmware_check_done = 0;
char firmware_message[MAX_STR_LENGTH];
int eiger_highvoltage = 0; int eiger_highvoltage = 0;
int eiger_theo_highvoltage = 0; int eiger_theo_highvoltage = 0;
int eiger_iodelay = 0; int eiger_iodelay = 0;
@ -60,8 +58,6 @@ int eiger_readoutspeed = 0;
int eiger_triggermode = 0; int eiger_triggermode = 0;
int eiger_extgating = 0; int eiger_extgating = 0;
int eiger_extgatingpolarity = 0; int eiger_extgatingpolarity = 0;
int eiger_nexposures = 1; int eiger_nexposures = 1;
int eiger_ncycles = 1; int eiger_ncycles = 1;
@ -381,25 +377,25 @@ void allocateDetectorStructureMemory() {
FILE_LOG(logINFO, ("This Server is for 1 Eiger half module (250k)\n\n")); FILE_LOG(logINFO, ("This Server is for 1 Eiger half module (250k)\n\n"));
//Allocation of memory //Allocation of memory
detectorModules=malloc(sizeof(sls_detector_module)); detectorModules = malloc(sizeof(sls_detector_module));
detectorChans=malloc(NCHIP*NCHAN*sizeof(int)); detectorChans = malloc(NCHIP*NCHAN*sizeof(int));
detectorDacs=malloc(NDAC*sizeof(int)); detectorDacs = malloc(NDAC*sizeof(int));
detectorAdcs=malloc(NADC*sizeof(int)); detectorAdcs = malloc(NADC*sizeof(int));
FILE_LOG(logDEBUG1, ("modules from 0x%x to 0x%x\n",detectorModules, detectorModules)); FILE_LOG(logDEBUG1, ("modules from 0x%x to 0x%x\n",detectorModules, detectorModules));
FILE_LOG(logDEBUG1, ("chans from 0x%x to 0x%x\n",detectorChans, detectorChans)); FILE_LOG(logDEBUG1, ("chans from 0x%x to 0x%x\n",detectorChans, detectorChans));
FILE_LOG(logDEBUG1, ("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs)); FILE_LOG(logDEBUG1, ("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs));
FILE_LOG(logDEBUG1, ("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs)); FILE_LOG(logDEBUG1, ("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs));
(detectorModules)->dacs=detectorDacs; (detectorModules)->dacs = detectorDacs;
(detectorModules)->adcs=detectorAdcs; (detectorModules)->adcs = detectorAdcs;
(detectorModules)->chanregs=detectorChans; (detectorModules)->chanregs = detectorChans;
(detectorModules)->ndac=NDAC; (detectorModules)->ndac = NDAC;
(detectorModules)->nadc=NADC; (detectorModules)->nadc = NADC;
(detectorModules)->nchip=NCHIP; (detectorModules)->nchip = NCHIP;
(detectorModules)->nchan=NCHIP*NCHAN; (detectorModules)->nchan = NCHIP * NCHAN;
(detectorModules)->reg=0; (detectorModules)->reg = 0;
(detectorModules)->iodelay=0; (detectorModules)->iodelay = 0;
(detectorModules)->tau=0; (detectorModules)->tau = 0;
(detectorModules)->eV=0; (detectorModules)->eV = 0;
thisSettings = UNINITIALIZED; thisSettings = UNINITIALIZED;
// if trimval requested, should return -1 to acknowledge unknown // if trimval requested, should return -1 to acknowledge unknown
@ -1196,6 +1192,7 @@ enum externalCommunicationMode getTiming() {
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2) { int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2) {
#ifndef VIRTUAL #ifndef VIRTUAL
FILE_LOG(logINFO, ("Configuring MAC\n"));
char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50]; char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50];
int src_port = 0xE185; int src_port = 0xE185;
sprintf(src_ip,"%d.%d.%d.%d",(sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff); sprintf(src_ip,"%d.%d.%d.%d",(sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff);
@ -1215,12 +1212,14 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
FILE_LOG(logINFO, ("src_port:%d\n" FILE_LOG(logINFO, (
"\tsrc_ip:%s\n" "\tSource IP : %s\n"
"\tdst_ip:%s\n" "\tSource MAC : %s\n"
"\tsrc_mac:%s\n" "\tSource Port : %d\n"
"\tdst_mac:%s\n", "\tDest IP : %s\n"
src_port, src_ip, dst_ip, src_mac, dst_mac)); "\tDest MAC : %s\n",
src_ip, src_mac, src_port,
dst_ip, dst_mac));
int beb_num = detid; int beb_num = detid;
@ -1229,13 +1228,13 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
if (!top) if (!top)
dst_port = udpport2; dst_port = udpport2;
FILE_LOG(logINFO, ("\tdst_port:%d\n", dst_port)); FILE_LOG(logINFO, ("\tDest Port : %d\n", dst_port));
int i=0; int i=0;
/* for(i=0;i<32;i++) { modified for Aldo*/ /* for(i=0;i<32;i++) { modified for Aldo*/
if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) && if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) &&
Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) { Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) {
FILE_LOG(logINFO, ("set up left ok\n")); FILE_LOG(logDEBUG1, ("\tset up left ok\n"));
} else { } else {
return -1; return -1;
} }
@ -1245,12 +1244,12 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
dst_port = udpport2; dst_port = udpport2;
if (!top) if (!top)
dst_port = udpport; dst_port = udpport;
FILE_LOG(logINFO, ("dst_port:%d\n",dst_port)); FILE_LOG(logINFO, ("\tDest Port : %d\n",dst_port));
/*for(i=0;i<32;i++) {*//** modified for Aldo*/ /*for(i=0;i<32;i++) {*//** modified for Aldo*/
if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) && if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) &&
Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) { Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) {
FILE_LOG(logINFO, ("set up right ok\n")); FILE_LOG(logDEBUG1, (" set up right ok\n"));
} else { } else {
return -1; return -1;
} }
@ -1654,7 +1653,7 @@ void* start_timer(void* arg) {
int stopStateMachine() { int stopStateMachine() {
FILE_LOG(logERROR, ("Going to stop acquisition\n")); FILE_LOG(logINFORED, ("Going to stop acquisition\n"));
#ifdef VIRTUAL #ifdef VIRTUAL
eiger_virtual_stop = 0; eiger_virtual_stop = 0;
return OK; return OK;
@ -1722,13 +1721,13 @@ enum runStatus getRunStatus() {
int i = Feb_Control_AcquisitionInProgress(); int i = Feb_Control_AcquisitionInProgress();
switch (i) { switch (i) {
case STATUS_ERROR: case STATUS_ERROR:
FILE_LOG(logINFO, ("Status: ERROR reading status register\n")); FILE_LOG(logERROR, ("Status: ERROR reading status register\n"));
return ERROR; return ERROR;
case STATUS_IDLE: case STATUS_IDLE:
FILE_LOG(logINFO, ("Status: IDLE\n")); FILE_LOG(logINFOBLUE, ("Status: IDLE\n"));
return IDLE; return IDLE;
default: default:
FILE_LOG(logINFO, ("Status: RUNNING...\n")); FILE_LOG(logINFOBLUE, ("Status: RUNNING...\n"));
return RUNNING; return RUNNING;
} }

View File

@ -9,7 +9,6 @@
#define SLSDETECTORSERVER_DEFS_H_ #define SLSDETECTORSERVER_DEFS_H_
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include <stdint.h>
#define GOODBYE (-200) #define GOODBYE (-200)
#define REQUIRED_FIRMWARE_VERSION (22) #define REQUIRED_FIRMWARE_VERSION (22)

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/jungfrauDetectorServer Path: slsDetectorPackage/slsDetectorServers/jungfrauDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: ee20932392a576a700f48140be02acb94b7eb6de Repsitory UUID: 92123069ce045314a12416a7e8b308875d7f9f21
Revision: 1 Revision: 7
Branch: refactor Branch: refactor
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4103 Last Changed Rev: 4158
Last Changed Date: 2018-10-11 13:46:09.000000002 +0200 ./RegisterDefs.h Last Changed Date: 2018-11-02 12:00:46.000000002 +0100 ./Makefile

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "ee20932392a576a700f48140be02acb94b7eb6de" #define GITREPUUID "92123069ce045314a12416a7e8b308875d7f9f21"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4103 #define GITREV 0x4158
#define GITDATE 0x20181011 #define GITDATE 0x20181102
#define GITBRANCH "refactor" #define GITBRANCH "refactor"

View File

@ -0,0 +1 @@
../slsDetectorServer/logger.h

View File

@ -3,14 +3,14 @@
#include "sls_detector_defs.h" //default dynamicgain in settings #include "sls_detector_defs.h" //default dynamicgain in settings
#include "RegisterDefs.h" #include "RegisterDefs.h"
#include <stdint.h>
#define GOODBYE (-200) #define GOODBYE (-200)
#define MIN_REQRD_VRSN_T_RD_API 0x171220 #define MIN_REQRD_VRSN_T_RD_API 0x171220
#define REQRD_FRMWR_VRSN 0x180615 #define REQRD_FRMWR_VRSN 0x180615
#define PROGRAMMING_MODE (0x2)
#define BOARD_JUNGFRAU_TYPE (8)
/* Struct Definitions */ /* Struct Definitions */
typedef struct ip_header_struct { typedef struct ip_header_struct {

View File

@ -1,10 +1,7 @@
#ifndef AD9257_H #ifndef AD9257_H
#define AD9257_H #define AD9257_H
#include "ansi.h" #include "commonServerFunctions.h" // blackfin.h, ansi.h
#include "commonServerFunctions.h"
#include <stdio.h>
/* AD9257 ADC DEFINES */ /* AD9257 ADC DEFINES */
#define AD9257_ADC_NUMBITS (24) #define AD9257_ADC_NUMBITS (24)
@ -81,36 +78,36 @@ void setAdc(int addr, int val) {
u_int32_t codata; u_int32_t codata;
codata = val + (addr << 8); codata = val + (addr << 8);
printf(" Setting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr); FILE_LOG(logINFO, ("\tSetting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr));
serializeToSPI(ADC_SPI_REG, codata, ADC_SERIAL_CS_OUT_MSK, AD9257_ADC_NUMBITS, serializeToSPI(ADC_SPI_REG, codata, ADC_SERIAL_CS_OUT_MSK, AD9257_ADC_NUMBITS,
ADC_SERIAL_CLK_OUT_MSK, ADC_SERIAL_DATA_OUT_MSK, ADC_SERIAL_DATA_OUT_OFST); ADC_SERIAL_CLK_OUT_MSK, ADC_SERIAL_DATA_OUT_MSK, ADC_SERIAL_DATA_OUT_OFST);
} }
void prepareADC(){ void prepareADC(){
printf("\n\nPreparing ADC ... \n"); FILE_LOG(logINFOBLUE, ("Preparing ADC:\n"));
//power mode reset //power mode reset
printf("power mode reset:\n"); FILE_LOG(logINFO, ("\tPower mode reset\n"));
setAdc(AD9257_POWER_MODE_REG, setAdc(AD9257_POWER_MODE_REG,
(AD9257_INT_RESET_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK); (AD9257_INT_RESET_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK);
//power mode chip run //power mode chip run
printf("power mode chip run:\n"); FILE_LOG(logINFO, ("\tPower mode chip run\n"));
setAdc(AD9257_POWER_MODE_REG, setAdc(AD9257_POWER_MODE_REG,
(AD9257_INT_CHIP_RUN_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK); (AD9257_INT_CHIP_RUN_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK);
//output clock phase //output clock phase
printf("output clock phase:\n"); FILE_LOG(logINFO, ("\tOutput clock phase\n"));
setAdc(AD9257_OUT_PHASE_REG, setAdc(AD9257_OUT_PHASE_REG,
(AD9257_OUT_CLK_60_VAL << AD9257_OUT_CLK_OFST) & AD9257_OUT_CLK_MSK); (AD9257_OUT_CLK_60_VAL << AD9257_OUT_CLK_OFST) & AD9257_OUT_CLK_MSK);
// lvds-iee reduced , binary offset // lvds-iee reduced , binary offset
printf("lvds-iee reduced, binary offset:\n"); FILE_LOG(logINFO, ("\tLvds-iee reduced, binary offset\n"));
setAdc(AD9257_OUT_MODE_REG, setAdc(AD9257_OUT_MODE_REG,
(AD9257_OUT_LVDS_IEEE_VAL << AD9257_OUT_LVDS_OPT_OFST) & AD9257_OUT_LVDS_OPT_MSK); (AD9257_OUT_LVDS_IEEE_VAL << AD9257_OUT_LVDS_OPT_OFST) & AD9257_OUT_LVDS_OPT_MSK);
// all devices on chip to receive next command // all devices on chip to receive next command
printf("all devices on chip to receive next command:\n"); FILE_LOG(logINFO, ("\tAll devices on chip to receive next command\n"));
setAdc(AD9257_DEV_IND_2_REG, setAdc(AD9257_DEV_IND_2_REG,
AD9257_CHAN_H_MSK | AD9257_CHAN_G_MSK | AD9257_CHAN_F_MSK | AD9257_CHAN_E_MSK); AD9257_CHAN_H_MSK | AD9257_CHAN_G_MSK | AD9257_CHAN_F_MSK | AD9257_CHAN_E_MSK);
setAdc(AD9257_DEV_IND_1_REG, setAdc(AD9257_DEV_IND_1_REG,
@ -118,21 +115,19 @@ void prepareADC(){
AD9257_CLK_CH_DCO_MSK | AD9257_CLK_CH_IFCO_MSK); AD9257_CLK_CH_DCO_MSK | AD9257_CLK_CH_IFCO_MSK);
// vref 1.33 // vref 1.33
printf("vref 1.33:\n"); FILE_LOG(logINFO, ("\tVref 1.33\n"));
setAdc(AD9257_VREF_REG, setAdc(AD9257_VREF_REG,
(AD9257_VREF_1_33_VAL << AD9257_VREF_OFST) & AD9257_VREF_MSK); (AD9257_VREF_1_33_VAL << AD9257_VREF_OFST) & AD9257_VREF_MSK);
// no test mode // no test mode
printf("no test mode:\n"); FILE_LOG(logINFO, ("\tNo test mode\n"));
setAdc(AD9257_TEST_MODE_REG, setAdc(AD9257_TEST_MODE_REG,
(AD9257_NONE_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK); (AD9257_NONE_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK);
#ifdef TESTADC #ifdef TESTADC
printf("***************************************** *******\n"); FILE_LOG(logINFOBLUE, ("Putting ADC in Test Mode!\n");
printf("******* PUTTING ADC IN TEST MODE!!!!!!!!! *******\n");
printf("***************************************** *******\n");
// mixed bit frequency test mode // mixed bit frequency test mode
printf("mixed bit frequency test mode:\n"); FILE_LOG(logINFO, ("\tMixed bit frequency test mode\n"));
setAdc(AD9257_TEST_MODE_REG, setAdc(AD9257_TEST_MODE_REG,
(AD9257_MIXED_BIT_FREQ_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK); (AD9257_MIXED_BIT_FREQ_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK);
#endif #endif

View File

@ -1,9 +1,7 @@
#ifndef BLACKFIN_H #pragma once
#define BLACKFIN_H
#include "ansi.h" #include "ansi.h"
#include <stdio.h>
#include <fcntl.h> // open #include <fcntl.h> // open
#include <sys/mman.h> // mmap #include <sys/mman.h> // mmap
@ -73,7 +71,7 @@ int64_t get64BitReg(int aLSB, int aMSB){
vMSB=bus_r(aMSB); vMSB=bus_r(aMSB);
v64=vMSB; v64=vMSB;
v64=(v64<<32) | vLSB; v64=(v64<<32) | vLSB;
printf(" reg64(%x,%x) %x %x %llx\n", aLSB, aMSB, vLSB, vMSB, (long long unsigned int)v64); FILE_LOG(logDEBUG1, (" reg64(%x,%x) %x %x %llx\n", aLSB, aMSB, vLSB, vMSB, (long long unsigned int)v64));
return v64; return v64;
} }
@ -124,39 +122,33 @@ u_int32_t writeRegister(u_int32_t offset, u_int32_t data) {
int mapCSP0(void) { int mapCSP0(void) {
// if not mapped // if not mapped
if (CSP0BASE == 0) { if (CSP0BASE == 0) {
printf("Mapping memory\n"); FILE_LOG(logINFO, ("Mapping memory\n"));
#ifdef VIRTUAL #ifdef VIRTUAL
CSP0BASE = malloc(MEM_SIZE); CSP0BASE = malloc(MEM_SIZE);
if (CSP0BASE == NULL) { if (CSP0BASE == NULL) {
cprintf(BG_RED, "Error: Could not allocate virtual memory.\n"); FILE_LOG(logERROR, ("Could not allocate virtual memory.\n"));
return FAIL; return FAIL;
} }
printf("memory allocated\n"); FILE_LOG(logINFO, (("memory allocated\n"));
#else #else
int fd; int fd;
fd = open("/dev/mem", O_RDWR | O_SYNC, 0); fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
if (fd == -1) { if (fd == -1) {
cprintf(BG_RED, "Error: Can't find /dev/mem\n"); FILE_LOG(logERROR, ("Can't find /dev/mem\n"));
return FAIL; return FAIL;
} }
#ifdef VERBOSE FILE_LOG(logDEBUG1, ("/dev/mem opened\n"));
printf("/dev/mem opened\n");
#endif
CSP0BASE = mmap(0, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, CSP0); CSP0BASE = mmap(0, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, CSP0);
if (CSP0BASE == MAP_FAILED) { if (CSP0BASE == MAP_FAILED) {
cprintf(BG_RED, "Error: Can't map memmory area\n"); FILE_LOG(logERROR, ("Can't map memmory area\n"));
return FAIL; return FAIL;
} }
#endif #endif
printf("CSPOBASE mapped from 0x%llx to 0x%llx\n", FILE_LOG(logINFO, ("CSPOBASE mapped from 0x%llx to 0x%llx\n",
(long long unsigned int)CSP0BASE, (long long unsigned int)CSP0BASE,
(long long unsigned int)(CSP0BASE+MEM_SIZE)); (long long unsigned int)(CSP0BASE+MEM_SIZE)));
printf("Status Register: %08x\n",bus_r(STATUS_REG)); FILE_LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
}else }else
printf("Memory already mapped before\n"); FILE_LOG(logINFO, ("Memory already mapped before\n"));
return OK; return OK;
} }
#endif //BLACKFIN_H

View File

@ -3,6 +3,8 @@
#ifndef GOTTHARDD //gotthard already had bus_w etc defined in its firmware_funcs.c (not yet made with common files) #ifndef GOTTHARDD //gotthard already had bus_w etc defined in its firmware_funcs.c (not yet made with common files)
#include "blackfin.h" #include "blackfin.h"
#else
#include "ansi.h"
#endif #endif
/* global variables */ /* global variables */
@ -54,13 +56,11 @@ void sendDataToSPI (u_int32_t* valw, u_int32_t addr, u_int32_t val, int numbitst
void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) { void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) {
#ifdef VERBOSE if (numbitstosend == 16) {
if (numbitstosend == 16) FILE_LOG(logDEBUG1, ("Writing to SPI Register: 0x%04x\n", val));
printf("Writing to SPI Register: 0x%04x\n",val); } else {
else FILE_LOG(logDEBUG1, ("Writing to SPI Register: 0x%08x\n", val));
printf("Writing to SPI Register: 0x%08x\n", val); }
#endif
u_int32_t valw; u_int32_t valw;
SPIChipSelect (&valw, addr, csmask); SPIChipSelect (&valw, addr, csmask);

View File

@ -1,14 +1,15 @@
#include "communication_funcs.h" #include "communication_funcs.h"
#include "logger.h" #include "logger.h"
//#include <netinet/tcp.h> /* for TCP_NODELAY */
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include <errno.h> #include <errno.h>
#include <sys/time.h> #include <arpa/inet.h>
#include <unistd.h>
#define SEND_REC_MAX_SIZE 4096
#define DEFAULT_PORTNO 1952
#define DEFAULT_BACKLOG 5
// Global variables from errno.h // Global variables from errno.h
extern int errno; extern int errno;
@ -25,7 +26,6 @@ char mess[MAX_STR_LENGTH];
// Local variables // Local variables
char dummyClientIP[INET_ADDRSTRLEN] = ""; char dummyClientIP[INET_ADDRSTRLEN] = "";
const int send_rec_max_size = SEND_REC_MAX_SIZE;
int myport = -1; int myport = -1;
// socket descriptor set // socket descriptor set
fd_set readset, tempset; fd_set readset, tempset;
@ -36,10 +36,6 @@ int isock = 0;
int maxfd = 0; int maxfd = 0;
#define DEFAULT_BACKLOG 5
int bindSocket(unsigned short int port_number) { int bindSocket(unsigned short int port_number) {
ret = FAIL; ret = FAIL;
int socketDescriptor = -1; int socketDescriptor = -1;
@ -324,7 +320,7 @@ int receiveDataOnly(int file_des, void* buf,int length) {
length, (isControlServer ? "control":"stop"))); length, (isControlServer ? "control":"stop")));
while(length > 0) { while(length > 0) {
nreceiving = (length>send_rec_max_size) ? send_rec_max_size:length; // (condition) ? if_true : if_false nreceiving = (length>SEND_REC_MAX_SIZE) ? SEND_REC_MAX_SIZE:length; // (condition) ? if_true : if_false
nreceived = read(file_des,(char*)buf+total_received,nreceiving); nreceived = read(file_des,(char*)buf+total_received,nreceiving);
if(!nreceived){ if(!nreceived){
if(!total_received) { if(!total_received) {

View File

@ -1,21 +1,9 @@
#ifndef COMMUNICATION_FUNCS_H #ifndef COMMUNICATION_FUNCS_H
#define COMMUNICATION_FUNCS_H #define COMMUNICATION_FUNCS_H
#define SEND_REC_MAX_SIZE 4096
#define DEFAULT_PORTNO 1952
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <unistd.h>
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
typedef enum{ typedef enum{
INT16, INT16,
INT32, INT32,

View File

@ -20,7 +20,7 @@
#endif #endif
typedef enum { typedef enum {
logERROR, logWARNING, logINFOBLUE, logINFOGREEN, logINFO, logERROR, logWARNING, logINFOBLUE, logINFOGREEN, logINFORED, logINFO,
logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5 logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5
}TLogLevel; }TLogLevel;
@ -36,6 +36,7 @@ static inline void FILELOG_PrintLog(TLogLevel level, char* m) {
case logWARNING: cprintf(YELLOW BOLD, "WARNING: %s", m); break; case logWARNING: cprintf(YELLOW BOLD, "WARNING: %s", m); break;
case logINFOBLUE: cprintf(BLUE, "INFO: %s", m); break; case logINFOBLUE: cprintf(BLUE, "INFO: %s", m); break;
case logINFOGREEN: cprintf(GREEN, "INFO: %s", m); break; case logINFOGREEN: cprintf(GREEN, "INFO: %s", m); break;
case logINFORED: cprintf(RED, "INFO: %s", m); break;
case logINFO: cprintf(RESET, "INFO: %s", m); break; case logINFO: cprintf(RESET, "INFO: %s", m); break;
case logDEBUG: cprintf(MAGENTA, "DEBUG: %s", m); break; case logDEBUG: cprintf(MAGENTA, "DEBUG: %s", m); break;
case logDEBUG1: cprintf(MAGENTA, "DEBUG1: %s", m); break; case logDEBUG1: cprintf(MAGENTA, "DEBUG1: %s", m); break;

View File

@ -1,19 +1,17 @@
#ifndef PROGRAM_FPGA_H #pragma once
#define PROGRAM_FPGA_H
#include "ansi.h" #include "ansi.h"
#include <stdio.h>
#include <unistd.h> // usleep #include <unistd.h> // usleep
#include <string.h> #include <string.h>
/* global variables */ /* global variables */
#define CTRL_SRVR_INIT_TIME_US (300 * 1000) #define CTRL_SRVR_INIT_TIME_US (300 * 1000)
int gpioDefined=0;
#define MTDSIZE 10 #define MTDSIZE 10
char mtdvalue[MTDSIZE];
int gpioDefined = 0;
char mtdvalue[MTDSIZE] = {0};
/** /**
@ -27,9 +25,9 @@ void defineGPIOpins(){
//define their direction //define their direction
system("echo in > /sys/class/gpio/gpio7/direction"); system("echo in > /sys/class/gpio/gpio7/direction");
system("echo out > /sys/class/gpio/gpio9/direction"); system("echo out > /sys/class/gpio/gpio9/direction");
printf("gpio pins defined\n"); FILE_LOG(logINFO, ("gpio pins defined\n"));
gpioDefined = 1; gpioDefined = 1;
}else printf("gpio pins already defined earlier\n"); }else FILE_LOG(logDEBUG1, ("gpio pins already defined earlier\n"));
} }
/** /**
@ -54,7 +52,7 @@ void FPGATouchFlash(){
* Reset FPGA * Reset FPGA
*/ */
void resetFPGA(){ void resetFPGA(){
cprintf(BLUE,"\n*** Reseting FPGA ***\n"); FILE_LOG(logINFOBLUE, ("Reseting FPGA\n"));
FPGAdontTouchFlash(); FPGAdontTouchFlash();
FPGATouchFlash(); FPGATouchFlash();
usleep(CTRL_SRVR_INIT_TIME_US); usleep(CTRL_SRVR_INIT_TIME_US);
@ -64,14 +62,12 @@ void resetFPGA(){
* Erasing flash * Erasing flash
*/ */
void eraseFlash(){ void eraseFlash(){
#ifdef VERY_VERBOSE FILE_LOG(logDEBUG1, ("Erasing Flash\n"));
printf("\nErasing Flash\n");
#endif
char command[255]; char command[255];
memset(command, 0, 255); memset(command, 0, 255);
sprintf(command,"flash_eraseall %s",mtdvalue); sprintf(command,"flash_eraseall %s",mtdvalue);
system(command); system(command);
printf("Flash erased\n"); FILE_LOG(logINFO, ("Flash erased\n"));
} }
/** /**
@ -81,43 +77,40 @@ void eraseFlash(){
* @return 0 for success, 1 for fail (cannot open file for writing program) * @return 0 for success, 1 for fail (cannot open file for writing program)
*/ */
int startWritingFPGAprogram(FILE** filefp){ int startWritingFPGAprogram(FILE** filefp){
#ifdef VERY_VERBOSE FILE_LOG(logDEBUG1, ("Start Writing of FPGA program\n"));
printf("\nStart Writing of FPGA program\n");
#endif
//getting the drive //getting the drive
char output[255]; char output[255];
memset(output, 0, 255); memset(output, 0, 255);
FILE* fp = popen("awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd", "r"); FILE* fp = popen("awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd", "r");
if (fp == NULL) { if (fp == NULL) {
cprintf(RED,"popen returned NULL. Need that to get mtd drive.\n"); FILE_LOG(logERROR, ("popen returned NULL. Need that to get mtd drive.\n"));
return 1; return 1;
} }
if (fgets(output, sizeof(output), fp) == NULL) { if (fgets(output, sizeof(output), fp) == NULL) {
cprintf(RED,"fgets returned NULL. Need that to get mtd drive.\n"); FILE_LOG(logERROR, ("fgets returned NULL. Need that to get mtd drive.\n"));
return 1; return 1;
} }
pclose(fp); pclose(fp);
//cprintf(RED,"output: %s\n", output);
memset(mtdvalue, 0, MTDSIZE); memset(mtdvalue, 0, MTDSIZE);
strcpy(mtdvalue,"/dev/"); strcpy(mtdvalue,"/dev/");
char* pch = strtok(output,":"); char* pch = strtok(output,":");
if(pch == NULL){ if(pch == NULL){
cprintf(RED,"Could not get mtd value\n"); FILE_LOG(logERROR, ("Could not get mtd value\n"));
return 1; return 1;
} }
strcat(mtdvalue,pch); strcat(mtdvalue,pch);
printf ("\nFlash drive found: %s\n",mtdvalue); FILE_LOG(logINFO, ("Flash drive found: %s\n", mtdvalue));
FPGAdontTouchFlash(); FPGAdontTouchFlash();
//writing the program to flash //writing the program to flash
*filefp = fopen(mtdvalue, "w"); *filefp = fopen(mtdvalue, "w");
if(*filefp == NULL){ if(*filefp == NULL){
cprintf(RED,"Unable to open %s in write mode\n",mtdvalue); FILE_LOG(logERROR, ("Unable to open %s in write mode\n", mtdvalue));
return 1; return 1;
} }
printf("Flash ready for writing\n"); FILE_LOG(logINFO, ("Flash ready for writing\n"));
return 0; return 0;
} }
@ -128,9 +121,7 @@ int startWritingFPGAprogram(FILE** filefp){
* @param filefp pointer to flash * @param filefp pointer to flash
*/ */
void stopWritingFPGAprogram(FILE* filefp){ void stopWritingFPGAprogram(FILE* filefp){
#ifdef VERY_VERBOSE FILE_LOG(logDEBUG1, ("Stopping of writing FPGA program\n"));
printf("\nStopping of writing FPGA program\n");
#endif
int wait = 0; int wait = 0;
if(filefp!= NULL){ if(filefp!= NULL){
@ -142,9 +133,7 @@ void stopWritingFPGAprogram(FILE* filefp){
FPGATouchFlash(); FPGATouchFlash();
if(wait){ if(wait){
#ifdef VERY_VERBOSE FILE_LOG(logDEBUG1, ("Waiting for FPGA to program from flash\n"));
printf("Waiting for FPGA to program from flash\n");
#endif
//waiting for success or done //waiting for success or done
char output[255]; char output[255];
int res=0; int res=0;
@ -153,12 +142,10 @@ void stopWritingFPGAprogram(FILE* filefp){
fgets(output, sizeof(output), sysFile); fgets(output, sizeof(output), sysFile);
pclose(sysFile); pclose(sysFile);
sscanf(output,"%d",&res); sscanf(output,"%d",&res);
#ifdef VERY_VERBOSE FILE_LOG(logDEBUG1, ("gpi07 returned %d\n", res));
printf("gpi07 returned %d\n",res);
#endif
} }
} }
printf("FPGA has picked up the program from flash\n\n"); FILE_LOG(logINFO, ("FPGA has picked up the program from flash\n"));
} }
@ -170,21 +157,15 @@ void stopWritingFPGAprogram(FILE* filefp){
* @return 0 for success, 1 for fail (cannot write) * @return 0 for success, 1 for fail (cannot write)
*/ */
int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp){ int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp){
#ifdef VERY_VERBOSE FILE_LOG(logDEBUG1, ("Writing of FPGA Program\n"
printf("\nWriting of FPGA Program\n"); "\taddress of fpgasrc:%p\n"
cprintf(BLUE,"address of fpgasrc:%p\n",(void *)fpgasrc); "\tfsize:%lu\n\tpointer:%p\n",
cprintf(BLUE,"fsize:%lu\n",fsize); (void *)fpgasrc, fsize, (void*)filefp));
cprintf(BLUE,"pointer:%p\n",(void*)filefp);
#endif
if(fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp )!= fsize){ if(fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp )!= fsize){
cprintf(RED,"Could not write FPGA source to flash (size:%lu)\n", fsize); FILE_LOG(logERROR, ("Could not write FPGA source to flash (size:%lu)\n", fsize));
return 1; return 1;
} }
#ifdef VERY_VERBOSE FILE_LOG(logDEBUG1, ("program written to flash\n"));
cprintf(BLUE, "program written to flash\n");
#endif
return 0; return 0;
} }
#endif //PROGRAM_FPGA_H

View File

@ -37,9 +37,7 @@ u_int64_t getFirmwareAPIVersion();
u_int16_t getHardwareVersionNumber(); u_int16_t getHardwareVersionNumber();
u_int16_t getHardwareSerialNumber(); u_int16_t getHardwareSerialNumber();
#endif #endif
#ifdef EIGERD
u_int32_t getDetectorNumber(); u_int32_t getDetectorNumber();
#endif
u_int64_t getDetectorMAC(); u_int64_t getDetectorMAC();
u_int32_t getDetectorIP(); u_int32_t getDetectorIP();

View File

@ -2,16 +2,15 @@
The port number is passed as an argument */ The port number is passed as an argument */
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "slsDetectorServer_defs.h"
#include "logger.h" #include "logger.h"
#include "communication_funcs.h" #include "communication_funcs.h"
#include "slsDetectorServer_funcs.h" #include "slsDetectorServer_funcs.h"
#include "slsDetectorServer_defs.h"
#include <stdio.h>
#include <stdlib.h>
#include <signal.h> #include <signal.h>
#include <string.h> #include <string.h>
// Global variables from communication_funcs // Global variables from communication_funcs
extern int isControlServer; extern int isControlServer;
extern int ret; extern int ret;

View File

@ -3,19 +3,19 @@
#include "communication_funcs.h" #include "communication_funcs.h"
#include "logger.h" #include "logger.h"
#include <stdio.h>
#include <string.h> #include <string.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <unistd.h>
//defined in the detector specific Makefile //defined in the detector specific Makefile
#ifdef GOTTHARDD #ifdef GOTTHARDD
const enum detectorType myDetectorType=GOTTHARD; const enum detectorType myDetectorType = GOTTHARD;
#elif EIGERD #elif EIGERD
const enum detectorType myDetectorType=EIGER; const enum detectorType myDetectorType = EIGER;
#elif JUNGFRAUD #elif JUNGFRAUD
const enum detectorType myDetectorType=JUNGFRAU; const enum detectorType myDetectorType = JUNGFRAU;
#else #else
const enum detectorType myDetectorType=GENERIC; const enum detectorType myDetectorType = GENERIC;
#endif #endif
// Global variables from communication_funcs // Global variables from communication_funcs
@ -64,7 +64,7 @@ void init_detector() {
if (isControlServer) { if (isControlServer) {
basictests(); basictests();
#ifdef JUNGFRAUD #ifdef JUNGFRAUD
if (debugflag == PROGRAMMING_MODE) if (debugflag != PROGRAMMING_MODE)
#endif #endif
initControlServer(); initControlServer();
#ifdef EIGERD #ifdef EIGERD
@ -1342,6 +1342,14 @@ int get_time_left(int file_des) {
// only get // only get
// check index // check index
#ifdef JUNGFRAUD
if (ind == DELAY_AFTER_TRIGGER) {
ret = FAIL;
sprintf(mess,"Timer Left Index (%d) is not implemented for this release.\n", (int)ind);
FILE_LOG(logERROR,(mess));
}
#endif
if (ret == OK) {
switch(ind) { switch(ind) {
#ifdef EIGERD #ifdef EIGERD
case MEASURED_PERIOD: case MEASURED_PERIOD:
@ -1365,18 +1373,11 @@ int get_time_left(int file_des) {
retval = getTimeLeft(ind); retval = getTimeLeft(ind);
FILE_LOG(logDEBUG1, ("Timer left index %d: %lld\n", ind, retval)); FILE_LOG(logDEBUG1, ("Timer left index %d: %lld\n", ind, retval));
break; break;
#ifdef JUNGFRAUD
case DELAY_AFTER_TRIGGER:
ret = FAIL;
sprintf(mess,"Timer Left Index (%d) is not implemented for this release.\n", (int)ind);
FILE_LOG(logERROR,(mess));
break;
#endif
default: default:
modeNotImplemented("Timer left index", (int)ind); modeNotImplemented("Timer left index", (int)ind);
break; break;
} }
}
return Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval)); return Server_SendResult(file_des, INT64, 1, &retval, sizeof(retval));
} }
@ -1692,9 +1693,16 @@ int set_port(int file_des) {
int update_client(int file_des) { int update_client(int file_des) {
ret = OK; ret = FORCE_UPDATE;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
#ifdef JUNGFRAUD
if (debugflag == PROGRAMMING_MODE) {
ret = OK;
}
#endif
Server_SendResult(file_des, INT32, 0, NULL, 0); Server_SendResult(file_des, INT32, 0, NULL, 0);
if (ret == OK)
return ret;
return send_update(file_des); return send_update(file_des);
} }
@ -1702,6 +1710,7 @@ int update_client(int file_des) {
int send_update(int file_des) { int send_update(int file_des) {
ret = OK;
int n = 0; int n = 0;
int i32 = -1; int i32 = -1;
int64_t i64 = -1; int64_t i64 = -1;
@ -1769,7 +1778,7 @@ int send_update(int file_des) {
strcpy(lastClientIP,thisClientIP); strcpy(lastClientIP,thisClientIP);
} }
return OK; return ret;
} }
@ -2369,7 +2378,6 @@ int program_fpga(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
FILE_LOG(logDEBUG1, ("Programming FPGA\n"));
#ifndef JUNGFRAUD #ifndef JUNGFRAUD
//to receive any arguments //to receive any arguments
int n = 1; int n = 1;
@ -2405,7 +2413,7 @@ int program_fpga(int file_des) {
if (receiveData(file_des,&filesize,sizeof(filesize),INT32) < 0) if (receiveData(file_des,&filesize,sizeof(filesize),INT32) < 0)
return printSocketReadError(); return printSocketReadError();
totalsize = filesize; totalsize = filesize;
FILE_LOG(logDEBUG1, ("Total program size is: %d\n", totalsize); FILE_LOG(logDEBUG1, ("Total program size is: %d\n", totalsize));
// opening file pointer to flash and telling FPGA to not touch flash // opening file pointer to flash and telling FPGA to not touch flash
if (startWritingFPGAprogram(&fp) != OK) { if (startWritingFPGAprogram(&fp) != OK) {
@ -2430,8 +2438,7 @@ int program_fpga(int file_des) {
if (unitprogramsize > filesize) //less than 2mb if (unitprogramsize > filesize) //less than 2mb
unitprogramsize = filesize; unitprogramsize = filesize;
FILE_LOG(logDEBUG1, ("unit size to receive is:%d\n" FILE_LOG(logDEBUG1, ("unit size to receive is:%d\n"
"filesize:%d currentpointer:%d\n", "filesize:%d\n", unitprogramsize, filesize));
unitprogramsize, filesize, currentPointer));
//receive part of program //receive part of program
@ -2462,8 +2469,8 @@ int program_fpga(int file_des) {
fflush(stdout); fflush(stdout);
} }
} }
printf("\n");
FILE_LOG(logINFO("\nDone copying program\n")); FILE_LOG(logINFO, ("Done copying program\n"));
// closing file pointer to flash and informing FPGA // closing file pointer to flash and informing FPGA
stopWritingFPGAprogram(fp); stopWritingFPGAprogram(fp);
@ -2735,6 +2742,7 @@ int storage_cell_start(int file_des) {
FILE_LOG(logDEBUG1, ("Storage cell start: %d\n", retval)); FILE_LOG(logDEBUG1, ("Storage cell start: %d\n", retval));
validate(arg, retval, "set storage cell start", 0); validate(arg, retval, "set storage cell start", 0);
} }
}
#endif #endif
return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval)); return Server_SendResult(file_des, INT32, 1, &retval, sizeof(retval));
} }

View File

@ -1,6 +1,5 @@
#pragma once #pragma once
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include <stdlib.h>
// initialization functions // initialization functions
int printSocketReadError(); int printSocketReadError();

View File

@ -1430,8 +1430,9 @@ int slsDetector::updateDetector() {
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0); ret = thisDetectorControl->Client_Send(fnum, NULL, 0, NULL, 0);
// no ret handling as ret never fail // if it returns ok (jungfrau in programming mode), dont update
updateDetectorNoWait(); if (ret == FORCE_UPDATE)
ret = updateDetectorNoWait();
disconnectControl(); disconnectControl();
} }
return ret; return ret;
@ -4122,7 +4123,8 @@ int slsDetector::programFPGA(std::string fname) {
//erasing flash //erasing flash
if (ret != FAIL) { if (ret != FAIL) {
FILE_LOG(logINFO) << "This can take awhile. Please be patient..."; FILE_LOG(logINFO) << "This can take awhile. Please be patient...";
printf("Erasing Flash: %d%%\r", 0); FILE_LOG(logINFO) << "Erasing Flash:";
printf("%d%%\r", 0);
std::cout << std::flush; std::cout << std::flush;
//erasing takes 65 seconds, printing here (otherwise need threads //erasing takes 65 seconds, printing here (otherwise need threads
//in server-unnecessary) //in server-unnecessary)
@ -4131,12 +4133,13 @@ int slsDetector::programFPGA(std::string fname) {
while(count > 0) { while(count > 0) {
usleep(1 * 1000 * 1000); usleep(1 * 1000 * 1000);
--count; --count;
printf("Erasing Flash:%d%%\r", printf("%d%%\r",
(int) (((double)(ERASE_TIME - count) / ERASE_TIME) * 100)); (int) (((double)(ERASE_TIME - count) / ERASE_TIME) * 100));
std::cout << std::flush; std::cout << std::flush;
} }
std::cout << std::endl; printf("\n");
printf("Writing to Flash:%d%%\r", 0); FILE_LOG(logINFO) << "Writing to Flash:";
printf("%d%%\r", 0);
std::cout << std::flush; std::cout << std::flush;
} }
@ -4160,16 +4163,17 @@ int slsDetector::programFPGA(std::string fname) {
currentPointer += unitprogramsize; currentPointer += unitprogramsize;
//print progress //print progress
printf("Writing to Flash:%d%%\r", printf("%d%%\r",
(int) (((double)(totalsize - filesize) / totalsize) * 100)); (int) (((double)(totalsize - filesize) / totalsize) * 100));
std::cout << std::flush; std::cout << std::flush;
} else { } else {
printf("\n");
controlSocket->ReceiveDataOnly(mess,sizeof(mess)); controlSocket->ReceiveDataOnly(mess,sizeof(mess));
FILE_LOG(logERROR) << "Detector returned error: " << mess; FILE_LOG(logERROR) << "Detector returned error: " << mess;
setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); setErrorMask((getErrorMask())|(PROGRAMMING_ERROR));
} }
} }
std::cout << std::endl; printf("\n");
//check ending error //check ending error
if ((ret == FAIL) && if ((ret == FAIL) &&

View File

@ -31,9 +31,9 @@ if (USE_HDF5)
endif (USE_HDF5) endif (USE_HDF5)
add_definitions( #add_definitions(
-DDACS_INT -DSLS_RECEIVER_UDP_FUNCTIONS # -DVERBOSE
) #)
include_directories( include_directories(
include include

View File

@ -82,7 +82,7 @@ void slsReceiverImplementation::InitializeMembers() {
//***connection parameters*** //***connection parameters***
strcpy(eth,""); strcpy(eth,"");
for(int i=0;i<MAX_NUMBER_OF_LISTENING_THREADS;i++){ for(int i=0;i<MAX_NUMBER_OF_LISTENING_THREADS;i++) {
udpPortNum[i] = DEFAULT_UDP_PORTNO + i; udpPortNum[i] = DEFAULT_UDP_PORTNO + i;
} }
udpSocketBufferSize = 0; udpSocketBufferSize = 0;
@ -205,7 +205,7 @@ uint64_t slsReceiverImplementation::getTotalFramesCaught() const {
uint64_t sum = 0; uint64_t sum = 0;
uint32_t flagsum = 0; uint32_t flagsum = 0;
for (const auto& it : dataProcessor){ for (const auto& it : dataProcessor) {
flagsum += it->GetMeasurementStartedFlag(); flagsum += it->GetMeasurementStartedFlag();
sum += it->GetNumTotalFramesCaught(); sum += it->GetNumTotalFramesCaught();
} }
@ -220,7 +220,7 @@ uint64_t slsReceiverImplementation::getFramesCaught() const {
uint64_t sum = 0; uint64_t sum = 0;
uint32_t flagsum = 0; uint32_t flagsum = 0;
for (const auto& it : dataProcessor){ for (const auto& it : dataProcessor) {
flagsum += it->GetMeasurementStartedFlag(); flagsum += it->GetMeasurementStartedFlag();
sum += it->GetNumFramesCaught(); sum += it->GetNumFramesCaught();
} }
@ -235,7 +235,7 @@ int64_t slsReceiverImplementation::getAcquisitionIndex() const {
uint64_t sum = 0; uint64_t sum = 0;
uint32_t flagsum = 0; uint32_t flagsum = 0;
for (const auto& it : dataProcessor){ for (const auto& it : dataProcessor) {
flagsum += it->GetMeasurementStartedFlag(); flagsum += it->GetMeasurementStartedFlag();
sum += it->GetActualProcessedAcquisitionIndex(); sum += it->GetActualProcessedAcquisitionIndex();
} }
@ -385,7 +385,7 @@ uint32_t slsReceiverImplementation::getActualUDPSocketBufferSize() const {
/**initial parameters***/ /**initial parameters***/
void slsReceiverImplementation::setDetectorHostname(const char *c){ void slsReceiverImplementation::setDetectorHostname(const char *c) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if(strlen(c)) if(strlen(c))
@ -411,7 +411,7 @@ void slsReceiverImplementation::setMultiDetectorSize(const int* size) {
} }
void slsReceiverImplementation::setFlippedData(int axis, int enable){ void slsReceiverImplementation::setFlippedData(int axis, int enable) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if(axis<0 || axis>1) if(axis<0 || axis>1)
return; return;
@ -436,8 +436,8 @@ int slsReceiverImplementation::setGapPixelsEnable(const bool b) {
} }
void slsReceiverImplementation::setFileFormat(const fileFormat f){ void slsReceiverImplementation::setFileFormat(const fileFormat f) {
switch(f){ switch(f) {
#ifdef HDF5C #ifdef HDF5C
case HDF5: case HDF5:
fileFormatType = HDF5; fileFormatType = HDF5;
@ -455,7 +455,7 @@ void slsReceiverImplementation::setFileFormat(const fileFormat f){
} }
void slsReceiverImplementation::setFileName(const char c[]){ void slsReceiverImplementation::setFileName(const char c[]) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if(strlen(c)) if(strlen(c))
@ -464,11 +464,11 @@ void slsReceiverImplementation::setFileName(const char c[]){
} }
void slsReceiverImplementation::setFilePath(const char c[]){ void slsReceiverImplementation::setFilePath(const char c[]) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if(strlen(c)){ if(strlen(c)) {
//check if filepath exists //check if filepath exists
struct stat st; struct stat st;
if(stat(c,&st) == 0) if(stat(c,&st) == 0)
@ -480,7 +480,7 @@ void slsReceiverImplementation::setFilePath(const char c[]){
} }
void slsReceiverImplementation::setFileIndex(const uint64_t i){ void slsReceiverImplementation::setFileIndex(const uint64_t i) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
fileIndex = i; fileIndex = i;
@ -488,7 +488,7 @@ void slsReceiverImplementation::setFileIndex(const uint64_t i){
} }
void slsReceiverImplementation::setFramesPerFile(const uint32_t i){ void slsReceiverImplementation::setFramesPerFile(const uint32_t i) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
framesPerFile = i; framesPerFile = i;
@ -496,7 +496,7 @@ void slsReceiverImplementation::setFramesPerFile(const uint32_t i){
} }
void slsReceiverImplementation::setFrameDiscardPolicy(const frameDiscardPolicy i){ void slsReceiverImplementation::setFrameDiscardPolicy(const frameDiscardPolicy i) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if (i >= 0 && i < NUM_DISCARD_POLICIES) if (i >= 0 && i < NUM_DISCARD_POLICIES)
@ -506,7 +506,7 @@ void slsReceiverImplementation::setFrameDiscardPolicy(const frameDiscardPolicy i
} }
void slsReceiverImplementation::setFramePaddingEnable(const bool i){ void slsReceiverImplementation::setFramePaddingEnable(const bool i) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
framePadding = i; framePadding = i;
@ -514,8 +514,8 @@ void slsReceiverImplementation::setFramePaddingEnable(const bool i){
} }
void slsReceiverImplementation::setFileWriteEnable(const bool b){ void slsReceiverImplementation::setFileWriteEnable(const bool b) {
if (fileWriteEnable != b){ if (fileWriteEnable != b) {
fileWriteEnable = b; fileWriteEnable = b;
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
dataProcessor[i]->SetupFileWriter(fileWriteEnable, (int*)numDet, dataProcessor[i]->SetupFileWriter(fileWriteEnable, (int*)numDet,
@ -529,7 +529,7 @@ void slsReceiverImplementation::setFileWriteEnable(const bool b){
} }
void slsReceiverImplementation::setOverwriteEnable(const bool b){ void slsReceiverImplementation::setOverwriteEnable(const bool b) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
overwriteEnable = b; overwriteEnable = b;
@ -538,21 +538,21 @@ void slsReceiverImplementation::setOverwriteEnable(const bool b){
/***connection parameters***/ /***connection parameters***/
void slsReceiverImplementation::setUDPPortNumber(const uint32_t i){ void slsReceiverImplementation::setUDPPortNumber(const uint32_t i) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
udpPortNum[0] = i; udpPortNum[0] = i;
FILE_LOG(logINFO) << "UDP Port Number[0]: " << udpPortNum[0]; FILE_LOG(logINFO) << "UDP Port Number[0]: " << udpPortNum[0];
} }
void slsReceiverImplementation::setUDPPortNumber2(const uint32_t i){ void slsReceiverImplementation::setUDPPortNumber2(const uint32_t i) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
udpPortNum[1] = i; udpPortNum[1] = i;
FILE_LOG(logINFO) << "UDP Port Number[1]: " << udpPortNum[1]; FILE_LOG(logINFO) << "UDP Port Number[1]: " << udpPortNum[1];
} }
void slsReceiverImplementation::setEthernetInterface(const char* c){ void slsReceiverImplementation::setEthernetInterface(const char* c) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
strcpy(eth, c); strcpy(eth, c);
@ -635,7 +635,7 @@ int slsReceiverImplementation::setStreamingFrequency(const uint32_t freq) {
return OK; return OK;
} }
void slsReceiverImplementation::setStreamingTimer(const uint32_t time_in_ms){ void slsReceiverImplementation::setStreamingTimer(const uint32_t time_in_ms) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
streamingTimerInMs = time_in_ms; streamingTimerInMs = time_in_ms;
@ -680,21 +680,21 @@ void slsReceiverImplementation::setStreamingPort(const uint32_t i) {
} }
void slsReceiverImplementation::setStreamingSourceIP(const char c[]){ void slsReceiverImplementation::setStreamingSourceIP(const char c[]) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
strcpy(streamingSrcIP, c); strcpy(streamingSrcIP, c);
FILE_LOG(logINFO) << "Streaming Source IP: " << streamingSrcIP; FILE_LOG(logINFO) << "Streaming Source IP: " << streamingSrcIP;
} }
void slsReceiverImplementation::setAdditionalJsonHeader(const char c[]){ void slsReceiverImplementation::setAdditionalJsonHeader(const char c[]) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
strcpy(additionalJsonHeader, c); strcpy(additionalJsonHeader, c);
FILE_LOG(logINFO) << "Additional JSON Header: " << additionalJsonHeader; FILE_LOG(logINFO) << "Additional JSON Header: " << additionalJsonHeader;
} }
int slsReceiverImplementation::setAcquisitionPeriod(const uint64_t i){ int slsReceiverImplementation::setAcquisitionPeriod(const uint64_t i) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
acquisitionPeriod = i; acquisitionPeriod = i;
@ -704,7 +704,7 @@ int slsReceiverImplementation::setAcquisitionPeriod(const uint64_t i){
return OK; return OK;
} }
int slsReceiverImplementation::setAcquisitionTime(const uint64_t i){ int slsReceiverImplementation::setAcquisitionTime(const uint64_t i) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
acquisitionTime = i; acquisitionTime = i;
@ -714,21 +714,21 @@ int slsReceiverImplementation::setAcquisitionTime(const uint64_t i){
return OK; return OK;
} }
void slsReceiverImplementation::setSubExpTime(const uint64_t i){ void slsReceiverImplementation::setSubExpTime(const uint64_t i) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
subExpTime = i; subExpTime = i;
FILE_LOG(logINFO) << "Sub Exposure Time: " << (double)subExpTime/(1E9) << "s"; FILE_LOG(logINFO) << "Sub Exposure Time: " << (double)subExpTime/(1E9) << "s";
} }
void slsReceiverImplementation::setSubPeriod(const uint64_t i){ void slsReceiverImplementation::setSubPeriod(const uint64_t i) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
subPeriod = i; subPeriod = i;
FILE_LOG(logINFO) << "Sub Exposure Period: " << (double)subPeriod/(1E9) << "s"; FILE_LOG(logINFO) << "Sub Exposure Period: " << (double)subPeriod/(1E9) << "s";
} }
int slsReceiverImplementation::setNumberOfFrames(const uint64_t i){ int slsReceiverImplementation::setNumberOfFrames(const uint64_t i) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
numberOfFrames = i; numberOfFrames = i;
@ -794,7 +794,7 @@ int slsReceiverImplementation::setFifoDepth(const uint32_t i) {
/***receiver parameters***/ /***receiver parameters***/
bool slsReceiverImplementation::setActivate(bool enable){ bool slsReceiverImplementation::setActivate(bool enable) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
activated = enable; activated = enable;
FILE_LOG(logINFO) << "Activation: " << stringEnable(activated); FILE_LOG(logINFO) << "Activation: " << stringEnable(activated);
@ -802,14 +802,14 @@ bool slsReceiverImplementation::setActivate(bool enable){
} }
bool slsReceiverImplementation::setDeactivatedPadding(bool enable){ bool slsReceiverImplementation::setDeactivatedPadding(bool enable) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
deactivatedPaddingEnable = enable; deactivatedPaddingEnable = enable;
FILE_LOG(logINFO) << "Deactivated Padding Enable: " << stringEnable(deactivatedPaddingEnable); FILE_LOG(logINFO) << "Deactivated Padding Enable: " << stringEnable(deactivatedPaddingEnable);
return deactivatedPaddingEnable; return deactivatedPaddingEnable;
} }
void slsReceiverImplementation::setSilentMode(const bool i){ void slsReceiverImplementation::setSilentMode(const bool i) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
silentMode = i; silentMode = i;
@ -902,7 +902,7 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) {
void slsReceiverImplementation::setDetectorPositionId(const int i){ void slsReceiverImplementation::setDetectorPositionId(const int i) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
detID = i; detID = i;
FILE_LOG(logINFO) << "Detector Position Id:" << detID; FILE_LOG(logINFO) << "Detector Position Id:" << detID;
@ -983,7 +983,7 @@ int slsReceiverImplementation::startReceiver(char *c) {
void slsReceiverImplementation::stopReceiver(){ void slsReceiverImplementation::stopReceiver() {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
FILE_LOG(logINFO) << "Stopping Receiver"; FILE_LOG(logINFO) << "Stopping Receiver";
@ -1061,9 +1061,9 @@ void slsReceiverImplementation::stopReceiver(){
void slsReceiverImplementation::startReadout(){ void slsReceiverImplementation::startReadout() {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if(status == RUNNING){ if(status == RUNNING) {
// wait for incoming delayed packets // wait for incoming delayed packets
int totalPacketsReceived = 0; int totalPacketsReceived = 0;
int previousValue=-1; int previousValue=-1;
@ -1071,9 +1071,9 @@ void slsReceiverImplementation::startReadout(){
totalPacketsReceived += it->GetPacketsCaught(); totalPacketsReceived += it->GetPacketsCaught();
//wait for all packets //wait for all packets
const auto numPacketsToReceive = numberOfFrames * generalData->packetsPerFrame * listener.size(); const int numPacketsToReceive = numberOfFrames * generalData->packetsPerFrame * listener.size();
if(totalPacketsReceived != numPacketsToReceive){ if(totalPacketsReceived != numPacketsToReceive) {
while(totalPacketsReceived != previousValue){ while(totalPacketsReceived != previousValue) {
FILE_LOG(logDEBUG3) << "waiting for all packets, previousValue:" << previousValue << FILE_LOG(logDEBUG3) << "waiting for all packets, previousValue:" << previousValue <<
" totalPacketsReceived: " << totalPacketsReceived; " totalPacketsReceived: " << totalPacketsReceived;
usleep(5*1000);/* TODO! Need to find optimal time **/ usleep(5*1000);/* TODO! Need to find optimal time **/
@ -1119,7 +1119,7 @@ void slsReceiverImplementation::closeFiles() {
int slsReceiverImplementation::restreamStop() { int slsReceiverImplementation::restreamStop() {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
bool ret = OK; bool ret = OK;
for (const auto& it : dataStreamer){ for (const auto& it : dataStreamer) {
if (it->RestreamStop() == FAIL) if (it->RestreamStop() == FAIL)
ret = FAIL; ret = FAIL;
} }
@ -1134,24 +1134,24 @@ int slsReceiverImplementation::restreamStop() {
/***callback functions***/ /***callback functions***/
void slsReceiverImplementation::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){ void slsReceiverImplementation::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg) {
startAcquisitionCallBack=func; startAcquisitionCallBack=func;
pStartAcquisition=arg; pStartAcquisition=arg;
} }
void slsReceiverImplementation::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){ void slsReceiverImplementation::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg) {
acquisitionFinishedCallBack=func; acquisitionFinishedCallBack=func;
pAcquisitionFinished=arg; pAcquisitionFinished=arg;
} }
void slsReceiverImplementation::registerCallBackRawDataReady(void (*func)(char* , void slsReceiverImplementation::registerCallBackRawDataReady(void (*func)(char* ,
char*, uint32_t, void*),void *arg){ char*, uint32_t, void*),void *arg) {
rawDataReadyCallBack=func; rawDataReadyCallBack=func;
pRawDataReady=arg; pRawDataReady=arg;
} }
void slsReceiverImplementation::registerCallBackRawDataModifyReady(void (*func)(char* , void slsReceiverImplementation::registerCallBackRawDataModifyReady(void (*func)(char* ,
char*, uint32_t&, void*),void *arg){ char*, uint32_t&, void*),void *arg) {
rawDataModifyReadyCallBack=func; rawDataModifyReadyCallBack=func;
pRawDataReady=arg; pRawDataReady=arg;
} }
@ -1187,7 +1187,7 @@ void slsReceiverImplementation::SetLocalNetworkParameters() {
void slsReceiverImplementation::SetThreadPriorities() { void slsReceiverImplementation::SetThreadPriorities() {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
for (const auto& it : listener){ for (const auto& it : listener) {
if (it->SetThreadPriority(LISTENER_PRIORITY) == FAIL) { if (it->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
FILE_LOG(logWARNING) << "Could not prioritize listener threads. (No Root Privileges?)"; FILE_LOG(logWARNING) << "Could not prioritize listener threads. (No Root Privileges?)";
return; return;
@ -1288,15 +1288,15 @@ int slsReceiverImplementation::SetupWriter() {
void slsReceiverImplementation::StartRunning() { void slsReceiverImplementation::StartRunning() {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
//set running mask and post semaphore to start the inner loop in execution thread //set running mask and post semaphore to start the inner loop in execution thread
for (const auto& it : listener){ for (const auto& it : listener) {
it->StartRunning(); it->StartRunning();
it->Continue(); it->Continue();
} }
for (const auto& it : dataProcessor){ for (const auto& it : dataProcessor) {
it->StartRunning(); it->StartRunning();
it->Continue(); it->Continue();
} }
for (const auto& it : dataStreamer){ for (const auto& it : dataStreamer) {
it->StartRunning(); it->StartRunning();
it->Continue(); it->Continue();
} }

View File

@ -689,8 +689,9 @@ public:
if(nsent == header_packet_size) if(nsent == header_packet_size)
continue; continue;
if(nsent != nsending){ if(nsent != nsending){
if(nsent && (nsent != -1)) if(nsent && (nsent != -1)) {
FILE_LOG(logERROR) << "Incomplete Packet size " << nsent; FILE_LOG(logERROR) << "Incomplete Packet size " << nsent;
}
break; break;
} }
length-=nsent; length-=nsent;
@ -707,9 +708,10 @@ public:
if(nsent<=0 || nsent == packet_size) if(nsent<=0 || nsent == packet_size)
break; break;
//incomplete packets or header packets ignored and read buffer again //incomplete packets or header packets ignored and read buffer again
if(nsent != packet_size && nsent != header_packet_size) if(nsent != packet_size && nsent != header_packet_size) {
FILE_LOG(logERROR) << portno << ": Incomplete Packet size " << nsent; FILE_LOG(logERROR) << portno << ": Incomplete Packet size " << nsent;
} }
}
//nsent = 1040; //nsent = 1040;
if(nsent > 0)total_sent+=nsent; if(nsent > 0)total_sent+=nsent;
} }

View File

@ -1,6 +1,6 @@
/** API versions */ /** API versions */
#define APIRECEIVER 0x180927 #define APIRECEIVER 0x180927
#define APIEIGER 0x181008 #define APIEIGER 0x181031
#define APIJUNGFRAU 0x181008 #define APIJUNGFRAU 0x181102
#define APIGOTTHARD 0x181009 #define APIGOTTHARD 0x181009