mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
ctb readout works with receiver for digital readout, allocate ram in server only if 1g udp, free addr info only when setting new udp detals upon configuring ,brough readout flags to receiver
This commit is contained in:
@ -556,35 +556,40 @@ void setupDetector() {
|
||||
}
|
||||
|
||||
int allocateRAM() {
|
||||
int oldDataBytes = dataBytes;
|
||||
updateDataBytes();
|
||||
int oldDataBytes = dataBytes;
|
||||
updateDataBytes();
|
||||
|
||||
// update only if change in databytes
|
||||
if (dataBytes == oldDataBytes) {
|
||||
FILE_LOG(logDEBUG1, ("RAM of size %d already allocated. Nothing to be done.\n", dataBytes));
|
||||
return OK;
|
||||
}
|
||||
// Zero databytes
|
||||
if (dataBytes <= 0) {
|
||||
FILE_LOG(logERROR, ("Can not allocate RAM for 0 bytes (databytes: 0).\n"));
|
||||
return FAIL;
|
||||
}
|
||||
// clear RAM
|
||||
if (ramValues) {
|
||||
free(ramValues);
|
||||
ramValues = 0;
|
||||
}
|
||||
// allocate RAM
|
||||
ramValues = malloc(dataBytes);
|
||||
// cannot malloc
|
||||
if (ramValues == NULL) {
|
||||
FILE_LOG(logERROR, ("Can not allocate RAM for even 1 frame. "
|
||||
"Probably cause: Memory Leak.\n"));
|
||||
return FAIL;
|
||||
}
|
||||
// only allcoate RAM for 1 giga udp (if 10G, return)
|
||||
if (enableTenGigabitEthernet(-1))
|
||||
return OK;
|
||||
|
||||
FILE_LOG(logINFO, ("\tRAM allocated to %d bytes\n", dataBytes));
|
||||
return OK;
|
||||
|
||||
// update only if change in databytes
|
||||
if (dataBytes == oldDataBytes) {
|
||||
FILE_LOG(logDEBUG1, ("RAM of size %d already allocated. Nothing to be done.\n", dataBytes));
|
||||
return OK;
|
||||
}
|
||||
// Zero databytes
|
||||
if (dataBytes <= 0) {
|
||||
FILE_LOG(logERROR, ("Can not allocate RAM for 0 bytes (databytes: 0).\n"));
|
||||
return FAIL;
|
||||
}
|
||||
// clear RAM
|
||||
if (ramValues) {
|
||||
free(ramValues);
|
||||
ramValues = 0;
|
||||
}
|
||||
// allocate RAM
|
||||
ramValues = malloc(dataBytes);
|
||||
// cannot malloc
|
||||
if (ramValues == NULL) {
|
||||
FILE_LOG(logERROR, ("Can not allocate RAM for even 1 frame. "
|
||||
"Probably cause: Memory Leak.\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("\tRAM allocated to %d bytes\n", dataBytes));
|
||||
return OK;
|
||||
}
|
||||
|
||||
void updateDataBytes() {
|
||||
@ -1510,6 +1515,9 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
FILE_LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
// 1 giga udp
|
||||
if (!enableTenGigabitEthernet(-1)) {
|
||||
// if it was in 10G mode, it was not allocating RAM
|
||||
if (allocateRAM() == FAIL)
|
||||
return -1;
|
||||
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);
|
||||
|
@ -22,7 +22,6 @@ extern int nframes;
|
||||
extern char* ramValues;
|
||||
|
||||
#define UDP_PACKET_HEADER_VERSION (0x1)
|
||||
#define UDP_PACKET_DATA_BYTES (1344)
|
||||
|
||||
|
||||
uint32_t udpPacketNumber = 0;
|
||||
|
@ -62,6 +62,7 @@ int setUDPDestinationDetails(const char* ip, unsigned short int port) {
|
||||
}
|
||||
|
||||
int createUDPSocket() {
|
||||
FILE_LOG(logDEBUG2, ("Creating UDP Socket\n"));
|
||||
if (!strlen(udpDestinationIp)) {
|
||||
FILE_LOG(logERROR, ("No destination UDP ip specified.\n"));
|
||||
return FAIL;
|
||||
@ -107,10 +108,9 @@ int sendUDPPacket(const char* buf, int length) {
|
||||
}
|
||||
|
||||
void closeUDPSocket() {
|
||||
close(udpSockfd);
|
||||
udpSockfd = -1;
|
||||
if (udpServerAddrInfo) {
|
||||
freeaddrinfo(udpServerAddrInfo);
|
||||
udpServerAddrInfo = 0;
|
||||
if (udpSockfd != -1) {
|
||||
FILE_LOG(logINFO, ("Udp client socket closed\n"));
|
||||
close(udpSockfd);
|
||||
udpSockfd = -1;
|
||||
}
|
||||
}
|
||||
|
@ -2272,10 +2272,21 @@ int configure_mac(int file_des) {
|
||||
|
||||
#endif
|
||||
ret = configureMAC(dstIp, dstMac, srcMac, srcIp, dstPort, dstPort2);
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
if (ret != OK) {
|
||||
if (ret == FAIL)
|
||||
sprintf(mess,"Could not configure mac because of incorrect udp 1G destination IP and port\n");
|
||||
else if (ret == -1)
|
||||
sprintf(mess, "Could not allocate RAM\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
#else
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess,"Configure Mac failed\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
} else {
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
FILE_LOG(logINFO, ("\tConfigure MAC successful\n"));
|
||||
}
|
||||
#if defined(EIGERD) || defined (JUNGFRAUD)
|
||||
|
Reference in New Issue
Block a user