virtual UDP for mythen3 (#55)

This commit is contained in:
Marie Andrä
2019-08-26 10:53:17 +02:00
committed by Dhanya Thattil
parent 3b2feba3b2
commit f981825172
5 changed files with 55 additions and 11 deletions

View File

@ -8,6 +8,9 @@
/* Status register */
#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 */
#define SET_CYCLES_LSB_REG (0x02 << MEM_MAP_SHIFT)
#define SET_CYCLES_MSB_REG (0x03 << MEM_MAP_SHIFT)

View File

@ -168,6 +168,12 @@ void initStopServer() {
void setupDetector() {
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;
}
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(){
#ifdef VIRTUAL
// create udp socket
@ -314,8 +337,10 @@ void* start_timer(void* arg) {
// loop over number of frames
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
struct timespec begin, end;
clock_gettime(CLOCK_REALTIME, &begin);
@ -334,6 +359,7 @@ void* start_timer(void* arg) {
// set register frames left
}
closeUDPSocket(0);
// set status to idle
virtual_status = 0;
return NULL;
@ -364,12 +390,25 @@ enum runStatus getRunStatus(){
}
void readFrame(int *ret, char *mess){
// wait for status to be done
while(runBusy()){
usleep(500);
}
#ifdef VIRTUAL
FILE_LOG(logINFOGREEN, ("acquisition successfully finished\n"));
return;
#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 */
int calculateDataBytes(){

View File

@ -9,4 +9,12 @@
#define NCHAN (128)
#define NCHIP (10)
#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