mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-27 00:30:03 +02:00
gotthard2 virtual server sends data
This commit is contained in:
parent
bdf3a010c3
commit
2e78484b61
@ -22,7 +22,7 @@ target_include_directories(gotthard2DetectorServer_virtual
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(gotthard2DetectorServer_virtual
|
target_compile_definitions(gotthard2DetectorServer_virtual
|
||||||
PUBLIC GOTTHARD2D VIRTUAL STOP_SERVER
|
PUBLIC GOTTHARD2D VIRTUAL STOP_SERVER DEBUG1
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(gotthard2DetectorServer_virtual
|
target_link_libraries(gotthard2DetectorServer_virtual
|
||||||
|
@ -155,6 +155,21 @@
|
|||||||
#define PKT_CONFIG_RXR_START_ID_OFST (8)
|
#define PKT_CONFIG_RXR_START_ID_OFST (8)
|
||||||
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST)
|
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST)
|
||||||
|
|
||||||
|
/* Module Coordinates Register */
|
||||||
|
#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT)
|
||||||
|
#define COORD_ROW_OFST (0)
|
||||||
|
#define COORD_ROW_MSK (0x0000FFFF << COORD_ROW_OFST)
|
||||||
|
#define COORD_COL_OFST (16)
|
||||||
|
#define COORD_COL_MSK (0x0000FFFF << COORD_COL_OFST)
|
||||||
|
|
||||||
|
/* Module ID Register */
|
||||||
|
#define COORD_1_REG (0x03 * REG_OFFSET + BASE_PKT)
|
||||||
|
#define COORD_RESERVED_OFST (0)
|
||||||
|
#define COORD_RESERVED_MSK (0x0000FFFF << COORD_RESERVED_OFST)
|
||||||
|
#define COORD_ID_OFST (16) // Not connected in firmware TODO
|
||||||
|
#define COORD_ID_MSK (0x0000FFFF << COORD_ID_OFST) // Not connected in firmware TODO
|
||||||
|
|
||||||
|
|
||||||
/* Flow control registers --------------------------------------------------*/
|
/* Flow control registers --------------------------------------------------*/
|
||||||
|
|
||||||
/* Flow status Register*/
|
/* Flow status Register*/
|
||||||
|
Binary file not shown.
@ -24,6 +24,7 @@
|
|||||||
extern int debugflag;
|
extern int debugflag;
|
||||||
extern int checkModuleFlag;
|
extern int checkModuleFlag;
|
||||||
extern udpStruct udpDetails;
|
extern udpStruct udpDetails;
|
||||||
|
extern const enum detectorType myDetectorType;
|
||||||
|
|
||||||
int initError = OK;
|
int initError = OK;
|
||||||
int initCheckDone = 0;
|
int initCheckDone = 0;
|
||||||
@ -422,10 +423,12 @@ void setupDetector() {
|
|||||||
// power on chip
|
// power on chip
|
||||||
powerChip(1);
|
powerChip(1);
|
||||||
|
|
||||||
|
#ifndef VIRTUAL
|
||||||
// also sets default dac and on chip dac values
|
// also sets default dac and on chip dac values
|
||||||
if (readConfigFile() == FAIL) {
|
if (readConfigFile() == FAIL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// set burst mode will take in burstType and also set it
|
// set burst mode will take in burstType and also set it
|
||||||
burstType = DEFAULT_BURST_TYPE;
|
burstType = DEFAULT_BURST_TYPE;
|
||||||
setBurstMode(DEFAULT_BURST_MODE);
|
setBurstMode(DEFAULT_BURST_MODE);
|
||||||
@ -1169,7 +1172,35 @@ void calcChecksum(udp_header* udp) {
|
|||||||
|
|
||||||
int setDetectorPosition(int pos[]) {
|
int setDetectorPosition(int pos[]) {
|
||||||
memcpy(detPos, pos, sizeof(detPos));
|
memcpy(detPos, pos, sizeof(detPos));
|
||||||
return OK;
|
|
||||||
|
uint32_t addr = COORD_0_REG;
|
||||||
|
int value = 0;
|
||||||
|
int valueRead = 0;
|
||||||
|
int ret = OK;
|
||||||
|
|
||||||
|
// row
|
||||||
|
value = detPos[X];
|
||||||
|
bus_w(addr, (bus_r(addr) &~COORD_ROW_MSK) | ((value << COORD_ROW_OFST) & COORD_ROW_MSK));
|
||||||
|
valueRead = ((bus_r(addr) & COORD_ROW_MSK) >> COORD_ROW_OFST);
|
||||||
|
if (valueRead != value) {
|
||||||
|
FILE_LOG(logERROR, ("Could not set row. Set %d, read %d\n", value, valueRead));
|
||||||
|
ret = FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// col
|
||||||
|
value = detPos[Y];
|
||||||
|
bus_w(addr, (bus_r(addr) &~COORD_COL_MSK) | ((value << COORD_COL_OFST) & COORD_COL_MSK));
|
||||||
|
valueRead = ((bus_r(addr) & COORD_COL_MSK) >> COORD_COL_OFST);
|
||||||
|
if (valueRead != value) {
|
||||||
|
FILE_LOG(logERROR, ("Could not set column. Set %d, read %d\n", value, valueRead));
|
||||||
|
ret = FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == OK) {
|
||||||
|
FILE_LOG(logINFO, ("\tPosition set to [%d, %d]\n", detPos[X], detPos[Y]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int* getDetectorPosition() {
|
int* getDetectorPosition() {
|
||||||
@ -1847,6 +1878,8 @@ void* start_timer(void* arg) {
|
|||||||
int numFrames = (getNumFrames() *
|
int numFrames = (getNumFrames() *
|
||||||
getNumTriggers() );
|
getNumTriggers() );
|
||||||
int64_t exp_ns = getExpTime();
|
int64_t exp_ns = getExpTime();
|
||||||
|
int datasize = 2560;
|
||||||
|
int packetsize = datasize + sizeof(sls_detector_header);
|
||||||
|
|
||||||
|
|
||||||
int frameNr = 0;
|
int frameNr = 0;
|
||||||
@ -1864,6 +1897,22 @@ void* start_timer(void* arg) {
|
|||||||
usleep(exp_ns / 1000);
|
usleep(exp_ns / 1000);
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
|
|
||||||
|
char packetData[packetsize];
|
||||||
|
memset(packetData, 0, packetsize);
|
||||||
|
// set header
|
||||||
|
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||||
|
header->frameNumber = frameNr;
|
||||||
|
header->packetNumber = 0;
|
||||||
|
header->modId = 0;
|
||||||
|
header->row = detPos[X];
|
||||||
|
header->column = detPos[Y];
|
||||||
|
header->detType = (uint16_t)myDetectorType;
|
||||||
|
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||||
|
|
||||||
|
// send 1 packet = 1 frame
|
||||||
|
sendUDPPacket(0, packetData, packetsize);
|
||||||
|
FILE_LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||||
|
|
||||||
// calculate time left in period
|
// calculate time left in period
|
||||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||||
(end.tv_nsec - begin.tv_nsec));
|
(end.tv_nsec - begin.tv_nsec));
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
// 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;
|
||||||
|
|
||||||
int initError = OK;
|
int initError = OK;
|
||||||
int initCheckDone = 0;
|
int initCheckDone = 0;
|
||||||
@ -1667,7 +1668,7 @@ void* start_timer(void* arg) {
|
|||||||
|
|
||||||
usleep(exp_us);
|
usleep(exp_us);
|
||||||
|
|
||||||
const int size = datasize + 112;
|
const int size = datasize + sizeof(sls_detector_header);
|
||||||
char packetData[size];
|
char packetData[size];
|
||||||
memset(packetData, 0, sizeof(sls_detector_header));
|
memset(packetData, 0, sizeof(sls_detector_header));
|
||||||
|
|
||||||
@ -1679,6 +1680,11 @@ void* start_timer(void* arg) {
|
|||||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||||
header->frameNumber = frameNr;
|
header->frameNumber = frameNr;
|
||||||
header->packetNumber = i;
|
header->packetNumber = i;
|
||||||
|
header->modId = 0;
|
||||||
|
header->row = detPos[X];
|
||||||
|
header->column = detPos[Y];
|
||||||
|
header->detType = (uint16_t)myDetectorType;
|
||||||
|
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||||
// fill data
|
// fill data
|
||||||
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, datasize);
|
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, datasize);
|
||||||
srcOffset += datasize;
|
srcOffset += datasize;
|
||||||
|
@ -38,6 +38,9 @@ int ASIC_Driver_Set (int index, int length, char* buffer) {
|
|||||||
FILE_LOG(logDEBUG1, ("\t]\n"));
|
FILE_LOG(logDEBUG1, ("\t]\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
return OK;
|
||||||
|
#endif
|
||||||
int fd=open(fname, O_RDWR);
|
int fd=open(fname, O_RDWR);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
FILE_LOG(logERROR, ("Could not open file %s for writing to control ASIC (%d)\n", fname, index));
|
FILE_LOG(logERROR, ("Could not open file %s for writing to control ASIC (%d)\n", fname, index));
|
||||||
|
@ -9,4 +9,4 @@
|
|||||||
#define APICTB 0x191210
|
#define APICTB 0x191210
|
||||||
#define APIEIGER 0x200110
|
#define APIEIGER 0x200110
|
||||||
#define APIMYTHEN3 0x200120
|
#define APIMYTHEN3 0x200120
|
||||||
#define APIGOTTHARD2 0x200120
|
#define APIGOTTHARD2 0x200121
|
||||||
|
Loading…
x
Reference in New Issue
Block a user