mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-10 14:50:02 +02:00
1. allow 1gbe non blocking acquire by creating another thread (#753)
* allow 1gbe non blocking acquire by creating another thread * removed unnnecessary print out in ctb
This commit is contained in:
parent
f0c789dc91
commit
afee45790f
Binary file not shown.
@ -2289,6 +2289,11 @@ enum runStatus getRunStatus() {
|
||||
return TRANSMITTING;
|
||||
}
|
||||
|
||||
// 1g might still be transmitting or reading from fifo (not virtual)
|
||||
if (!enableTenGigabitEthernet(-1) && checkDataInFifo()) {
|
||||
return TRANSMITTING;
|
||||
}
|
||||
|
||||
if (!(retval & STATUS_IDLE_MSK)) {
|
||||
LOG(logINFOBLUE, ("Status: Idle\n"));
|
||||
return IDLE;
|
||||
@ -2299,19 +2304,17 @@ enum runStatus getRunStatus() {
|
||||
}
|
||||
}
|
||||
|
||||
void readandSendUDPFrames(int *ret, char *mess) {
|
||||
int validateUDPSocket() {
|
||||
if (getUdPSocketDescriptor(0, 0) <= 0) {
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
void readandSendUDPFrames() {
|
||||
LOG(logDEBUG1, ("Reading from 1G UDP\n"));
|
||||
|
||||
// validate udp socket
|
||||
if (getUdPSocketDescriptor(0, 0) <= 0) {
|
||||
*ret = FAIL;
|
||||
sprintf(mess, "UDP Socket not created. sockfd:%d\n",
|
||||
getUdPSocketDescriptor(0, 0));
|
||||
LOG(logERROR, (mess));
|
||||
return;
|
||||
}
|
||||
|
||||
// every frame read
|
||||
// read every frame
|
||||
while (readFrameFromFifo() == OK) {
|
||||
int bytesToSend = 0, n = 0;
|
||||
while ((bytesToSend = fillUDPPacket(udpPacketData))) {
|
||||
@ -2324,6 +2327,7 @@ void readandSendUDPFrames(int *ret, char *mess) {
|
||||
}
|
||||
}
|
||||
closeUDPSocket(0);
|
||||
LOG(logINFOBLUE, ("Transmitting frames done\n"));
|
||||
}
|
||||
|
||||
void waitForAcquisitionEnd() {
|
||||
@ -2339,20 +2343,6 @@ void waitForAcquisitionEnd() {
|
||||
LOG(logINFOGREEN, ("Blocking Acquisition done\n"));
|
||||
}
|
||||
|
||||
void readFrames(int *ret, char *mess) {
|
||||
#ifdef VIRTUAL
|
||||
while (runBusy()) {
|
||||
usleep(500);
|
||||
}
|
||||
#else
|
||||
// 1G force reading of frames
|
||||
if (!enableTenGigabitEthernet(-1)) {
|
||||
readandSendUDPFrames(ret, mess);
|
||||
LOG(logINFOBLUE, ("Transmitting frames done\n"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void unsetFifoReadStrobes() {
|
||||
bus_w(DUMMY_REG, bus_r(DUMMY_REG) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK) &
|
||||
(~DUMMY_DGTL_FIFO_RD_STRBE_MSK));
|
||||
@ -2444,7 +2434,7 @@ uint32_t checkDataInFifo() {
|
||||
uint32_t dataPresent = 0;
|
||||
if (analogEnable) {
|
||||
uint32_t analogFifoEmpty = bus_r(FIFO_EMPTY_REG);
|
||||
LOG(logINFO,
|
||||
LOG(logDEBUG1,
|
||||
("Analog Fifo Empty (32 channels): 0x%08x\n", analogFifoEmpty));
|
||||
dataPresent = (~analogFifoEmpty);
|
||||
}
|
||||
|
@ -676,16 +676,14 @@ int softwareTrigger(int block);
|
||||
int startReadOut();
|
||||
#endif
|
||||
enum runStatus getRunStatus();
|
||||
#if defined(CHIPTESTBOARDD)
|
||||
void readFrames(int *ret, char *mess);
|
||||
#endif
|
||||
#ifdef EIGERD
|
||||
void waitForAcquisitionEnd(int *ret, char *mess);
|
||||
#else
|
||||
void waitForAcquisitionEnd();
|
||||
#endif
|
||||
#if defined(CHIPTESTBOARDD)
|
||||
void readandSendUDPFrames(int *ret, char *mess);
|
||||
int validateUDPSocket();
|
||||
void readandSendUDPFrames();
|
||||
void unsetFifoReadStrobes();
|
||||
void readSample(int ns);
|
||||
uint32_t checkDataInFifo();
|
||||
|
@ -48,6 +48,9 @@ int set_settings(int);
|
||||
int get_threshold_energy(int);
|
||||
int acquire(int blocking, int file_des);
|
||||
void *start_state_machine(void *arg);
|
||||
#if defined(CHIPTESTBOARDD) && !defined(VIRTUAL)
|
||||
void *start_reading_and_sending_udp_frames(void *arg);
|
||||
#endif
|
||||
int start_acquisition(int);
|
||||
int stop_acquisition(int);
|
||||
int get_run_status(int);
|
||||
|
@ -67,6 +67,7 @@ int moduleIndex = -1;
|
||||
// Local variables
|
||||
int (*flist[NUM_DET_FUNCTIONS])(int);
|
||||
pthread_t pthread_tid;
|
||||
pthread_t pthread_tid_ctb_1g;
|
||||
|
||||
// scan variables
|
||||
int scan = 0;
|
||||
@ -1917,7 +1918,9 @@ int acquire(int blocking, int file_des) {
|
||||
strcpy(mess, "Could not start acquisition thread!\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
// only does not wait for non blocking and scan
|
||||
// wait for blocking always (scan or not)
|
||||
// non blocking-no scan also wait (for error message)
|
||||
// non blcoking-scan dont wait (there is scanErrorMessage)
|
||||
if (blocking || !scan) {
|
||||
pthread_join(pthread_tid, NULL);
|
||||
}
|
||||
@ -1999,18 +2002,43 @@ void *start_state_machine(void *arg) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(CHIPTESTBOARDD)
|
||||
readFrames(&ret, mess);
|
||||
if (ret == FAIL && scan) {
|
||||
sprintf(scanErrMessage, "Cannot scan at %d. ", scanSteps[i]);
|
||||
strcat(scanErrMessage, mess);
|
||||
sharedMemory_setScanStatus(ERROR);
|
||||
break;
|
||||
// only 1g real ctb needs to read from fifo
|
||||
// to avoid blocking, in another thread
|
||||
#if defined(CHIPTESTBOARDD) && !defined(VIRTUAL)
|
||||
if (!enableTenGigabitEthernet(-1)) {
|
||||
ret = validateUDPSocket();
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess, "UDP socket not created!\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
if (pthread_create(&pthread_tid_ctb_1g, NULL,
|
||||
&start_reading_and_sending_udp_frames,
|
||||
NULL)) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not start read frames thread!\n");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
// add scan error message
|
||||
if (ret == FAIL) {
|
||||
if (scan) {
|
||||
sprintf(scanErrMessage, "Cannot scan at %d. ",
|
||||
scanSteps[i]);
|
||||
strcat(scanErrMessage, mess);
|
||||
sharedMemory_setScanStatus(ERROR);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// blocking or scan
|
||||
if (*blocking || times > 1) {
|
||||
// wait to finish reading from fifo (1g real ctb)
|
||||
#if defined(CHIPTESTBOARDD) && !defined(VIRTUAL)
|
||||
if (!enableTenGigabitEthernet(-1)) {
|
||||
pthread_join(pthread_tid_ctb_1g, NULL);
|
||||
}
|
||||
#endif
|
||||
#ifdef EIGERD
|
||||
waitForAcquisitionEnd(&ret, mess);
|
||||
if (ret == FAIL && scan) {
|
||||
@ -2031,6 +2059,13 @@ void *start_state_machine(void *arg) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(CHIPTESTBOARDD) && !defined(VIRTUAL)
|
||||
void *start_reading_and_sending_udp_frames(void *arg) {
|
||||
readandSendUDPFrames();
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
int start_acquisition(int file_des) { return acquire(0, file_des); }
|
||||
|
||||
int stop_acquisition(int file_des) {
|
||||
|
@ -10,4 +10,4 @@
|
||||
#define APIEIGER "developer 0x230224"
|
||||
#define APIJUNGFRAU "developer 0x230508"
|
||||
#define APIMOENCH "developer 0x230508"
|
||||
#define APICTB "developer 0x230522"
|
||||
#define APICTB "developer 0x230523"
|
||||
|
Loading…
x
Reference in New Issue
Block a user