mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-29 09:30:02 +02:00
virtual UDP for mythen3 (#55)
This commit is contained in:
parent
3b2feba3b2
commit
f981825172
@ -8,6 +8,9 @@
|
|||||||
/* Status register */
|
/* Status register */
|
||||||
#define STATUS_REG (0x01 << MEM_MAP_SHIFT)
|
#define STATUS_REG (0x01 << MEM_MAP_SHIFT)
|
||||||
|
|
||||||
|
#define RUN_BUSY_OFST (0)
|
||||||
|
#define RUN_BUSY_MSK (0x00000001 << RUN_BUSY_OFST)
|
||||||
|
|
||||||
/* Set Cycles 64 bit register */
|
/* Set Cycles 64 bit register */
|
||||||
#define SET_CYCLES_LSB_REG (0x02 << MEM_MAP_SHIFT)
|
#define SET_CYCLES_LSB_REG (0x02 << MEM_MAP_SHIFT)
|
||||||
#define SET_CYCLES_MSB_REG (0x03 << MEM_MAP_SHIFT)
|
#define SET_CYCLES_MSB_REG (0x03 << MEM_MAP_SHIFT)
|
||||||
|
@ -168,6 +168,12 @@ void initStopServer() {
|
|||||||
|
|
||||||
void setupDetector() {
|
void setupDetector() {
|
||||||
FILE_LOG(logINFO, ("This Server is for 1 Mythen3 module \n"));
|
FILE_LOG(logINFO, ("This Server is for 1 Mythen3 module \n"));
|
||||||
|
|
||||||
|
//Initialization of acquistion parameters
|
||||||
|
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
|
||||||
|
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
|
||||||
|
setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -280,6 +286,23 @@ int64_t getTimeLeft(enum timerIndex ind){
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport) {
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
char cDestIp[MAX_STR_LENGTH];
|
||||||
|
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||||
|
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||||
|
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, udpport));
|
||||||
|
if (setUDPDestinationDetails(0, cDestIp, udpport) == FAIL) {
|
||||||
|
FILE_LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
|
#endif
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int startStateMachine(){
|
int startStateMachine(){
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
// create udp socket
|
// create udp socket
|
||||||
@ -314,8 +337,10 @@ void* start_timer(void* arg) {
|
|||||||
// loop over number of frames
|
// loop over number of frames
|
||||||
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
||||||
|
|
||||||
//check if virtual_stop is high, then break
|
//check if virtual_stop is high
|
||||||
|
if(virtual_stop == 1){
|
||||||
|
break;
|
||||||
|
}
|
||||||
// sleep for exposure time
|
// sleep for exposure time
|
||||||
struct timespec begin, end;
|
struct timespec begin, end;
|
||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
@ -334,6 +359,7 @@ void* start_timer(void* arg) {
|
|||||||
// set register frames left
|
// set register frames left
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closeUDPSocket(0);
|
||||||
// set status to idle
|
// set status to idle
|
||||||
virtual_status = 0;
|
virtual_status = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -364,12 +390,25 @@ enum runStatus getRunStatus(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void readFrame(int *ret, char *mess){
|
void readFrame(int *ret, char *mess){
|
||||||
|
// wait for status to be done
|
||||||
|
while(runBusy()){
|
||||||
|
usleep(500);
|
||||||
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
FILE_LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
FILE_LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u_int32_t runBusy() {
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
return virtual_status;
|
||||||
|
#endif
|
||||||
|
u_int32_t s = (bus_r(STATUS_REG) & RUN_BUSY_MSK);
|
||||||
|
FILE_LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
|
|
||||||
int calculateDataBytes(){
|
int calculateDataBytes(){
|
||||||
|
@ -10,3 +10,11 @@
|
|||||||
#define NCHIP (10)
|
#define NCHIP (10)
|
||||||
#define NDAC (16)
|
#define NDAC (16)
|
||||||
#define TEMP_CLK (20) /* MHz */
|
#define TEMP_CLK (20) /* MHz */
|
||||||
|
|
||||||
|
|
||||||
|
/** Default Parameters */
|
||||||
|
#define DEFAULT_NUM_FRAMES (1)
|
||||||
|
#define DEFAULT_NUM_CYCLES (1)
|
||||||
|
#define DEFAULT_EXPTIME (100*1000*1000) //ns
|
||||||
|
|
||||||
|
|
||||||
|
@ -255,10 +255,8 @@ int configureMAC(int numInterfaces, int selInterface,
|
|||||||
uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport,
|
uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport,
|
||||||
uint32_t destip2, uint64_t destmac2, uint64_t sourcemac2, uint32_t sourceip2, uint32_t udpport2);
|
uint32_t destip2, uint64_t destmac2, uint64_t sourcemac2, uint32_t sourceip2, uint32_t udpport2);
|
||||||
#else
|
#else
|
||||||
#if !defined(MYTHEN3D) && !defined(GOTTHARD2D)
|
|
||||||
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport);
|
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(JUNGFRAUD) || defined(EIGERD)
|
#if defined(JUNGFRAUD) || defined(EIGERD)
|
||||||
int setDetectorPosition(int pos[]);
|
int setDetectorPosition(int pos[]);
|
||||||
@ -388,7 +386,7 @@ int checkFifoForEndOfAcquisition();
|
|||||||
int readFrameFromFifo();
|
int readFrameFromFifo();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D)
|
||||||
u_int32_t runBusy();
|
u_int32_t runBusy();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2321,9 +2321,6 @@ int configure_mac(int file_des) {
|
|||||||
if (receiveData(file_des, args, sizeof(args), OTHER) < 0)
|
if (receiveData(file_des, args, sizeof(args), OTHER) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
|
||||||
functionNotImplemented();
|
|
||||||
#else
|
|
||||||
FILE_LOG(logDEBUG1, ("\n Configuring MAC\n"));
|
FILE_LOG(logDEBUG1, ("\n Configuring MAC\n"));
|
||||||
// dest port
|
// dest port
|
||||||
uint32_t dstPort = 0;
|
uint32_t dstPort = 0;
|
||||||
@ -2442,7 +2439,7 @@ int configure_mac(int file_des) {
|
|||||||
if (status != IDLE && status != RUN_FINISHED && status != STOPPED) {
|
if (status != IDLE && status != RUN_FINISHED && status != STOPPED) {
|
||||||
if (status == RUNNING)
|
if (status == RUNNING)
|
||||||
stopStateMachine();
|
stopStateMachine();
|
||||||
#ifndef EIGERD
|
#if !defined(EIGERD) && !defined(MYTHEN3D)
|
||||||
cleanFifos();
|
cleanFifos();
|
||||||
#endif
|
#endif
|
||||||
status = getRunStatus();
|
status = getRunStatus();
|
||||||
@ -2516,7 +2513,6 @@ int configure_mac(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return Server_SendResult(file_des, OTHER, UPDATE, retvals, sizeof(retvals));
|
return Server_SendResult(file_des, OTHER, UPDATE, retvals, sizeof(retvals));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user