mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
eiger, jungfrau, ctb, moench, gotthard virtual servers checked
This commit is contained in:
parent
719157f5c3
commit
3ba9e5ec22
@ -22,7 +22,7 @@ install(TARGETS slsProjectCWarnings
|
|||||||
add_subdirectory(ctbDetectorServer)
|
add_subdirectory(ctbDetectorServer)
|
||||||
add_subdirectory(eigerDetectorServer)
|
add_subdirectory(eigerDetectorServer)
|
||||||
add_subdirectory(gotthardDetectorServer)
|
add_subdirectory(gotthardDetectorServer)
|
||||||
add_subdirectory(jungfrauDetectorServer)
|
#add_subdirectory(jungfrauDetectorServer)
|
||||||
add_subdirectory(mythen3DetectorServer)
|
#add_subdirectory(mythen3DetectorServer)
|
||||||
add_subdirectory(gotthard2DetectorServer)
|
#add_subdirectory(gotthard2DetectorServer)
|
||||||
add_subdirectory(moenchDetectorServer)
|
add_subdirectory(moenchDetectorServer)
|
||||||
|
@ -13,19 +13,26 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h> // usleep
|
#include <unistd.h> // usleep
|
||||||
|
#include <netinet/in.h>
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <math.h> //ceil
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Global variable from slsDetectorServer_funcs
|
// Global variable from slsDetectorServer_funcs
|
||||||
extern int debugflag;
|
extern int debugflag;
|
||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
|
extern const enum detectorType myDetectorType;
|
||||||
|
|
||||||
// Global variable from UDPPacketHeaderGenerator
|
// Global variable from UDPPacketHeaderGenerator
|
||||||
extern uint64_t udpFrameNumber;
|
extern uint64_t udpFrameNumber;
|
||||||
extern uint32_t udpPacketNumber;
|
extern uint32_t udpPacketNumber;
|
||||||
|
|
||||||
|
// Global variable from communication_funcs.c
|
||||||
|
extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||||
|
extern void getIpAddressinString(char* cip, uint32_t ip);
|
||||||
|
|
||||||
int initError = OK;
|
int initError = OK;
|
||||||
int initCheckDone = 0;
|
int initCheckDone = 0;
|
||||||
char initErrorMessage[MAX_STR_LENGTH];
|
char initErrorMessage[MAX_STR_LENGTH];
|
||||||
@ -1473,26 +1480,36 @@ void calcChecksum(udp_header* udp) {
|
|||||||
|
|
||||||
|
|
||||||
int configureMAC(){
|
int configureMAC(){
|
||||||
uint32_t sourceip = udpDetails.srcip;
|
uint32_t srcip = udpDetails.srcip;
|
||||||
uint32_t destip = udpDetails.dstip;
|
uint32_t dstip = udpDetails.dstip;
|
||||||
uint64_t sourcemac = udpDetails.srcmac;
|
uint64_t srcmac = udpDetails.srcmac;
|
||||||
uint64_t destmac = udpDetails.dstmac;
|
uint64_t dstmac = udpDetails.dstmac;
|
||||||
int sourceport = udpDetails.srcport;
|
int srcport = udpDetails.srcport;
|
||||||
int destport = udpDetails.dstport;
|
int dstport = udpDetails.dstport;
|
||||||
#ifdef VIRTUAL
|
|
||||||
return OK;
|
|
||||||
#endif
|
|
||||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||||
|
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||||
|
getMacAddressinString(src_mac, 50, srcmac);
|
||||||
|
getMacAddressinString(dst_mac, 50, dstmac);
|
||||||
|
getIpAddressinString(src_ip, srcip);
|
||||||
|
getIpAddressinString(dst_ip, dstip);
|
||||||
|
|
||||||
|
LOG(logINFO, (
|
||||||
|
"\tSource IP : %s\n"
|
||||||
|
"\tSource MAC : %s\n"
|
||||||
|
"\tSource Port : %d\n"
|
||||||
|
"\tDest IP : %s\n"
|
||||||
|
"\tDest MAC : %s\n"
|
||||||
|
"\tDest Port : %d\n",
|
||||||
|
src_ip, src_mac, srcport,
|
||||||
|
dst_ip, dst_mac, dstport));
|
||||||
|
|
||||||
// 1 giga udp
|
// 1 giga udp
|
||||||
if (!enableTenGigabitEthernet(-1)) {
|
if (!enableTenGigabitEthernet(-1)) {
|
||||||
LOG(logINFOBLUE, ("Configuring 1G MAC\n"));
|
LOG(logINFOBLUE, ("\t1G MAC\n"));
|
||||||
if (updateDatabytesandAllocateRAM() == FAIL)
|
if (updateDatabytesandAllocateRAM() == FAIL)
|
||||||
return -1;
|
return -1;
|
||||||
char cDestIp[MAX_STR_LENGTH];
|
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
|
||||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
|
||||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, destport));
|
|
||||||
if (setUDPDestinationDetails(0, cDestIp, destport) == FAIL) {
|
|
||||||
LOG(logERROR, ("could not set udp 1G destination IP and port\n"));
|
LOG(logERROR, ("could not set udp 1G destination IP and port\n"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -1500,31 +1517,7 @@ int configureMAC(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 10 G
|
// 10 G
|
||||||
LOG(logINFOBLUE, ("Configuring 10G MAC\n"));
|
LOG(logINFOBLUE, ("\t10G MAC\n"));
|
||||||
|
|
||||||
LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
|
||||||
(sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff, sourceip));
|
|
||||||
LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
|
||||||
(unsigned int)((sourcemac>>40)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>32)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>24)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>16)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>8)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>0)&0xFF),
|
|
||||||
(long long unsigned int)sourcemac));
|
|
||||||
LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n",sourceport, sourceport));
|
|
||||||
|
|
||||||
LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
|
||||||
(destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff, destip));
|
|
||||||
LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
|
||||||
(unsigned int)((destmac>>40)&0xFF),
|
|
||||||
(unsigned int)((destmac>>32)&0xFF),
|
|
||||||
(unsigned int)((destmac>>24)&0xFF),
|
|
||||||
(unsigned int)((destmac>>16)&0xFF),
|
|
||||||
(unsigned int)((destmac>>8)&0xFF),
|
|
||||||
(unsigned int)((destmac>>0)&0xFF),
|
|
||||||
(long long unsigned int)destmac));
|
|
||||||
LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n",destport, destport));
|
|
||||||
|
|
||||||
// start addr
|
// start addr
|
||||||
uint32_t addr = RXR_ENDPOINT_START_REG;
|
uint32_t addr = RXR_ENDPOINT_START_REG;
|
||||||
@ -1534,21 +1527,21 @@ int configureMAC(){
|
|||||||
|
|
||||||
// mac addresses
|
// mac addresses
|
||||||
// msb (32) + lsb (16)
|
// msb (32) + lsb (16)
|
||||||
udp->udp_destmac_msb = ((destmac >> 16) & BIT32_MASK);
|
udp->udp_destmac_msb = ((dstmac >> 16) & BIT32_MASK);
|
||||||
udp->udp_destmac_lsb = ((destmac >> 0) & BIT16_MASK);
|
udp->udp_destmac_lsb = ((dstmac >> 0) & BIT16_MASK);
|
||||||
// msb (16) + lsb (32)
|
// msb (16) + lsb (32)
|
||||||
udp->udp_srcmac_msb = ((sourcemac >> 32) & BIT16_MASK);
|
udp->udp_srcmac_msb = ((srcmac >> 32) & BIT16_MASK);
|
||||||
udp->udp_srcmac_lsb = ((sourcemac >> 0) & BIT32_MASK);
|
udp->udp_srcmac_lsb = ((srcmac >> 0) & BIT32_MASK);
|
||||||
|
|
||||||
// ip addresses
|
// ip addresses
|
||||||
udp->ip_srcip_msb = ((sourceip >> 16) & BIT16_MASK);
|
udp->ip_srcip_msb = ((srcip >> 16) & BIT16_MASK);
|
||||||
udp->ip_srcip_lsb = ((sourceip >> 0) & BIT16_MASK);
|
udp->ip_srcip_lsb = ((srcip >> 0) & BIT16_MASK);
|
||||||
udp->ip_destip_msb = ((destip >> 16) & BIT16_MASK);
|
udp->ip_destip_msb = ((dstip >> 16) & BIT16_MASK);
|
||||||
udp->ip_destip_lsb = ((destip >> 0) & BIT16_MASK);
|
udp->ip_destip_lsb = ((dstip >> 0) & BIT16_MASK);
|
||||||
|
|
||||||
// source port
|
// source port
|
||||||
udp->udp_srcport = sourceport;
|
udp->udp_srcport = srcport;
|
||||||
udp->udp_destport = destport;
|
udp->udp_destport = dstport;
|
||||||
|
|
||||||
// other defines
|
// other defines
|
||||||
udp->udp_ethertype = 0x800;
|
udp->udp_ethertype = 0x800;
|
||||||
@ -1579,6 +1572,9 @@ int* getDetectorPosition() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int enableTenGigabitEthernet(int val) {
|
int enableTenGigabitEthernet(int val) {
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
uint32_t addr = CONFIG_REG;
|
uint32_t addr = CONFIG_REG;
|
||||||
|
|
||||||
// set
|
// set
|
||||||
@ -2157,11 +2153,16 @@ uint64_t getPatternBitMask() {
|
|||||||
|
|
||||||
int startStateMachine(){
|
int startStateMachine(){
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_status = 1;
|
// create udp socket
|
||||||
|
if(createUDPSocket(0) != OK) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||||
|
virtual_status = 1;
|
||||||
virtual_stop = 0;
|
virtual_stop = 0;
|
||||||
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||||
virtual_status = 0;
|
|
||||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||||
|
virtual_status = 0;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||||
@ -2195,41 +2196,83 @@ int startStateMachine(){
|
|||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
void* start_timer(void* arg) {
|
void* start_timer(void* arg) {
|
||||||
int64_t periodns = getPeriod();
|
int64_t periodNs = getPeriod();
|
||||||
int numFrames = (getNumFrames() *
|
int numFrames = (getNumFrames() *
|
||||||
getNumTriggers() );
|
getNumTriggers() );
|
||||||
int64_t exp_ns = getExpTime();
|
int64_t expUs = getExpTime() / 1000;
|
||||||
|
|
||||||
int frameNr = 0;
|
int imageSize = dataBytes;
|
||||||
// loop over number of frames
|
int dataSize = UDP_PACKET_DATA_BYTES;
|
||||||
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
int packetSize = sizeof(sls_detector_header) + dataSize;
|
||||||
|
int packetsPerFrame = ceil((double)imageSize / (double)dataSize);
|
||||||
|
|
||||||
//check if virtual_stop is high
|
// Generate Data
|
||||||
if(virtual_stop == 1){
|
char imageData[imageSize];
|
||||||
break;
|
memset(imageData, 0, imageSize);
|
||||||
}
|
{
|
||||||
|
int i = 0;
|
||||||
// sleep for exposure time
|
for (i = 0; i < imageSize; i += sizeof(uint16_t)) {
|
||||||
struct timespec begin, end;
|
*((uint16_t*)(imageData + i)) = i;
|
||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
}
|
||||||
usleep(exp_ns / 1000);
|
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
|
||||||
|
|
||||||
// calculate time left in period
|
|
||||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
|
||||||
(end.tv_nsec - begin.tv_nsec));
|
|
||||||
|
|
||||||
// sleep for (period - exptime)
|
|
||||||
if (frameNr < numFrames) { // if there is a next frame
|
|
||||||
if (periodns > time_ns) {
|
|
||||||
usleep((periodns - time_ns)/ 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set register frames left
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set status to idle
|
// Send data
|
||||||
|
{
|
||||||
|
int frameNr = 0;
|
||||||
|
// loop over number of frames
|
||||||
|
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
||||||
|
|
||||||
|
//check if virtual_stop is high
|
||||||
|
if(virtual_stop == 1){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// sleep for exposure time
|
||||||
|
struct timespec begin, end;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
|
usleep(expUs);
|
||||||
|
|
||||||
|
int srcOffset = 0;
|
||||||
|
char packetData[packetSize];
|
||||||
|
memset(packetData, 0, packetSize);
|
||||||
|
|
||||||
|
// loop packet
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
for(i = 0; i != packetsPerFrame; ++i) {
|
||||||
|
// set header
|
||||||
|
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||||
|
header->detType = (uint16_t)myDetectorType;
|
||||||
|
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||||
|
header->frameNumber = frameNr;
|
||||||
|
header->packetNumber = i;
|
||||||
|
header->modId = 0;
|
||||||
|
header->row = detPos[X];
|
||||||
|
header->column = detPos[Y];
|
||||||
|
|
||||||
|
// fill data
|
||||||
|
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, dataSize);
|
||||||
|
srcOffset += dataSize;
|
||||||
|
|
||||||
|
sendUDPPacket(0, packetData, packetSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||||
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
|
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||||
|
(end.tv_nsec - begin.tv_nsec));
|
||||||
|
|
||||||
|
// sleep for (period - exptime)
|
||||||
|
if (frameNr < numFrames) { // if there is a next frame
|
||||||
|
if (periodNs > timeNs) {
|
||||||
|
usleep((periodNs - timeNs)/ 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closeUDPSocket(0);
|
||||||
|
|
||||||
virtual_status = 0;
|
virtual_status = 0;
|
||||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1200,21 +1200,20 @@ enum timingMode getTiming() {
|
|||||||
/* configure mac */
|
/* configure mac */
|
||||||
|
|
||||||
int configureMAC() {
|
int configureMAC() {
|
||||||
uint32_t sourceip = udpDetails.srcip;
|
uint32_t srcip = udpDetails.srcip;
|
||||||
uint32_t destip = udpDetails.dstip;
|
uint32_t dstip = udpDetails.dstip;
|
||||||
uint64_t sourcemac = udpDetails.srcmac;
|
uint64_t srcmac = udpDetails.srcmac;
|
||||||
uint64_t destmac = udpDetails.dstmac;
|
uint64_t dstmac = udpDetails.dstmac;
|
||||||
int src_port = udpDetails.srcport;
|
int srcport = udpDetails.srcport;
|
||||||
int destport = udpDetails.dstport;
|
int dstport = udpDetails.dstport;
|
||||||
int destport2 = udpDetails.dstport2;
|
int dstport2 = udpDetails.dstport2;
|
||||||
|
|
||||||
LOG(logINFO, ("Configuring MAC\n"));
|
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||||
|
|
||||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||||
getMacAddressinString(src_mac, 50, sourcemac);
|
getMacAddressinString(src_mac, 50, srcmac);
|
||||||
getMacAddressinString(dst_mac, 50, destmac);
|
getMacAddressinString(dst_mac, 50, dstmac);
|
||||||
getIpAddressinString(src_ip, sourceip);
|
getIpAddressinString(src_ip, srcip);
|
||||||
getIpAddressinString(dst_ip, destip);
|
getIpAddressinString(dst_ip, dstip);
|
||||||
|
|
||||||
LOG(logINFO, (
|
LOG(logINFO, (
|
||||||
"\tSource IP : %s\n"
|
"\tSource IP : %s\n"
|
||||||
@ -1224,19 +1223,15 @@ int configureMAC() {
|
|||||||
"\tDest MAC : %s\n"
|
"\tDest MAC : %s\n"
|
||||||
"\tDest Port : %d\n"
|
"\tDest Port : %d\n"
|
||||||
"\tDest Port2 : %d\n",
|
"\tDest Port2 : %d\n",
|
||||||
src_ip, src_mac, src_port,
|
src_ip, src_mac, srcport,
|
||||||
dst_ip, dst_mac, destport, destport2));
|
dst_ip, dst_mac, dstport, dstport2));
|
||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
char cDestIp[MAX_STR_LENGTH];
|
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
|
||||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
|
||||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d, port2:%d)\n", cDestIp, destport, destport2));
|
|
||||||
if (setUDPDestinationDetails(0, cDestIp, destport) == FAIL) {
|
|
||||||
LOG(logERROR, ("could not set udp destination IP and port\n"));
|
LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
if (setUDPDestinationDetails(1, cDestIp, destport2) == FAIL) {
|
if (setUDPDestinationDetails(1, dst_ip, dstport2) == FAIL) {
|
||||||
LOG(logERROR, ("could not set udp destination IP and port2\n"));
|
LOG(logERROR, ("could not set udp destination IP and port2\n"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -1245,11 +1240,9 @@ int configureMAC() {
|
|||||||
|
|
||||||
int beb_num = detid;
|
int beb_num = detid;
|
||||||
int header_number = 0;
|
int header_number = 0;
|
||||||
int dst_port = destport;
|
int dst_port = dstport;
|
||||||
if (!top)
|
if (!top)
|
||||||
dst_port = destport2;
|
dst_port = dstport2;
|
||||||
|
|
||||||
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*/
|
||||||
@ -1262,10 +1255,9 @@ int configureMAC() {
|
|||||||
/*}*/
|
/*}*/
|
||||||
|
|
||||||
header_number = 32;
|
header_number = 32;
|
||||||
dst_port = destport2;
|
dst_port = dstport2;
|
||||||
if (!top)
|
if (!top)
|
||||||
dst_port = destport;
|
dst_port = dstport;
|
||||||
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) &&
|
||||||
@ -1752,7 +1744,7 @@ int startStateMachine() {
|
|||||||
if(createUDPSocket(1) != OK) {
|
if(createUDPSocket(1) != OK) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||||
eiger_virtual_status = 1;
|
eiger_virtual_status = 1;
|
||||||
eiger_virtual_stop = 0;
|
eiger_virtual_stop = 0;
|
||||||
if (pthread_create(&eiger_virtual_tid, NULL, &start_timer, NULL)) {
|
if (pthread_create(&eiger_virtual_tid, NULL, &start_timer, NULL)) {
|
||||||
@ -1763,7 +1755,7 @@ int startStateMachine() {
|
|||||||
LOG(logINFO ,("Virtual Acquisition started\n"));
|
LOG(logINFO ,("Virtual Acquisition started\n"));
|
||||||
return OK;
|
return OK;
|
||||||
#else
|
#else
|
||||||
|
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||||
int ret = OK,prev_flag;
|
int ret = OK,prev_flag;
|
||||||
//get the DAQ toggle bit
|
//get the DAQ toggle bit
|
||||||
prev_flag = Feb_Control_AcquisitionStartedBit();
|
prev_flag = Feb_Control_AcquisitionStartedBit();
|
||||||
@ -1791,9 +1783,9 @@ int startStateMachine() {
|
|||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
void* start_timer(void* arg) {
|
void* start_timer(void* arg) {
|
||||||
int64_t periodns = eiger_virtual_period;
|
int64_t periodNs = eiger_virtual_period;
|
||||||
int numFrames = nimages_per_request;
|
int numFrames = nimages_per_request;
|
||||||
int64_t exp_us = eiger_virtual_exptime / 1000;
|
int64_t expUs = eiger_virtual_exptime / 1000;
|
||||||
|
|
||||||
int dr = eiger_dynamicrange;
|
int dr = eiger_dynamicrange;
|
||||||
double bytesPerPixel = (double)dr/8.00;
|
double bytesPerPixel = (double)dr/8.00;
|
||||||
@ -1811,7 +1803,7 @@ void* start_timer(void* arg) {
|
|||||||
LOG(logINFO, (" dr:%d\n bytesperpixel:%f\n tgenable:%d\n datasize:%d\n packetsize:%d\n numpackes:%d\n npixelsx:%d\n databytes:%d\n ntotpixels:%d\n",
|
LOG(logINFO, (" dr:%d\n bytesperpixel:%f\n tgenable:%d\n datasize:%d\n packetsize:%d\n numpackes:%d\n npixelsx:%d\n databytes:%d\n ntotpixels:%d\n",
|
||||||
dr, bytesPerPixel, tgEnable, datasize, packetsize, numPacketsPerFrame, npixelsx, databytes, ntotpixels));
|
dr, bytesPerPixel, tgEnable, datasize, packetsize, numPacketsPerFrame, npixelsx, databytes, ntotpixels));
|
||||||
|
|
||||||
//TODO: Generate data
|
// Generate data
|
||||||
char imageData[databytes * 2];
|
char imageData[databytes * 2];
|
||||||
memset(imageData, 0, databytes * 2);
|
memset(imageData, 0, databytes * 2);
|
||||||
{
|
{
|
||||||
@ -1842,9 +1834,10 @@ void* start_timer(void* arg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Send data
|
// Send data
|
||||||
{
|
{
|
||||||
int frameNr = 1;
|
int frameNr = 1;
|
||||||
|
// loop over number of frames
|
||||||
for(frameNr=1; frameNr <= numFrames; ++frameNr ) {
|
for(frameNr=1; frameNr <= numFrames; ++frameNr ) {
|
||||||
|
|
||||||
usleep(eiger_virtual_transmission_delay_frame);
|
usleep(eiger_virtual_transmission_delay_frame);
|
||||||
@ -1854,12 +1847,13 @@ void* start_timer(void* arg) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int srcOffset = 0;
|
// sleep for exposure time
|
||||||
int srcOffset2 = npixelsx;
|
|
||||||
|
|
||||||
struct timespec begin, end;
|
struct timespec begin, end;
|
||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
usleep(exp_us);
|
usleep(expUs);
|
||||||
|
|
||||||
|
int srcOffset = 0;
|
||||||
|
int srcOffset2 = npixelsx;
|
||||||
char packetData[packetsize];
|
char packetData[packetsize];
|
||||||
memset(packetData, 0, packetsize);
|
memset(packetData, 0, packetsize);
|
||||||
char packetData2[packetsize];
|
char packetData2[packetsize];
|
||||||
@ -1929,13 +1923,13 @@ void* start_timer(void* arg) {
|
|||||||
}
|
}
|
||||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||||
(end.tv_nsec - begin.tv_nsec));
|
(end.tv_nsec - begin.tv_nsec));
|
||||||
|
|
||||||
// sleep for (period - exptime)
|
// sleep for (period - exptime)
|
||||||
if (frameNr < numFrames) { // if there is a next frame
|
if (frameNr < numFrames) { // if there is a next frame
|
||||||
if (periodns > time_ns) {
|
if (periodNs > timeNs) {
|
||||||
usleep((periodns - time_ns)/ 1000);
|
usleep((periodNs - timeNs)/ 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,10 @@ extern int checkModuleFlag;
|
|||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
extern const enum detectorType myDetectorType;
|
extern const enum detectorType myDetectorType;
|
||||||
|
|
||||||
|
// Global variable from communication_funcs.c
|
||||||
|
extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||||
|
extern void getIpAddressinString(char* cip, uint32_t ip);
|
||||||
|
|
||||||
int initError = OK;
|
int initError = OK;
|
||||||
int initCheckDone = 0;
|
int initCheckDone = 0;
|
||||||
char initErrorMessage[MAX_STR_LENGTH];
|
char initErrorMessage[MAX_STR_LENGTH];
|
||||||
@ -2067,7 +2071,6 @@ void* start_timer(void* arg) {
|
|||||||
struct timespec begin, end;
|
struct timespec begin, end;
|
||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
usleep(exp_ns / 1000);
|
usleep(exp_ns / 1000);
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
|
||||||
|
|
||||||
char packetData[packetsize];
|
char packetData[packetsize];
|
||||||
memset(packetData, 0, packetsize);
|
memset(packetData, 0, packetsize);
|
||||||
@ -2086,6 +2089,7 @@ void* start_timer(void* arg) {
|
|||||||
|
|
||||||
// send 1 packet = 1 frame
|
// send 1 packet = 1 frame
|
||||||
sendUDPPacket(0, packetData, packetsize);
|
sendUDPPacket(0, packetData, packetsize);
|
||||||
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||||
|
|
||||||
// calculate time left in period
|
// calculate time left in period
|
||||||
|
@ -9,6 +9,7 @@ add_executable(gotthardDetectorServer_virtual
|
|||||||
../slsDetectorServer/src/LTC2620.c
|
../slsDetectorServer/src/LTC2620.c
|
||||||
../slsDetectorServer/src/common.c
|
../slsDetectorServer/src/common.c
|
||||||
../slsDetectorServer/src/commonServerFunctions.c
|
../slsDetectorServer/src/commonServerFunctions.c
|
||||||
|
../slsDetectorServer/src/communication_funcs_UDP.c
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
@ -4,19 +4,28 @@
|
|||||||
#include "RegisterDefs.h"
|
#include "RegisterDefs.h"
|
||||||
|
|
||||||
#include "LTC2620.h" // dacs
|
#include "LTC2620.h" // dacs
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
#include "communication_funcs_UDP.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include <unistd.h> // usleep
|
#include <unistd.h> // usleep
|
||||||
|
#include <netinet/in.h>
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
|
extern const enum detectorType myDetectorType;
|
||||||
|
|
||||||
// Variables that will be exported
|
// Variables that will be exported
|
||||||
int phaseShift = DEFAULT_PHASE_SHIFT;
|
int phaseShift = DEFAULT_PHASE_SHIFT;
|
||||||
|
|
||||||
|
// Global variable from communication_funcs.c
|
||||||
|
extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||||
|
extern void getIpAddressinString(char* cip, uint32_t ip);
|
||||||
|
|
||||||
int initError = OK;
|
int initError = OK;
|
||||||
int initCheckDone = 0;
|
int initCheckDone = 0;
|
||||||
char initErrorMessage[MAX_STR_LENGTH];
|
char initErrorMessage[MAX_STR_LENGTH];
|
||||||
@ -1263,44 +1272,42 @@ void calcChecksum(mac_conf* mac, int sourceip, int destip) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int configureMAC() {
|
int configureMAC() {
|
||||||
uint32_t sourceip = udpDetails.srcip;
|
uint32_t srcip = udpDetails.srcip;
|
||||||
uint32_t destip = udpDetails.dstip;
|
uint32_t dstip = udpDetails.dstip;
|
||||||
uint64_t sourcemac = udpDetails.srcmac;
|
uint64_t srcmac = udpDetails.srcmac;
|
||||||
uint64_t destmac = udpDetails.dstmac;
|
uint64_t dstmac = udpDetails.dstmac;
|
||||||
int sourceport = udpDetails.srcport;
|
int srcport = udpDetails.srcport;
|
||||||
int destport = udpDetails.dstport;
|
int dstport = udpDetails.dstport;
|
||||||
|
|
||||||
|
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||||
|
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||||
|
getMacAddressinString(src_mac, 50, srcmac);
|
||||||
|
getMacAddressinString(dst_mac, 50, dstmac);
|
||||||
|
getIpAddressinString(src_ip, srcip);
|
||||||
|
getIpAddressinString(dst_ip, dstip);
|
||||||
|
|
||||||
|
LOG(logINFO, (
|
||||||
|
"\tSource IP : %s\n"
|
||||||
|
"\tSource MAC : %s\n"
|
||||||
|
"\tSource Port : %d\n"
|
||||||
|
"\tDest IP : %s\n"
|
||||||
|
"\tDest MAC : %s\n"
|
||||||
|
"\tDest Port : %d\n",
|
||||||
|
src_ip, src_mac, srcport,
|
||||||
|
dst_ip, dst_mac, dstport));
|
||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
|
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||||
|
LOG(logERROR, ("could not set udp 1G destination IP and port\n"));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
return OK;
|
return OK;
|
||||||
#endif
|
#endif
|
||||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
|
||||||
u_int32_t addr = MULTI_PURPOSE_REG;
|
u_int32_t addr = MULTI_PURPOSE_REG;
|
||||||
|
|
||||||
LOG(logDEBUG1, ("\tRoi: %d, Ip Packet size: %d UDP Packet size: %d\n",
|
LOG(logDEBUG1, ("\tRoi: %d, Ip Packet size: %d UDP Packet size: %d\n",
|
||||||
adcConfigured, ipPacketSize, udpPacketSize));
|
adcConfigured, ipPacketSize, udpPacketSize));
|
||||||
|
|
||||||
LOG(logINFO, ("\tSource IP : %d.%d.%d.%d (0x%08x)\n",
|
|
||||||
(sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff, sourceip));
|
|
||||||
LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x (0x%010llx)\n",
|
|
||||||
(unsigned int)((sourcemac>>40)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>32)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>24)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>16)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>8)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>0)&0xFF),
|
|
||||||
(long long unsigned int)sourcemac));
|
|
||||||
LOG(logINFO, ("\tSource Port : %d (0x%08x)\n",sourceport, sourceport));
|
|
||||||
LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d (0x%08x)\n",
|
|
||||||
(destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff, destip));
|
|
||||||
LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x (0x%010llx)\n",
|
|
||||||
(unsigned int)((destmac>>40)&0xFF),
|
|
||||||
(unsigned int)((destmac>>32)&0xFF),
|
|
||||||
(unsigned int)((destmac>>24)&0xFF),
|
|
||||||
(unsigned int)((destmac>>16)&0xFF),
|
|
||||||
(unsigned int)((destmac>>8)&0xFF),
|
|
||||||
(unsigned int)((destmac>>0)&0xFF),
|
|
||||||
(long long unsigned int)destmac));
|
|
||||||
LOG(logINFO, ("\tDest. Port : %d (0x%08x)\n",destport, destport));
|
|
||||||
|
|
||||||
//reset mac
|
//reset mac
|
||||||
bus_w (addr, bus_r(addr) | RST_MSK);
|
bus_w (addr, bus_r(addr) | RST_MSK);
|
||||||
LOG(logDEBUG1, ("\tReset Mac. MultiPurpose reg: 0x%x\n", bus_r(addr)));
|
LOG(logDEBUG1, ("\tReset Mac. MultiPurpose reg: 0x%x\n", bus_r(addr)));
|
||||||
@ -1321,28 +1328,28 @@ int configureMAC() {
|
|||||||
|
|
||||||
LOG(logDEBUG1, ("\tConfiguring MAC CONF\n"));
|
LOG(logDEBUG1, ("\tConfiguring MAC CONF\n"));
|
||||||
mac_conf *mac_conf_regs = (mac_conf*)(Blackfin_getBaseAddress() + ENET_CONF_REG / 2); // direct write
|
mac_conf *mac_conf_regs = (mac_conf*)(Blackfin_getBaseAddress() + ENET_CONF_REG / 2); // direct write
|
||||||
mac_conf_regs->mac.mac_dest_mac1 = ((destmac >> (8 * 5)) & 0xFF);
|
mac_conf_regs->mac.mac_dest_mac1 = ((dstmac >> (8 * 5)) & 0xFF);
|
||||||
mac_conf_regs->mac.mac_dest_mac2 = ((destmac >> (8 * 4)) & 0xFF);
|
mac_conf_regs->mac.mac_dest_mac2 = ((dstmac >> (8 * 4)) & 0xFF);
|
||||||
mac_conf_regs->mac.mac_dest_mac3 = ((destmac >> (8 * 3)) & 0xFF);
|
mac_conf_regs->mac.mac_dest_mac3 = ((dstmac >> (8 * 3)) & 0xFF);
|
||||||
mac_conf_regs->mac.mac_dest_mac4 = ((destmac >> (8 * 2)) & 0xFF);
|
mac_conf_regs->mac.mac_dest_mac4 = ((dstmac >> (8 * 2)) & 0xFF);
|
||||||
mac_conf_regs->mac.mac_dest_mac5 = ((destmac >> (8 * 1)) & 0xFF);
|
mac_conf_regs->mac.mac_dest_mac5 = ((dstmac >> (8 * 1)) & 0xFF);
|
||||||
mac_conf_regs->mac.mac_dest_mac6 = ((destmac >> (8 * 0)) & 0xFF);
|
mac_conf_regs->mac.mac_dest_mac6 = ((dstmac >> (8 * 0)) & 0xFF);
|
||||||
LOG(logDEBUG1, ("\tDestination Mac: %llx %x:%x:%x:%x:%x:%x\n",
|
LOG(logDEBUG1, ("\tDestination Mac: %llx %x:%x:%x:%x:%x:%x\n",
|
||||||
destmac,
|
dstmac,
|
||||||
mac_conf_regs->mac.mac_dest_mac1,
|
mac_conf_regs->mac.mac_dest_mac1,
|
||||||
mac_conf_regs->mac.mac_dest_mac2,
|
mac_conf_regs->mac.mac_dest_mac2,
|
||||||
mac_conf_regs->mac.mac_dest_mac3,
|
mac_conf_regs->mac.mac_dest_mac3,
|
||||||
mac_conf_regs->mac.mac_dest_mac4,
|
mac_conf_regs->mac.mac_dest_mac4,
|
||||||
mac_conf_regs->mac.mac_dest_mac5,
|
mac_conf_regs->mac.mac_dest_mac5,
|
||||||
mac_conf_regs->mac.mac_dest_mac6));
|
mac_conf_regs->mac.mac_dest_mac6));
|
||||||
mac_conf_regs->mac.mac_src_mac1 = ((sourcemac >> (8 * 5)) & 0xFF);
|
mac_conf_regs->mac.mac_src_mac1 = ((srcmac >> (8 * 5)) & 0xFF);
|
||||||
mac_conf_regs->mac.mac_src_mac2 = ((sourcemac >> (8 * 4)) & 0xFF);
|
mac_conf_regs->mac.mac_src_mac2 = ((srcmac >> (8 * 4)) & 0xFF);
|
||||||
mac_conf_regs->mac.mac_src_mac3 = ((sourcemac >> (8 * 3)) & 0xFF);
|
mac_conf_regs->mac.mac_src_mac3 = ((srcmac >> (8 * 3)) & 0xFF);
|
||||||
mac_conf_regs->mac.mac_src_mac4 = ((sourcemac >> (8 * 2)) & 0xFF);
|
mac_conf_regs->mac.mac_src_mac4 = ((srcmac >> (8 * 2)) & 0xFF);
|
||||||
mac_conf_regs->mac.mac_src_mac5 = ((sourcemac >> (8 * 1)) & 0xFF);
|
mac_conf_regs->mac.mac_src_mac5 = ((srcmac >> (8 * 1)) & 0xFF);
|
||||||
mac_conf_regs->mac.mac_src_mac6 = ((sourcemac >> (8 * 0)) & 0xFF);
|
mac_conf_regs->mac.mac_src_mac6 = ((srcmac >> (8 * 0)) & 0xFF);
|
||||||
LOG(logDEBUG1, ("\tSource Mac: %llx %x:%x:%x:%x:%x:%x\n",
|
LOG(logDEBUG1, ("\tSource Mac: %llx %x:%x:%x:%x:%x:%x\n",
|
||||||
sourcemac,
|
srcmac,
|
||||||
mac_conf_regs->mac.mac_src_mac1,
|
mac_conf_regs->mac.mac_src_mac1,
|
||||||
mac_conf_regs->mac.mac_src_mac2,
|
mac_conf_regs->mac.mac_src_mac2,
|
||||||
mac_conf_regs->mac.mac_src_mac3,
|
mac_conf_regs->mac.mac_src_mac3,
|
||||||
@ -1351,9 +1358,9 @@ int configureMAC() {
|
|||||||
mac_conf_regs->mac.mac_src_mac6));
|
mac_conf_regs->mac.mac_src_mac6));
|
||||||
mac_conf_regs->mac.mac_ether_type = 0x0800; //ipv4
|
mac_conf_regs->mac.mac_ether_type = 0x0800; //ipv4
|
||||||
|
|
||||||
calcChecksum(mac_conf_regs, sourceip, destip);
|
calcChecksum(mac_conf_regs, srcip, dstip);
|
||||||
mac_conf_regs->udp.udp_srcport = sourceport;
|
mac_conf_regs->udp.udp_srcport = srcport;
|
||||||
mac_conf_regs->udp.udp_destport = destport;
|
mac_conf_regs->udp.udp_destport = dstport;
|
||||||
mac_conf_regs->udp.udp_len = udpPacketSize;
|
mac_conf_regs->udp.udp_len = udpPacketSize;
|
||||||
mac_conf_regs->udp.udp_chksum = 0x0000;
|
mac_conf_regs->udp.udp_chksum = 0x0000;
|
||||||
|
|
||||||
@ -1488,11 +1495,16 @@ int setPhase(enum CLKINDEX ind, int val, int degrees) {
|
|||||||
|
|
||||||
int startStateMachine(){
|
int startStateMachine(){
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_status = 1;
|
// create udp socket
|
||||||
|
if(createUDPSocket(0) != OK) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||||
|
virtual_status = 1;
|
||||||
virtual_stop = 0;
|
virtual_stop = 0;
|
||||||
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||||
virtual_status = 0;
|
|
||||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||||
|
virtual_status = 0;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||||
@ -1512,17 +1524,83 @@ int startStateMachine(){
|
|||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
void* start_timer(void* arg) {
|
void* start_timer(void* arg) {
|
||||||
int wait_in_s = (getNumFrames() *
|
int64_t periodNs = getPeriod();
|
||||||
getNumTriggers() *
|
int numFrames = (getNumFrames() *
|
||||||
(getPeriod()/(1E9)));
|
getNumTriggers() );
|
||||||
LOG(logDEBUG1, ("going to wait for %d s\n", wait_in_s));
|
int64_t expUs = getExpTime() / 1000;
|
||||||
while(!virtual_stop && (wait_in_s >= 0)) {
|
|
||||||
usleep(1000 * 1000);
|
int imageSize = adcConfigured == -1 ? DATA_BYTES : NCHAN_PER_ADC * NUM_BITS_PER_PIXEL;
|
||||||
wait_in_s--;
|
int dataSize = adcConfigured == -1 ? 1280 : 512;
|
||||||
}
|
int packetSize = adcConfigured == -1 ? 1286 : 518;
|
||||||
LOG(logINFOGREEN, ("Virtual Timer Done\n"));
|
int packetsPerFrame = adcConfigured == -1 ? 2 : 1;
|
||||||
|
|
||||||
|
// Generate Data
|
||||||
|
char imageData[imageSize];
|
||||||
|
memset(imageData, 0, imageSize);
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
if (adcConfigured == -1) {
|
||||||
|
*((uint32_t*)(imageData)) = 0xCACACACA;
|
||||||
|
}
|
||||||
|
for (i = 4; i < imageSize; i += sizeof(uint16_t)) {
|
||||||
|
*((uint16_t*)(imageData + i)) = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send data
|
||||||
|
{
|
||||||
|
int frameNr = 0;
|
||||||
|
int frameHeaderNr = 2;
|
||||||
|
// loop over number of frames
|
||||||
|
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
||||||
|
|
||||||
|
//check if virtual_stop is high
|
||||||
|
if(virtual_stop == 1){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// sleep for exposure time
|
||||||
|
struct timespec begin, end;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
|
usleep(expUs);
|
||||||
|
|
||||||
|
int srcOffset = 0;
|
||||||
|
char packetData[packetSize];
|
||||||
|
memset(packetData, 0, packetSize);
|
||||||
|
|
||||||
|
// loop packet
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
for(i = 0; i != packetsPerFrame; ++i) {
|
||||||
|
// set header
|
||||||
|
*((uint16_t*)(packetData)) = frameHeaderNr;
|
||||||
|
++frameHeaderNr;
|
||||||
|
|
||||||
|
// fill data
|
||||||
|
memcpy(packetData + 4, imageData + srcOffset, dataSize);
|
||||||
|
srcOffset += dataSize;
|
||||||
|
|
||||||
|
sendUDPPacket(0, packetData, packetSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||||
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
|
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||||
|
(end.tv_nsec - begin.tv_nsec));
|
||||||
|
|
||||||
|
// sleep for (period - exptime)
|
||||||
|
if (frameNr < numFrames) { // if there is a next frame
|
||||||
|
if (periodNs > timeNs) {
|
||||||
|
usleep((periodNs - timeNs)/ 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closeUDPSocket(0);
|
||||||
|
|
||||||
virtual_status = 0;
|
virtual_status = 0;
|
||||||
|
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,6 +23,10 @@ extern int debugflag;
|
|||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
extern const enum detectorType myDetectorType;
|
extern const enum detectorType myDetectorType;
|
||||||
|
|
||||||
|
// Global variable from communication_funcs.c
|
||||||
|
extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||||
|
extern void getIpAddressinString(char* cip, uint32_t ip);
|
||||||
|
|
||||||
int initError = OK;
|
int initError = OK;
|
||||||
int initCheckDone = 0;
|
int initCheckDone = 0;
|
||||||
char initErrorMessage[MAX_STR_LENGTH];
|
char initErrorMessage[MAX_STR_LENGTH];
|
||||||
@ -1672,7 +1676,7 @@ void* start_timer(void* arg) {
|
|||||||
const int numPacketsPerFrame = 128;
|
const int numPacketsPerFrame = 128;
|
||||||
int transmissionDelayUs = getTransmissionDelayFrame() * 1000;
|
int transmissionDelayUs = getTransmissionDelayFrame() * 1000;
|
||||||
|
|
||||||
//TODO: Generate data
|
// Generate data
|
||||||
char imageData[DATA_BYTES];
|
char imageData[DATA_BYTES];
|
||||||
memset(imageData, 0, DATA_BYTES);
|
memset(imageData, 0, DATA_BYTES);
|
||||||
{
|
{
|
||||||
@ -1684,7 +1688,7 @@ void* start_timer(void* arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: Send data
|
// Send data
|
||||||
{
|
{
|
||||||
int frameNr = 0;
|
int frameNr = 0;
|
||||||
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
||||||
@ -1696,13 +1700,12 @@ void* start_timer(void* arg) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int srcOffset = 0;
|
// sleep for exposure time
|
||||||
|
|
||||||
struct timespec begin, end;
|
struct timespec begin, end;
|
||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
|
|
||||||
usleep(exp_us);
|
usleep(exp_us);
|
||||||
|
|
||||||
|
int srcOffset = 0;
|
||||||
char packetData[packetsize];
|
char packetData[packetsize];
|
||||||
memset(packetData, 0, packetsize);
|
memset(packetData, 0, packetsize);
|
||||||
|
|
||||||
|
@ -11,19 +11,26 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h> // usleep
|
#include <unistd.h> // usleep
|
||||||
|
#include <netinet/in.h>
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <math.h> //ceil
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Global variable from slsDetectorServer_funcs
|
// Global variable from slsDetectorServer_funcs
|
||||||
extern int debugflag;
|
extern int debugflag;
|
||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
|
extern const enum detectorType myDetectorType;
|
||||||
|
|
||||||
// Global variable from UDPPacketHeaderGenerator
|
// Global variable from UDPPacketHeaderGenerator
|
||||||
extern uint64_t udpFrameNumber;
|
extern uint64_t udpFrameNumber;
|
||||||
extern uint32_t udpPacketNumber;
|
extern uint32_t udpPacketNumber;
|
||||||
|
|
||||||
|
// Global variable from communication_funcs.c
|
||||||
|
extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||||
|
extern void getIpAddressinString(char* cip, uint32_t ip);
|
||||||
|
|
||||||
int initError = OK;
|
int initError = OK;
|
||||||
int initCheckDone = 0;
|
int initCheckDone = 0;
|
||||||
char initErrorMessage[MAX_STR_LENGTH];
|
char initErrorMessage[MAX_STR_LENGTH];
|
||||||
@ -1136,26 +1143,36 @@ void calcChecksum(udp_header* udp) {
|
|||||||
|
|
||||||
|
|
||||||
int configureMAC(){
|
int configureMAC(){
|
||||||
uint32_t sourceip = udpDetails.srcip;
|
uint32_t srcip = udpDetails.srcip;
|
||||||
uint32_t destip = udpDetails.dstip;
|
uint32_t dstip = udpDetails.dstip;
|
||||||
uint64_t sourcemac = udpDetails.srcmac;
|
uint64_t srcmac = udpDetails.srcmac;
|
||||||
uint64_t destmac = udpDetails.dstmac;
|
uint64_t dstmac = udpDetails.dstmac;
|
||||||
int sourceport = udpDetails.srcport;
|
int srcport = udpDetails.srcport;
|
||||||
int destport = udpDetails.dstport;
|
int dstport = udpDetails.dstport;
|
||||||
#ifdef VIRTUAL
|
|
||||||
return OK;
|
|
||||||
#endif
|
|
||||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||||
|
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||||
|
getMacAddressinString(src_mac, 50, srcmac);
|
||||||
|
getMacAddressinString(dst_mac, 50, dstmac);
|
||||||
|
getIpAddressinString(src_ip, srcip);
|
||||||
|
getIpAddressinString(dst_ip, dstip);
|
||||||
|
|
||||||
|
LOG(logINFO, (
|
||||||
|
"\tSource IP : %s\n"
|
||||||
|
"\tSource MAC : %s\n"
|
||||||
|
"\tSource Port : %d\n"
|
||||||
|
"\tDest IP : %s\n"
|
||||||
|
"\tDest MAC : %s\n"
|
||||||
|
"\tDest Port : %d\n",
|
||||||
|
src_ip, src_mac, srcport,
|
||||||
|
dst_ip, dst_mac, dstport));
|
||||||
|
|
||||||
// 1 giga udp
|
// 1 giga udp
|
||||||
if (!enableTenGigabitEthernet(-1)) {
|
if (!enableTenGigabitEthernet(-1)) {
|
||||||
LOG(logINFOBLUE, ("Configuring 1G MAC\n"));
|
LOG(logINFOBLUE, ("\t1G MAC\n"));
|
||||||
if (updateDatabytesandAllocateRAM() == FAIL)
|
if (updateDatabytesandAllocateRAM() == FAIL)
|
||||||
return -1;
|
return -1;
|
||||||
char cDestIp[MAX_STR_LENGTH];
|
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
|
||||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
|
||||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, destport));
|
|
||||||
if (setUDPDestinationDetails(0, cDestIp, destport) == FAIL) {
|
|
||||||
LOG(logERROR, ("could not set udp 1G destination IP and port\n"));
|
LOG(logERROR, ("could not set udp 1G destination IP and port\n"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -1163,31 +1180,7 @@ int configureMAC(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 10 G
|
// 10 G
|
||||||
LOG(logINFOBLUE, ("Configuring 10G MAC\n"));
|
LOG(logINFOBLUE, ("\t10G MAC\n"));
|
||||||
|
|
||||||
LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
|
||||||
(sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff, sourceip));
|
|
||||||
LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
|
||||||
(unsigned int)((sourcemac>>40)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>32)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>24)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>16)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>8)&0xFF),
|
|
||||||
(unsigned int)((sourcemac>>0)&0xFF),
|
|
||||||
(long long unsigned int)sourcemac));
|
|
||||||
LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n",sourceport, sourceport));
|
|
||||||
|
|
||||||
LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
|
||||||
(destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff, destip));
|
|
||||||
LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
|
||||||
(unsigned int)((destmac>>40)&0xFF),
|
|
||||||
(unsigned int)((destmac>>32)&0xFF),
|
|
||||||
(unsigned int)((destmac>>24)&0xFF),
|
|
||||||
(unsigned int)((destmac>>16)&0xFF),
|
|
||||||
(unsigned int)((destmac>>8)&0xFF),
|
|
||||||
(unsigned int)((destmac>>0)&0xFF),
|
|
||||||
(long long unsigned int)destmac));
|
|
||||||
LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n",destport, destport));
|
|
||||||
|
|
||||||
// start addr
|
// start addr
|
||||||
uint32_t addr = RXR_ENDPOINT_START_REG;
|
uint32_t addr = RXR_ENDPOINT_START_REG;
|
||||||
@ -1197,21 +1190,21 @@ int configureMAC(){
|
|||||||
|
|
||||||
// mac addresses
|
// mac addresses
|
||||||
// msb (32) + lsb (16)
|
// msb (32) + lsb (16)
|
||||||
udp->udp_destmac_msb = ((destmac >> 16) & BIT32_MASK);
|
udp->udp_destmac_msb = ((dstmac >> 16) & BIT32_MASK);
|
||||||
udp->udp_destmac_lsb = ((destmac >> 0) & BIT16_MASK);
|
udp->udp_destmac_lsb = ((dstmac >> 0) & BIT16_MASK);
|
||||||
// msb (16) + lsb (32)
|
// msb (16) + lsb (32)
|
||||||
udp->udp_srcmac_msb = ((sourcemac >> 32) & BIT16_MASK);
|
udp->udp_srcmac_msb = ((srcmac >> 32) & BIT16_MASK);
|
||||||
udp->udp_srcmac_lsb = ((sourcemac >> 0) & BIT32_MASK);
|
udp->udp_srcmac_lsb = ((srcmac >> 0) & BIT32_MASK);
|
||||||
|
|
||||||
// ip addresses
|
// ip addresses
|
||||||
udp->ip_srcip_msb = ((sourceip >> 16) & BIT16_MASK);
|
udp->ip_srcip_msb = ((srcip >> 16) & BIT16_MASK);
|
||||||
udp->ip_srcip_lsb = ((sourceip >> 0) & BIT16_MASK);
|
udp->ip_srcip_lsb = ((srcip >> 0) & BIT16_MASK);
|
||||||
udp->ip_destip_msb = ((destip >> 16) & BIT16_MASK);
|
udp->ip_destip_msb = ((dstip >> 16) & BIT16_MASK);
|
||||||
udp->ip_destip_lsb = ((destip >> 0) & BIT16_MASK);
|
udp->ip_destip_lsb = ((dstip >> 0) & BIT16_MASK);
|
||||||
|
|
||||||
// source port
|
// source port
|
||||||
udp->udp_srcport = sourceport;
|
udp->udp_srcport = srcport;
|
||||||
udp->udp_destport = destport;
|
udp->udp_destport = dstport;
|
||||||
|
|
||||||
// other defines
|
// other defines
|
||||||
udp->udp_ethertype = 0x800;
|
udp->udp_ethertype = 0x800;
|
||||||
@ -1242,6 +1235,9 @@ int* getDetectorPosition() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int enableTenGigabitEthernet(int val) {
|
int enableTenGigabitEthernet(int val) {
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
uint32_t addr = CONFIG_REG;
|
uint32_t addr = CONFIG_REG;
|
||||||
|
|
||||||
// set
|
// set
|
||||||
@ -1819,11 +1815,16 @@ uint64_t getPatternBitMask() {
|
|||||||
|
|
||||||
int startStateMachine(){
|
int startStateMachine(){
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_status = 1;
|
// create udp socket
|
||||||
|
if(createUDPSocket(0) != OK) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||||
|
virtual_status = 1;
|
||||||
virtual_stop = 0;
|
virtual_stop = 0;
|
||||||
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||||
virtual_status = 0;
|
|
||||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||||
|
virtual_status = 0;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||||
@ -1857,41 +1858,83 @@ int startStateMachine(){
|
|||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
void* start_timer(void* arg) {
|
void* start_timer(void* arg) {
|
||||||
int64_t periodns = getPeriod();
|
int64_t periodNs = getPeriod();
|
||||||
int numFrames = (getNumFrames() *
|
int numFrames = (getNumFrames() *
|
||||||
getNumTriggers() );
|
getNumTriggers() );
|
||||||
int64_t exp_ns = getExpTime();
|
int64_t expNs = getExpTime();
|
||||||
|
|
||||||
int frameNr = 0;
|
int imageSize = dataBytes;
|
||||||
// loop over number of frames
|
int dataSize = UDP_PACKET_DATA_BYTES;
|
||||||
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
int packetSize = sizeof(sls_detector_header) + dataSize;
|
||||||
|
int packetsPerFrame = ceil((double)imageSize / (double)dataSize);
|
||||||
|
|
||||||
//check if virtual_stop is high
|
// Generate Data
|
||||||
if(virtual_stop == 1){
|
char imageData[imageSize];
|
||||||
break;
|
memset(imageData, 0, imageSize);
|
||||||
}
|
{
|
||||||
|
int i = 0;
|
||||||
// sleep for exposure time
|
for (i = 0; i < imageSize; i += sizeof(uint16_t)) {
|
||||||
struct timespec begin, end;
|
*((uint16_t*)(imageData + i)) = i;
|
||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
}
|
||||||
usleep(exp_ns / 1000);
|
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
|
||||||
|
|
||||||
// calculate time left in period
|
|
||||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
|
||||||
(end.tv_nsec - begin.tv_nsec));
|
|
||||||
|
|
||||||
// sleep for (period - exptime)
|
|
||||||
if (frameNr < numFrames) { // if there is a next frame
|
|
||||||
if (periodns > time_ns) {
|
|
||||||
usleep((periodns - time_ns)/ 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set register frames left
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set status to idle
|
// Send data
|
||||||
|
{
|
||||||
|
int frameNr = 0;
|
||||||
|
// loop over number of frames
|
||||||
|
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
||||||
|
|
||||||
|
//check if virtual_stop is high
|
||||||
|
if(virtual_stop == 1){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// sleep for exposure time
|
||||||
|
struct timespec begin, end;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
|
usleep(expNs / 1000);
|
||||||
|
|
||||||
|
int srcOffset = 0;
|
||||||
|
char packetData[packetSize];
|
||||||
|
memset(packetData, 0, packetSize);
|
||||||
|
|
||||||
|
// loop packet
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
for(i = 0; i != packetsPerFrame; ++i) {
|
||||||
|
// set header
|
||||||
|
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||||
|
header->detType = (uint16_t)myDetectorType;
|
||||||
|
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||||
|
header->frameNumber = frameNr;
|
||||||
|
header->packetNumber = i;
|
||||||
|
header->modId = 0;
|
||||||
|
header->row = detPos[X];
|
||||||
|
header->column = detPos[Y];
|
||||||
|
|
||||||
|
// fill data
|
||||||
|
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, dataSize);
|
||||||
|
srcOffset += dataSize;
|
||||||
|
|
||||||
|
sendUDPPacket(0, packetData, packetSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||||
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
|
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||||
|
(end.tv_nsec - begin.tv_nsec));
|
||||||
|
|
||||||
|
// sleep for (period - exptime)
|
||||||
|
if (frameNr < numFrames) { // if there is a next frame
|
||||||
|
if (periodNs > timeNs) {
|
||||||
|
usleep((periodNs - timeNs)/ 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closeUDPSocket(0);
|
||||||
|
|
||||||
virtual_status = 0;
|
virtual_status = 0;
|
||||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -22,6 +22,10 @@ extern int debugflag;
|
|||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
extern const enum detectorType myDetectorType;
|
extern const enum detectorType myDetectorType;
|
||||||
|
|
||||||
|
// Global variable from communication_funcs.c
|
||||||
|
extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||||
|
extern void getIpAddressinString(char* cip, uint32_t ip);
|
||||||
|
|
||||||
int initError = OK;
|
int initError = OK;
|
||||||
int initCheckDone = 0;
|
int initCheckDone = 0;
|
||||||
char initErrorMessage[MAX_STR_LENGTH];
|
char initErrorMessage[MAX_STR_LENGTH];
|
||||||
|
@ -616,7 +616,12 @@ void getMacAddressinString(char* cmac, int size, uint64_t mac) {
|
|||||||
|
|
||||||
void getIpAddressinString(char* cip, uint32_t ip) {
|
void getIpAddressinString(char* cip, uint32_t ip) {
|
||||||
memset(cip, 0, INET_ADDRSTRLEN);
|
memset(cip, 0, INET_ADDRSTRLEN);
|
||||||
|
#if defined(EIGERD) && !defined(VIRTUAL)
|
||||||
inet_ntop(AF_INET, &ip, cip, INET_ADDRSTRLEN);
|
inet_ntop(AF_INET, &ip, cip, INET_ADDRSTRLEN);
|
||||||
|
#else
|
||||||
|
sprintf(cip, "%d.%d.%d.%d",
|
||||||
|
(ip>>24)&0xff,(ip>>16)&0xff,(ip>>8)&0xff,(ip)&0xff);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
int udpSockfd[2] = {-1, -1};
|
int udpSockfd[2] = {-1, -1};
|
||||||
struct addrinfo* udpServerAddrInfo[2] = {0, 0};
|
struct addrinfo* udpServerAddrInfo[2] = {0, 0};
|
||||||
unsigned short int udpDestinationPort[2] = {0, 0};
|
unsigned short int udpDestinationPort[2] = {0, 0};
|
||||||
char udpDestinationIp[2][MAX_STR_LENGTH] = {"", ""};
|
char udpDestinationIp[2][INET_ADDRSTRLEN] = {"", ""};
|
||||||
|
|
||||||
//DEFAULT_TX_UDP_PORT;// src port
|
//DEFAULT_TX_UDP_PORT;// src port
|
||||||
int getUdPSocketDescriptor(int index) {
|
int getUdPSocketDescriptor(int index) {
|
||||||
@ -26,8 +26,8 @@ int getUdPSocketDescriptor(int index) {
|
|||||||
int setUDPDestinationDetails(int index, const char* ip, unsigned short int port) {
|
int setUDPDestinationDetails(int index, const char* ip, unsigned short int port) {
|
||||||
udpDestinationPort[index] = port;
|
udpDestinationPort[index] = port;
|
||||||
size_t len = strlen(ip);
|
size_t len = strlen(ip);
|
||||||
memset(udpDestinationIp[index], 0, MAX_STR_LENGTH);
|
memset(udpDestinationIp[index], 0, INET_ADDRSTRLEN);
|
||||||
strncpy(udpDestinationIp[index], ip, len > MAX_STR_LENGTH ? MAX_STR_LENGTH : len );
|
strncpy(udpDestinationIp[index], ip, len > INET_ADDRSTRLEN ? INET_ADDRSTRLEN : len );
|
||||||
|
|
||||||
if (udpServerAddrInfo[index]) {
|
if (udpServerAddrInfo[index]) {
|
||||||
freeaddrinfo(udpServerAddrInfo[index]);
|
freeaddrinfo(udpServerAddrInfo[index]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user