diff --git a/CMakeLists.txt b/CMakeLists.txt index 1313c48bb..5676ec92d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -249,8 +249,8 @@ endif() if(SLS_USE_SANITIZER) target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer) target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined) - # target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread) - # target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread) + #target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread -fno-omit-frame-pointer) + #target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread) endif() diff --git a/docs/conf.py.in b/docs/conf.py.in index c5db6e684..e6925b044 100644 --- a/docs/conf.py.in +++ b/docs/conf.py.in @@ -63,4 +63,4 @@ html_static_path = ['static'] def setup(app): - app.add_stylesheet('css/extra.css') # may also be an URL \ No newline at end of file + app.add_css_file('css/extra.css') # may also be an URL diff --git a/docs/src/commandline.rst b/docs/src/commandline.rst index 4b54da9b9..25afce8ad 100644 --- a/docs/src/commandline.rst +++ b/docs/src/commandline.rst @@ -4,11 +4,54 @@ Command line interface Usage ------------- -Commands can be used either with sls_detector_get or sls_detector_put +The syntax is *'[detector index]-[module index]:[command]'*, where the indices are by default '0', when not specified. + +Module index +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Modules are indexed based on their order in the hostname command. They are used to configure a specific module within a detector and are followed by a ':' in syntax. + + .. code-block:: + + # Applies to all modules of detector 0 + sls_detector_put exptime 5s + + # Applies to only the 4th module + sls_detector_put 3:exptime 5s + + +Detector index +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +This index is useful when configuring multiple detectors from a single host. Each detector uses a unique shared memory identified by a detector index, derived again from the hostname command. It is followed by a '-'. + + .. code-block:: + + # For detector with index 2 in shared memory + sls_detector_put 2-hostname bchip133+bchip123+bchip456 + + # Without '-', the detector index defaults to 0 + sls_detector_put hostname bchip133+bchip123+bchip456 + + # Accessing all modules with detector index 2 + sls_detector_put 2-exptime + + # Starting acquisition only for detector with index 2 + sls_detector_put 2-start + + # Applies only to the 2nd detector, 4th module + sls_detector_put 1-3:exptime 5s + + +Command Execution +^^^^^^^^^^^^^^^^^^^^^^^ +Commands can be executed using: + +* **sls_detector_put**: setting values +* **sls_detector_get**: getting values +* **sls_detector**: automatically infers based on the number of arguments. +* **sls_detector_help**: gets help on the specific command +* **sls_detector_acquire**: initiates acquisition with the detector. This command blocks until the entire acquisition process is completed. -.. code-block:: - sls_detector_get exptime Help -------- @@ -28,12 +71,15 @@ Help # list of deprecated commands list deprecated - # autocompletion - # bash_autocomplete.sh or zsh_autocomplete.sh must be sourced from the - # main package folder to enable auto completion of commands and arguments - # for the command line on that shell. - source bash_autocomplete.sh +Autocompletion +--------------- + +bash_autocomplete.sh or zsh_autocomplete.sh must be sourced from the main package folder to enable auto completion of commands and arguments for the command line on that shell. + +.. code-block:: + + source bash_autocomplete.sh Commands diff --git a/docs/src/detector.rst b/docs/src/detector.rst index 9c8ec8be2..af09d792a 100644 --- a/docs/src/detector.rst +++ b/docs/src/detector.rst @@ -13,7 +13,6 @@ containing results from all modules. (:ref:`Result class`) Here are some :ref:`examples ` on how to use the API. -.. _Cplusplus Api Examples: .. doxygenclass:: sls::Detector :members: :undoc-members: \ No newline at end of file diff --git a/docs/src/index.rst b/docs/src/index.rst index 2a333c03e..af291cd6e 100644 --- a/docs/src/index.rst +++ b/docs/src/index.rst @@ -39,7 +39,7 @@ Welcome to slsDetectorPackage's documentation! .. toctree:: :caption: Command line - :maxdepth: 2 + :maxdepth: 1 commandline quick_start_guide diff --git a/docs/src/masterfileattributes.rst b/docs/src/masterfileattributes.rst index fb3aba0e5..90793f3c0 100644 --- a/docs/src/masterfileattributes.rst +++ b/docs/src/masterfileattributes.rst @@ -1,5 +1,6 @@ .. _master file attributes: + Master File Attributes ======================= diff --git a/docs/src/quick_start_guide.rst b/docs/src/quick_start_guide.rst index 9ccd28506..3e4efc943 100644 --- a/docs/src/quick_start_guide.rst +++ b/docs/src/quick_start_guide.rst @@ -128,6 +128,10 @@ For Multiple Modules # set file path fpath /tmp +.. note :: + The **hostname** and **detsize** command in a multi module system can affect the row and column values in the udp/zmq header. The modules are stacked row by row until they reach the y-axis limit set by detsize (if specified). Then, stacking continues in the next column and so on. + + Gui ---- diff --git a/docs/src/servers.rst b/docs/src/servers.rst index 4a0faebb9..06c4d8d82 100644 --- a/docs/src/servers.rst +++ b/docs/src/servers.rst @@ -39,13 +39,13 @@ Arguments .. _Automatic start servers: + Automatic start ------------------ One can start the on-board detector server automatically upon powering on the board. -#. Create a soft link to the binary on board - : +#. Create a soft link to the binary on board: .. code-block:: bash ln -sf someDetectorServervx.x.x someDetectorServer @@ -87,8 +87,7 @@ One can start the on-board detector server automatically upon powering on the bo /root/xxxDetectorServer >> /dev/null & -#. Sync, reboot and verify - : +#. Sync, reboot and verify: .. code-block:: bash sync diff --git a/docs/src/udpheader.rst b/docs/src/udpheader.rst index 56e59a387..f49ae1d02 100644 --- a/docs/src/udpheader.rst +++ b/docs/src/udpheader.rst @@ -73,9 +73,9 @@ Description * **modId**: module ID picked up from det_id_[detector type].txt on the detector cpu. -* **row**: row position of the module in the detector system. It is calculated by the order of the module in hostname command, as well as the detsize command. +* **row**: row position of the module in the detector system. It is calculated by the order of the module in hostname command, as well as the detsize command. The modules are stacked row by row until they reach the y-axis limit set by detsize (if specified). Then, stacking continues in the next column and so on. -* **column**: column position of the module in the detector system. It is calculated by the order of the module in hostname command, as well as the detsize command. +* **column**: column position of the module in the detector system. It is calculated by the order of the module in hostname command, as well as the detsize command. The modules are stacked row by row until they reach the y-axis limit set by detsize (if specified). Then, stacking continues in the next column and so on. * **detType**: detector type from enum of detectorType in the package. diff --git a/python/scripts/frameSynchronizerPullSocket.py b/python/scripts/frameSynchronizerPullSocket.py new file mode 100644 index 000000000..4c13815ab --- /dev/null +++ b/python/scripts/frameSynchronizerPullSocket.py @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: LGPL-3.0-or-other +# Copyright (C) 2021 Contributors to the SLS Detector Package +# Script to get combined zmq packets from frame synchronizer using pull zmq sockets +import json +import zmq + +c = zmq.Context() +s = c.socket(zmq.PULL) +s.connect("tcp://127.0.0.1:5555") + +while True: + m = s.recv_multipart() + for p in m: + if p.startswith(b"{"): + print(p.decode().strip()) + else: + print("binary") + print("--------") + diff --git a/python/scripts/generate_functions.py b/python/scripts/generate_functions.py index 872672437..ae6d13326 100644 --- a/python/scripts/generate_functions.py +++ b/python/scripts/generate_functions.py @@ -123,6 +123,9 @@ def visit(node): if node.kind == cindex.CursorKind.CLASS_DECL: if node.displayname == "Detector": for child in node.get_children(): + # Skip assignment operators + if child.kind == cindex.CursorKind.CXX_METHOD and child.spelling == "operator=": + continue if ( child.kind == cindex.CursorKind.CXX_METHOD and child.access_specifier == cindex.AccessSpecifier.PUBLIC diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 6b0b86f68..0de4199f5 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -151,6 +151,10 @@ class Detector(CppDetectorApi): def hostname(self): """Frees shared memory and sets hostname (or IP address) of all modules concatenated by + Virtual servers can already use the port in hostname separated by ':' and ports incremented by 2 to accomodate the stop server as well. + + Note + ----- + The row and column values in the udp/zmq header are affected by the order in this command and the detsize command. The modules are stacked row by row until they reach the y-axis limit set by detsize (if specified). Then, stacking continues in the next column and so on. This only affects row and column in udp/zmq header. Example ------- @@ -2566,7 +2570,7 @@ class Detector(CppDetectorApi): Note ----- - By default, the on-chip gain switching is active during the entire exposure. This mode disables the on-chip gain switching comparator automatically after 93.75% of exposure time (only for longer than 100us). The % is only for chipv1.0, the duration can be set for chipv1.1.\n + By default, the on-chip gain switching is active during the entire exposure. This mode disables the on-chip gain switching comparator automatically and the duration is set using compdisabletime.\n Default is 0 or this mode disabled (comparator enabled throughout). 1 enables mode. 0 disables mode. """ return self.getAutoComparatorDisable() @@ -2580,10 +2584,6 @@ class Detector(CppDetectorApi): def compdisabletime(self): """[Jungfrau] Time before end of exposure when comparator is disabled. - Note - ----- - It is only possible for chipv1.1. - :getter: always returns in seconds. To get in DurationWrapper, use getComparatorDisableTime Example @@ -2913,7 +2913,7 @@ class Detector(CppDetectorApi): @property @element def timing_info_decoder(self): - """[Jungfrau] [Jungfrau] Advanced Command and only for SWISSFEL and SHINE. Sets the bunch id or timing info decoder. Default is SWISSFEL. + """[Jungfrau] [Jungfrau] Advanced Command and only for SWISSFEL and SHINE. Sets the bunch id or timing info decoder. Default is SWISSFEL. Only allowed for pcbv2.0. Enum: timingInfoDecoder """ return self.getTimingInfoDecoder() diff --git a/serverBin/xilinx_ctbDetectorServer_developer b/serverBin/xilinx_ctbDetectorServer_developer new file mode 120000 index 000000000..f3a2ec25c --- /dev/null +++ b/serverBin/xilinx_ctbDetectorServer_developer @@ -0,0 +1 @@ +../slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer \ No newline at end of file diff --git a/slsDetectorCalibration/singlePhotonDetector.h b/slsDetectorCalibration/singlePhotonDetector.h index 5dc04b86c..f47638ce3 100644 --- a/slsDetectorCalibration/singlePhotonDetector.h +++ b/slsDetectorCalibration/singlePhotonDetector.h @@ -572,6 +572,7 @@ class singlePhotonDetector : public analogDetector { } #endif if (ee == PHOTON && val[iy * nx + ix] == max) { + good = 1; ee = PHOTON_MAX; // cout << "**" < { cout << max << " " << val[iy * nx + ix] << endl; } //else (clusters + nph)->print(); - good = 1; if (eMin > 0 && tot < eMin) good = 0; if (eMax > 0 && tot > eMax) diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index 6525af9d6..a085b20c3 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index ce706d0e5..9ddc04c89 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -1974,9 +1974,6 @@ int autoCompDisable(int on) { } int setComparatorDisableTime(int64_t val) { - if (getChipVersion() != 11) { - return FAIL; - } if (val < 0) { LOG(logERROR, ("Invalid comp disable time: %lld ns\n", (long long int)val)); @@ -2817,7 +2814,8 @@ void *start_timer(void *arg) { getNextFrameNumber(&frameNr); int iRxEntry = firstDest; for (int iframes = 0; iframes != numFrames; ++iframes) { - usleep(transmissionDelayUs); + if (transmissionDelayUs) + usleep(transmissionDelayUs); // check if manual stop if (sharedMemory_getStop() == 1) { diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index 7f7342e79..bebb87f8f 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -1927,7 +1927,8 @@ void *start_timer(void *arg) { getNextFrameNumber(&frameNr); int iRxEntry = firstDest; for (int iframes = 0; iframes != numFrames; ++iframes) { - usleep(transmissionDelayUs); + if (transmissionDelayUs) + usleep(transmissionDelayUs); // check if manual stop if (sharedMemory_getStop() == 1) { diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index 0661d3a32..ce3642633 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h index d9287e862..b0d8c1ea5 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h @@ -50,7 +50,7 @@ #define DEFAULT_NUM_CYCLES (1) #define DEFAULT_GATE_WIDTH (100 * 1000 * 1000) // ns #define DEFAULT_GATE_DELAY (0) -#define DEFAULT_PERIOD (2 * 1000 * 1000) // ns +#define DEFAULT_PERIOD (0) // ns #define DEFAULT_DELAY_AFTER_TRIGGER (0) #define DEFAULT_HIGH_VOLTAGE (0) #define DEFAULT_TIMING_MODE (AUTO_TIMING) diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index ee7182f16..cc4d43934 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -197,6 +197,8 @@ int isChipConfigured(); int powerChip(int on, char *mess); int getPowerChip(); int configureChip(char *mess); +int readConfigFile(char *mess, char *fileName, char *fileType); +int resetChip(char *mess); #endif #if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) || \ defined(MYTHEN3D) || defined(GOTTHARD2D) @@ -742,8 +744,7 @@ int softwareTrigger(); #if defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD) int softwareTrigger(int block); #endif -#if defined(EIGERD) || defined(MYTHEN3D) || defined(CHIPTESTBOARDD) || \ - defined(XILINX_CHIPTESTBOARDD) +#if defined(EIGERD) || defined(MYTHEN3D) || defined(CHIPTESTBOARDD) int startReadOut(); #endif enum runStatus getRunStatus(); diff --git a/slsDetectorServers/slsDetectorServer/src/loadPattern.c b/slsDetectorServers/slsDetectorServer/src/loadPattern.c index 6065d0076..90ef5b6d4 100644 --- a/slsDetectorServers/slsDetectorServer/src/loadPattern.c +++ b/slsDetectorServers/slsDetectorServer/src/loadPattern.c @@ -853,7 +853,7 @@ int loadPattern(char *message, enum TLogLevel printLevel, } } // iocontrol -#if !defined(MYTHEN3D) && !defined(XILINX_CHIPTESTBOARDD) // TODO +#if !defined(MYTHEN3D) if (ret == OK) { ret = validate_writePatternIOControl(message, pat->ioctrl); } @@ -914,7 +914,7 @@ int getPattern(char *message, patternParameters *pat) { pat->word[i] = retval64; } // iocontrol -#if !defined(MYTHEN3D) && !defined(XILINX_CHIPTESTBOARDD) // TODO +#if !defined(MYTHEN3D) if (ret == OK) { validate_readPatternIOControl(); } @@ -1051,12 +1051,12 @@ int loadPatternFile(char *patFname, char *errMessage) { } // patioctrl -#if !defined(MYTHEN3D) && !defined(XILINX_CHIPTESTBOARDD) // TODO +#if !defined(MYTHEN3D) // TODO if (!strncmp(line, "patioctrl", strlen("patioctrl"))) { uint64_t arg = 0; // cannot scan values -#ifdef VIRTUAL +#if defined(VIRTUAL) || defined(XILINX_CHIPTESTBOARDD) if (sscanf(line, "%s 0x%lx", command, &arg) != 2) { #else if (sscanf(line, "%s 0x%llx", command, &arg) != 2) { diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 9cf641b2d..94657697f 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -8467,8 +8467,7 @@ int get_bursts_left(int file_des) { int start_readout(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); -#if !defined(MYTHEN3D) && !defined(CHIPTESTBOARDD) && \ - !defined(XILINX_CHIPTESTBOARDD) +#if !defined(MYTHEN3D) && !defined(CHIPTESTBOARDD) functionNotImplemented(); #else if (Server_VerifyLock() == OK) { @@ -9098,16 +9097,9 @@ int get_comp_disable_time(int file_des) { functionNotImplemented(); #else // get only - if (getChipVersion() != 11) { - ret = FAIL; - strcpy(mess, - "Cannot get comparator disable time. Only valid for chipv1.1\n"); - LOG(logERROR, (mess)); - } else { - retval = getComparatorDisableTime(); - LOG(logDEBUG1, - ("retval comp disable time %lld ns\n", (long long int)retval)); - } + retval = getComparatorDisableTime(); + LOG(logDEBUG1, + ("retval comp disable time %lld ns\n", (long long int)retval)); #endif return Server_SendResult(file_des, INT64, &retval, sizeof(retval)); } @@ -9125,23 +9117,16 @@ int set_comp_disable_time(int file_des) { #else // only set if (Server_VerifyLock() == OK) { - if (getChipVersion() != 11) { - ret = FAIL; - strcpy(mess, "Cannot get comparator disable time. Only valid for " - "chipv1.1\n"); + ret = setComparatorDisableTime(arg); + int64_t retval = getComparatorDisableTime(); + LOG(logDEBUG1, + ("retval get comp disable time %lld ns\n", (long long int)retval)); + if (ret == FAIL) { + sprintf(mess, + "Could not set comp disable time. Set %lld ns, read " + "%lld ns.\n", + (long long int)arg, (long long int)retval); LOG(logERROR, (mess)); - } else { - ret = setComparatorDisableTime(arg); - int64_t retval = getComparatorDisableTime(); - LOG(logDEBUG1, ("retval get comp disable time %lld ns\n", - (long long int)retval)); - if (ret == FAIL) { - sprintf(mess, - "Could not set comp disable time. Set %lld ns, read " - "%lld ns.\n", - (long long int)arg, (long long int)retval); - LOG(logERROR, (mess)); - } } } #endif @@ -11144,6 +11129,12 @@ int set_timing_info_decoder(int file_des) { modeNotImplemented("Timing info decoder index", (int)arg); break; } + if (ret == OK && isHardwareVersion_1_0()) { + ret = FAIL; + sprintf(mess, "Could not set timing info decoder. Not supported " + "for hardware version 1.0\n"); + LOG(logERROR, (mess)); + } if (ret == OK) { ret = setTimingInfoDecoder(arg); if (ret == FAIL) { diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt b/slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt index 78a5fbfb7..db081528a 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt +++ b/slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt @@ -40,3 +40,9 @@ set_target_properties(xilinx_ctbDetectorServer_virtual PROPERTIES install(TARGETS xilinx_ctbDetectorServer_virtual RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) + +configure_file(chip_config_xilinx.txt ${CMAKE_BINARY_DIR}/bin/chip_config_xilinx.txt COPYONLY) +configure_file(reset_chip_xilinx.txt ${CMAKE_BINARY_DIR}/bin/reset_chip_xilinx.txt COPYONLY) +configure_file(enable_clock_pattern.pyat ${CMAKE_BINARY_DIR}/bin/enable_clock_pattern.pyat COPYONLY) +configure_file(readout_pattern.pyat ${CMAKE_BINARY_DIR}/bin/readout_pattern.pyat COPYONLY) + diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/Makefile b/slsDetectorServers/xilinx_ctbDetectorServer/Makefile index c271efdfe..59cf0fe37 100755 --- a/slsDetectorServers/xilinx_ctbDetectorServer/Makefile +++ b/slsDetectorServers/xilinx_ctbDetectorServer/Makefile @@ -48,6 +48,10 @@ $(PROGS): $(OBJS) mkdir -p $(DESTDIR) $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) mv $(PROGS) $(DESTDIR) + cp chip_config_xilinx.txt $(DESTDIR) + cp reset_chip_xilinx.txt $(DESTDIR) + cp enable_clock_pattern.pyat $(DESTDIR) + cp readout_pattern.pyat $(DESTDIR) rm $(main_src)*.o $(md5_dir)*.o clean: rm -rf $(DESTDIR)/$(PROGS) *.o *.gdb $(main_src)*.o $(md5_dir)*.o diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h b/slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h index 3563a8b82..bd3edb1d3 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h +++ b/slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h @@ -2,7 +2,7 @@ // Copyright (C) 2021 Contributors to the SLS Detector Package #pragma once -#define CTRL_REG (0x0) +#define CTRL_REG (0x8000) #define POWER_VIO_OFST (0) #define POWER_VIO_MSK (0x00000001 << POWER_VIO_OFST) @@ -15,624 +15,93 @@ #define POWER_VCC_D_OFST (4) #define POWER_VCC_D_MSK (0x00000001 << POWER_VCC_D_OFST) -#define EMPTY4REG (0x4) +#define STATUS_REG (0x8004) -#define STATUSREG1 (0x8) +#define PATTERN_RUNNING_OFST (0) +#define PATTERN_RUNNING_MSK (0x00000001 << PATTERN_RUNNING_OFST) +#define RX_BUSY_OFST (1) +#define RX_BUSY_MSK (0x00000001 << RX_BUSY_OFST) +#define PROCESSING_BUSY_OFST (2) +#define PROCESSING_BUSY_MSK (0x00000001 << PROCESSING_BUSY_OFST) +#define UDP_GEN_BUSY_OFST (3) +#define UDP_GEN_BUSY_MSK (0x00000001 << UDP_GEN_BUSY_OFST) +#define NETWORK_BUSY_OFST (4) +#define NETWORK_BUSY_MSK (0x00000001 << NETWORK_BUSY_OFST) +#define WAIT_FOR_TRIGGER_OFST (5) +#define WAIT_FOR_TRIGGER_MSK (0x00000001 << WAIT_FOR_TRIGGER_OFST) +#define RX_NOT_GOOD_OFST (6) +#define RX_NOT_GOOD_MSK (0x00000001 << RX_NOT_GOOD_OFST) -#define TRANSMISSIONBUSY_OFST (0) -#define TRANSMISSIONBUSY_MSK (0x00000001 << TRANSMISSIONBUSY_OFST) +#define STATUS_REG2 (0x8008) -#define STATUSREG2 (0xC) - -#define FPGAVERSIONREG (0x10) +#define FPGAVERSIONREG (0x800C) #define FPGACOMPDATE_OFST (0) #define FPGACOMPDATE_MSK (0x00ffffff << FPGACOMPDATE_OFST) #define FPGADETTYPE_OFST (24) #define FPGADETTYPE_MSK (0x000000ff << FPGADETTYPE_OFST) -#define EMPTY14REG (0x14) +#define FPGA_GIT_HEAD (0x8010) -#define FIXEDPATTERNREG (0x18) +#define FIXEDPATTERNREG (0x8014) #define FIXEDPATTERNVAL (0xACDC2016) -#define EMPTY1CREG (0x1C) - -#define APIVERSIONREG (0x20) +#define APIVERSIONREG (0x8018) #define APICOMPDATE_OFST (0) #define APICOMPDATE_MSK (0x00ffffff << APICOMPDATE_OFST) #define APIDETTYPE_OFST (24) #define APIDETTYPE_MSK (0x000000ff << APIDETTYPE_OFST) -#define EMPTY24REG (0x24) +#define A_FIFO_OVERFLOW_STATUS_REG (0x9000) -#define PKTPACKETLENGTHREG (0x28) +#define A_FIFO_EMPTY_STATUS_REG (0x9004) -#define PACKETLENGTH1G_OFST (0) -#define PACKETLENGTH1G_MSK (0x0000ffff << PACKETLENGTH1G_OFST) -#define PACKETLENGTH10G_OFST (16) -#define PACKETLENGTH10G_MSK (0x0000ffff << PACKETLENGTH10G_OFST) +#define A_FIFO_FULL_STATUS_REG (0x9008) -#define EMPTY2CREG (0x2C) +#define D_FIFO_OVERFLOW_STATUS_REG (0x900C) -#define PKTNOPACKETSREG (0x30) +#define D_FIFO_OVERFLOW_STATUS_OFST (0) +#define D_FIFO_OVERFLOW_STATUS_MSK (0x00000001 << D_FIFO_OVERFLOW_STATUS_OFST) -#define NOPACKETS1G_OFST (0) -#define NOPACKETS1G_MSK (0x0000003f << NOPACKETS1G_OFST) -#define NOPACKETS10G_OFST (16) -#define NOPACKETS10G_MSK (0x0000003f << NOPACKETS10G_OFST) +#define D_FIFO_EMPTY_STATUS_REG (0x9010) -#define EMPTY34REG (0x34) +#define D_FIFO_EMPTY_STATUS_OFST (0) +#define D_FIFO_EMPTY_STATUS_MSK (0x00000001 << D_FIFO_EMPTY_STATUS_OFST) -#define PKTCTRLREG (0x38) +#define D_FIFO_FULL_STATUS_REG (0x9014) -#define NOSERVERS_OFST (0) -#define NOSERVERS_MSK (0x0000003f << NOSERVERS_OFST) -#define SERVERSTART_OFST (8) -#define SERVERSTART_MSK (0x0000001f << SERVERSTART_OFST) -#define ETHINTERF_OFST (16) -#define ETHINTERF_MSK (0x00000001 << ETHINTERF_OFST) +#define D_FIFO_FULL_STATUS_OFST (0) +#define D_FIFO_FULL_STATUS_MSK (0x00000001 << D_FIFO_FULL_STATUS_OFST) -#define EMPTY3CREG (0x3C) +#define X_FIFO_OVERFLOW_STATUS_REG (0x9018) -#define PKTCOORDREG1 (0x40) +#define X_FIFO_OVERFLOW_STATUS_OFST (0) +#define X_FIFO_OVERFLOW_STATUS_MSK (0x0000000f << X_FIFO_OVERFLOW_STATUS_OFST) -#define COORDX_OFST (0) -#define COORDX_MSK (0x0000ffff << COORDX_OFST) -#define COORDY_OFST (16) -#define COORDY_MSK (0x0000ffff << COORDY_OFST) +#define X_FIFO_EMPTY_STATUS_REG (0x901C) -#define EMPTY44REG (0x44) +#define X_FIFO_EMPTY_STATUS_OFST (0) +#define X_FIFO_EMPTY_STATUS_MSK (0x0000000f << X_FIFO_EMPTY_STATUS_OFST) -#define PKTCOORDREG2 (0x48) +#define X_FIFO_FULL_STATUS_REG (0x9020) -#define COORDZ_OFST (0) -#define COORDZ_MSK (0x0000ffff << COORDZ_OFST) +#define X_FIFO_FULL_STATUS_OFST (0) +#define X_FIFO_FULL_STATUS_MSK (0x0000000f << X_FIFO_FULL_STATUS_OFST) -#define EMPTY4CREG (0x4C) +#define A_FIFO_CLEAN_REG (0x9024) -#define EMPTY50REG (0x50) +#define D_FIFO_CLEAN_REG (0x9028) -#define EMPTY54REG (0x54) +#define D_FIFO_CLEAN_OFST (0) +#define D_FIFO_CLEAN_MSK (0x00000001 << D_FIFO_CLEAN_OFST) -#define EMPTY58REG (0x58) +#define X_FIFO_CLEAN_REG (0x902C) -#define EMPTY5CREG (0x5C) +#define X_FIFO_CLEAN_OFST (0) +#define X_FIFO_CLEAN_MSK (0x0000000f << X_FIFO_CLEAN_OFST) -#define EMPTY60REG (0x60) - -#define EMPTY64REG (0x64) - -#define EMPTY68REG (0x68) - -#define EMPTY6CREG (0x6C) - -#define EMPTY70REG (0x70) - -#define EMPTY74REG (0x74) - -#define EMPTY78REG (0x78) - -#define EMPTY7CREG (0x7C) - -#define EMPTY80REG (0x80) - -#define EMPTY84REG (0x84) - -#define EMPTY88REG (0x88) - -#define EMPTY8CREG (0x8C) - -#define EMPTY90REG (0x90) - -#define EMPTY94REG (0x94) - -#define EMPTY98REG (0x98) - -#define EMPTY9CREG (0x9C) - -#define FLOW_STATUS_REG (0x100) - -#define RSM_BUSY_OFST (0) -#define RSM_BUSY_MSK (0x00000001 << RSM_BUSY_OFST) -#define RSM_TRG_WAIT_OFST (3) -#define RSM_TRG_WAIT_MSK (0x00000001 << RSM_TRG_WAIT_OFST) -#define CSM_BUSY_OFST (17) -#define CSM_BUSY_MSK (0x00000001 << CSM_BUSY_OFST) - -#define EMPTY104REG (0x104) - -#define FLOW_CONTROL_REG (0x108) - -#define START_F_OFST (0) -#define START_F_MSK (0x00000001 << START_F_OFST) -#define STOP_F_OFST (1) -#define STOP_F_MSK (0x00000001 << STOP_F_OFST) -#define RST_F_OFST (2) -#define RST_F_MSK (0x00000001 << RST_F_OFST) -#define SW_TRIGGER_F_OFST (3) -#define SW_TRIGGER_F_MSK (0x00000001 << SW_TRIGGER_F_OFST) -#define TRIGGER_ENABLE_OFST (4) -#define TRIGGER_ENABLE_MSK (0x00000001 << TRIGGER_ENABLE_OFST) - -#define EMPTY10CREG (0x10C) - -#define TIME_FROM_START_OUT_REG_1 (0x110) - -#define TIME_FROM_START_OUT_REG_2 (0x114) - -#define FRAMES_FROM_START_OUT_REG_1 (0x118) - -#define FRAMES_FROM_START_OUT_REG_2 (0x11C) - -#define FRAME_TIME_OUT_REG_1 (0x120) - -#define FRAME_TIME_OUT_REG_2 (0x124) - -#define DELAY_OUT_REG_1 (0x128) - -#define DELAY_OUT_REG_2 (0x12C) - -#define CYCLES_OUT_REG_1 (0x130) - -#define CYCLES_OUT_REG_2 (0x134) - -#define FRAMES_OUT_REG_1 (0x138) - -#define FRAMES_OUT_REG_2 (0x13C) - -#define PERIOD_OUT_REG_1 (0x140) - -#define PERIOD_OUT_REG_2 (0x144) - -#define DELAY_IN_REG_1 (0x148) - -#define DELAY_IN_REG_2 (0x14C) - -#define CYCLES_IN_REG_1 (0x150) - -#define CYCLES_IN_REG_2 (0x154) - -#define FRAMES_IN_REG_1 (0x158) - -#define FRAMES_IN_REG_2 (0x15C) - -#define PERIOD_IN_REG_1 (0x160) - -#define PERIOD_IN_REG_2 (0x164) - -#define EMPTY168REG (0x168) - -#define EMPTY16CREG (0x16C) - -#define EMPTY170REG (0x170) - -#define EMPTY174REG (0x174) - -#define EMPTY178REG (0x178) - -#define EMPTY17CREG (0x17C) - -#define EMPTY180REG (0x180) - -#define EMPTY184REG (0x184) - -#define EMPTY188REG (0x188) - -#define EMPTY18CREG (0x18C) - -#define EMPTY190REG (0x190) - -#define EMPTY194REG (0x194) - -#define EMPTY198REG (0x198) - -#define EMPTY19CREG (0x19C) - -#define PATTERN_OUT_LSB_REG (0x200) - -#define PATTERN_OUT_MSB_REG (0x204) - -#define PATTERN_IN_LSB_REG (0x208) - -#define PATTERN_IN_MSB_REG (0x20C) - -#define PATTERN_MASK_LSB_REG (0x210) - -#define PATTERN_MASK_MSB_REG (0x214) - -#define PATTERN_SET_LSB_REG (0x218) - -#define PATTERN_SET_MSB_REG (0x21C) - -#define PATTERN_CNTRL_REG (0x220) - -#define PATTERN_CNTRL_WR_OFST (0) -#define PATTERN_CNTRL_WR_MSK (0x00000001 << PATTERN_CNTRL_WR_OFST) -#define PATTERN_CNTRL_RD_OFST (1) -#define PATTERN_CNTRL_RD_MSK (0x00000001 << PATTERN_CNTRL_RD_OFST) -#define PATTERN_CNTRL_ADDR_OFST (16) -#define PATTERN_CNTRL_ADDR_MSK (0x00001fff << PATTERN_CNTRL_ADDR_OFST) - -#define EMPTY224REG (0x224) - -#define PATTERN_LIMIT_REG (0x228) - -#define PATTERN_LIMIT_STRT_OFST (0) -#define PATTERN_LIMIT_STRT_MSK (0x00001fff << PATTERN_LIMIT_STRT_OFST) -#define PATTERN_LIMIT_STP_OFST (16) -#define PATTERN_LIMIT_STP_MSK (0x00001fff << PATTERN_LIMIT_STP_OFST) - -#define EMPTY22CREG (0x22C) - -#define PATTERN_LOOP_0_ADDR_REG (0x230) - -#define PATTERN_LOOP_0_ADDR_STRT_OFST (0) -#define PATTERN_LOOP_0_ADDR_STRT_MSK \ - (0x00001fff << PATTERN_LOOP_0_ADDR_STRT_OFST) -#define PATTERN_LOOP_0_ADDR_STP_OFST (16) -#define PATTERN_LOOP_0_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_0_ADDR_STP_OFST) - -#define EMPTY234REG (0x234) - -#define PATTERN_LOOP_0_ITERATION_REG (0x238) - -#define EMPTY23CREG (0x23C) - -#define PATTERN_WAIT_0_ADDR_REG (0x240) - -#define PATTERN_WAIT_0_ADDR_OFST (0) -#define PATTERN_WAIT_0_ADDR_MSK (0x00001fff << PATTERN_WAIT_0_ADDR_OFST) - -#define EMPTY244REG (0x244) - -#define PATTERN_WAIT_TIMER_0_LSB_REG (0x248) - -#define PATTERN_WAIT_TIMER_0_MSB_REG (0x24C) - -#define PATTERN_LOOP_1_ADDR_REG (0x250) - -#define PATTERN_LOOP_1_ADDR_STRT_OFST (0) -#define PATTERN_LOOP_1_ADDR_STRT_MSK \ - (0x00001fff << PATTERN_LOOP_1_ADDR_STRT_OFST) -#define PATTERN_LOOP_1_ADDR_STP_OFST (16) -#define PATTERN_LOOP_1_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_1_ADDR_STP_OFST) - -#define EMPTY254REG (0x254) - -#define PATTERN_LOOP_1_ITERATION_REG (0x258) - -#define EMPTY25CREG (0x25C) - -#define PATTERN_WAIT_1_ADDR_REG (0x260) - -#define PATTERN_WAIT_1_ADDR_OFST (0) -#define PATTERN_WAIT_1_ADDR_MSK (0x00001fff << PATTERN_WAIT_1_ADDR_OFST) - -#define EMPTY264REG (0x264) - -#define PATTERN_WAIT_TIMER_1_LSB_REG (0x268) - -#define PATTERN_WAIT_TIMER_1_MSB_REG (0x26C) - -#define PATTERN_LOOP_2_ADDR_REG (0x270) - -#define PATTERN_LOOP_2_ADDR_STRT_OFST (0) -#define PATTERN_LOOP_2_ADDR_STRT_MSK \ - (0x00001fff << PATTERN_LOOP_2_ADDR_STRT_OFST) -#define PATTERN_LOOP_2_ADDR_STP_OFST (16) -#define PATTERN_LOOP_2_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_2_ADDR_STP_OFST) - -#define EMPTY274REG (0x274) - -#define PATTERN_LOOP_2_ITERATION_REG (0x278) - -#define EMPTY27CREG (0x27C) - -#define PATTERN_WAIT_2_ADDR_REG (0x280) - -#define PATTERN_WAIT_2_ADDR_OFST (0) -#define PATTERN_WAIT_2_ADDR_MSK (0x00001fff << PATTERN_WAIT_2_ADDR_OFST) - -#define EMPTY284REG (0x284) - -#define PATTERN_WAIT_TIMER_2_LSB_REG (0x288) - -#define PATTERN_WAIT_TIMER_2_MSB_REG (0x28C) - -#define PATTERN_LOOP_3_ADDR_REG (0x290) - -#define PATTERN_LOOP_3_ADDR_STRT_OFST (0) -#define PATTERN_LOOP_3_ADDR_STRT_MSK \ - (0x00001fff << PATTERN_LOOP_3_ADDR_STRT_OFST) -#define PATTERN_LOOP_3_ADDR_STP_OFST (16) -#define PATTERN_LOOP_3_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_3_ADDR_STP_OFST) - -#define EMPTY294REG (0x294) - -#define PATTERN_LOOP_3_ITERATION_REG (0x298) - -#define EMPTY29CREG (0x29C) - -#define PATTERN_WAIT_3_ADDR_REG (0x300) - -#define PATTERN_WAIT_3_ADDR_OFST (0) -#define PATTERN_WAIT_3_ADDR_MSK (0x00001fff << PATTERN_WAIT_3_ADDR_OFST) - -#define EMPTY304REG (0x304) - -#define PATTERN_WAIT_TIMER_3_LSB_REG (0x308) - -#define PATTERN_WAIT_TIMER_3_MSB_REG (0x30C) - -#define PATTERN_LOOP_4_ADDR_REG (0x310) - -#define PATTERN_LOOP_4_ADDR_STRT_OFST (0) -#define PATTERN_LOOP_4_ADDR_STRT_MSK \ - (0x00001fff << PATTERN_LOOP_4_ADDR_STRT_OFST) -#define PATTERN_LOOP_4_ADDR_STP_OFST (16) -#define PATTERN_LOOP_4_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_4_ADDR_STP_OFST) - -#define EMPTY314REG (0x314) - -#define PATTERN_LOOP_4_ITERATION_REG (0x318) - -#define EMPTY31CREG (0x31C) - -#define PATTERN_WAIT_4_ADDR_REG (0x320) - -#define PATTERN_WAIT_4_ADDR_OFST (0) -#define PATTERN_WAIT_4_ADDR_MSK (0x00001fff << PATTERN_WAIT_4_ADDR_OFST) - -#define EMPTY324REG (0x324) - -#define PATTERN_WAIT_TIMER_4_LSB_REG (0x328) - -#define PATTERN_WAIT_TIMER_4_MSB_REG (0x32C) - -#define PATTERN_LOOP_5_ADDR_REG (0x330) - -#define PATTERN_LOOP_5_ADDR_STRT_OFST (0) -#define PATTERN_LOOP_5_ADDR_STRT_MSK \ - (0x00001fff << PATTERN_LOOP_5_ADDR_STRT_OFST) -#define PATTERN_LOOP_5_ADDR_STP_OFST (16) -#define PATTERN_LOOP_5_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_5_ADDR_STP_OFST) - -#define EMPTY334REG (0x334) - -#define PATTERN_LOOP_5_ITERATION_REG (0x338) - -#define EMPTY33CREG (0x33C) - -#define PATTERN_WAIT_5_ADDR_REG (0x340) - -#define PATTERN_WAIT_5_ADDR_OFST (0) -#define PATTERN_WAIT_5_ADDR_MSK (0x00001fff << PATTERN_WAIT_5_ADDR_OFST) - -#define EMPTY344REG (0x344) - -#define PATTERN_WAIT_TIMER_5_LSB_REG (0x348) - -#define PATTERN_WAIT_TIMER_5_MSB_REG (0x34C) - -#define PINIOCTRLREG (0x350) - -#define EMPTY354REG (0x354) - -#define EMPTY358REG (0x358) - -#define EMPTY35CREG (0x35C) - -#define EMPTY360REG (0x360) - -#define EMPTY364REG (0x364) - -#define EMPTY368REG (0x368) - -#define EMPTY36CREG (0x36C) - -#define EMPTY370REG (0x370) - -#define EMPTY374REG (0x374) - -#define EMPTY378REG (0x378) - -#define EMPTY37CREG (0x37C) - -#define EMPTY380REG (0x380) - -#define EMPTY384REG (0x384) - -#define EMPTY388REG (0x388) - -#define EMPTY38CREG (0x38C) - -#define EMPTY390REG (0x390) - -#define EMPTY394REG (0x394) - -#define EMPTY398REG (0x398) - -#define EMPTY39CREG (0x39C) - -#define EMPTY3A0REG (0x3A0) - -#define EMPTY3A4REG (0x3A4) - -#define EMPTY3A8REG (0x3A8) - -#define EMPTY3ACREG (0x3AC) - -#define EMPTY3B0REG (0x3B0) - -#define EMPTY3B4REG (0x3B4) - -#define EMPTY3B8REG (0x3B8) - -#define EMPTY3BCREG (0x3BC) - -#define EMPTY3C0REG (0x3C0) - -#define EMPTY3C4REG (0x3C4) - -#define EMPTY3C8REG (0x3C8) - -#define EMPTY3CCREG (0x3CC) - -#define EMPTY3D0REG (0x3D0) - -#define EMPTY3D4REG (0x3D4) - -#define EMPTY3D8REG (0x3D8) - -#define EMPTY3DCREG (0x3DC) - -#define EMPTY3E0REG (0x3E0) - -#define EMPTY3E4REG (0x3E4) - -#define EMPTY3E8REG (0x3E8) - -#define EMPTY3ECREG (0x3EC) - -#define EMPTY3F0REG (0x3F0) - -#define EMPTY3F4REG (0x3F4) - -#define EMPTY3F8REG (0x3F8) - -#define EMPTY3FCREG (0x3FC) - -#define EMPTY400REG (0x400) - -#define EMPTY404REG (0x404) - -#define EMPTY408REG (0x408) - -#define EMPTY40CREG (0x40C) - -#define EMPTY410REG (0x410) - -#define EMPTY414REG (0x414) - -#define EMPTY418REG (0x418) - -#define EMPTY41CREG (0x41C) - -#define EMPTY420REG (0x420) - -#define EMPTY424REG (0x424) - -#define EMPTY428REG (0x428) - -#define EMPTY42CREG (0x42C) - -#define EMPTY430REG (0x430) - -#define EMPTY434REG (0x434) - -#define EMPTY438REG (0x438) - -#define EMPTY43CREG (0x43C) - -#define EMPTY440REG (0x440) - -#define EMPTY444REG (0x444) - -#define EMPTY448REG (0x448) - -#define EMPTY44CREG (0x44C) - -#define EMPTY450REG (0x450) - -#define EMPTY454REG (0x454) - -#define EMPTY458REG (0x458) - -#define EMPTY45CREG (0x45C) - -#define EMPTY460REG (0x460) - -#define EMPTY464REG (0x464) - -#define EMPTY468REG (0x468) - -#define EMPTY46CREG (0x46C) - -#define EMPTY470REG (0x470) - -#define EMPTY474REG (0x474) - -#define EMPTY478REG (0x478) - -#define EMPTY47CREG (0x47C) - -#define EMPTY480REG (0x480) - -#define EMPTY484REG (0x484) - -#define EMPTY488REG (0x488) - -#define EMPTY48CREG (0x48C) - -#define EMPTY490REG (0x490) - -#define EMPTY494REG (0x494) - -#define EMPTY498REG (0x498) - -#define EMPTY49CREG (0x49C) - -#define EMPTY4A0REG (0x4A0) - -#define EMPTY4A4REG (0x4A4) - -#define EMPTY4A8REG (0x4A8) - -#define EMPTY4ACREG (0x4AC) - -#define EMPTY4B0REG (0x4B0) - -#define EMPTY4B4REG (0x4B4) - -#define EMPTY4B8REG (0x4B8) - -#define EMPTY4BCREG (0x4BC) - -#define EMPTY4C0REG (0x4C0) - -#define EMPTY4C4REG (0x4C4) - -#define EMPTY4C8REG (0x4C8) - -#define EMPTY4CCREG (0x4CC) - -#define EMPTY4D0REG (0x4D0) - -#define EMPTY4D4REG (0x4D4) - -#define EMPTY4D8REG (0x4D8) - -#define EMPTY4DCREG (0x4DC) - -#define EMPTY4E0REG (0x4E0) - -#define EMPTY4E4REG (0x4E4) - -#define EMPTY4E8REG (0x4E8) - -#define EMPTY4ECREG (0x4EC) - -#define EMPTY4F0REG (0x4F0) - -#define EMPTY4F4REG (0x4F4) - -#define EMPTY4F8REG (0x4F8) - -#define EMPTY4FCREG (0x4FC) - -#define FIFO_TO_GB_CONTROL_REG (0x500) +#define FIFO_TO_GB_CONTROL_REG (0xA000) #define ENABLED_CHANNELS_ADC_OFST (0) #define ENABLED_CHANNELS_ADC_MSK (0x000000ff << ENABLED_CHANNELS_ADC_OFST) @@ -649,173 +118,307 @@ #define COUNT_FRAMES_FROM_UPDATE_OFST (16) #define COUNT_FRAMES_FROM_UPDATE_MSK \ (0x00000001 << COUNT_FRAMES_FROM_UPDATE_OFST) -#define START_STREAMING_P_OFST (17) -#define START_STREAMING_P_MSK (0x00000001 << START_STREAMING_P_OFST) +#define START_STREAMING_P_OFST (17) +#define START_STREAMING_P_MSK (0x00000001 << START_STREAMING_P_OFST) +#define STREAM_BUFFER_CLEAR_OFST (18) +#define STREAM_BUFFER_CLEAR_MSK (0x00000001 << STREAM_BUFFER_CLEAR_OFST) -#define EMPTY504REG (0x504) - -#define NO_SAMPLES_D_REG (0x508) +#define NO_SAMPLES_D_REG (0xA004) #define NO_SAMPLES_D_OFST (0) #define NO_SAMPLES_D_MSK (0x00003fff << NO_SAMPLES_D_OFST) -#define EMPTY50CREG (0x50C) - -#define NO_SAMPLES_A_REG (0x510) +#define NO_SAMPLES_A_REG (0xA008) #define NO_SAMPLES_A_OFST (0) #define NO_SAMPLES_A_MSK (0x00003fff << NO_SAMPLES_A_OFST) -#define EMPTY514REG (0x514) - -#define NO_SAMPLES_X_REG (0x518) +#define NO_SAMPLES_X_REG (0xA00C) #define NO_SAMPLES_X_OFST (0) #define NO_SAMPLES_X_MSK (0x00001fff << NO_SAMPLES_X_OFST) -#define EMPTY51CREG (0x51C) +#define COUNT_FRAMES_FROM_REG_1 (0xA010) -#define COUNT_FRAMES_FROM_REG_1 (0x520) +#define COUNT_FRAMES_FROM_REG_2 (0xA014) -#define COUNT_FRAMES_FROM_REG_2 (0x524) +#define LOCAL_FRAME_NUMBER_REG_1 (0xA018) -#define LOCAL_FRAME_NUMBER_REG_1 (0x528) +#define LOCAL_FRAME_NUMBER_REG_2 (0xA01C) -#define LOCAL_FRAME_NUMBER_REG_2 (0x52C) +#define PKTPACKETLENGTHREG (0xA020) -#define EMPTY530REG (0x530) +#define PACKETLENGTH1G_OFST (0) +#define PACKETLENGTH1G_MSK (0x0000ffff << PACKETLENGTH1G_OFST) +#define PACKETLENGTH10G_OFST (16) +#define PACKETLENGTH10G_MSK (0x0000ffff << PACKETLENGTH10G_OFST) -#define EMPTY534REG (0x534) +#define PKTNOPACKETSREG (0xA024) -#define EMPTY538REG (0x538) +#define NOPACKETS1G_OFST (0) +#define NOPACKETS1G_MSK (0x0000003f << NOPACKETS1G_OFST) +#define NOPACKETS10G_OFST (16) +#define NOPACKETS10G_MSK (0x0000003f << NOPACKETS10G_OFST) -#define EMPTY53CREG (0x53C) +#define PKTCTRLREG (0xA028) -#define EMPTY540REG (0x540) +#define NOSERVERS_OFST (0) +#define NOSERVERS_MSK (0x0000003f << NOSERVERS_OFST) +#define SERVERSTART_OFST (8) +#define SERVERSTART_MSK (0x0000001f << SERVERSTART_OFST) +#define ETHINTERF_OFST (16) +#define ETHINTERF_MSK (0x00000001 << ETHINTERF_OFST) -#define EMPTY544REG (0x544) +#define PKTCOORDREG1 (0xA02C) -#define EMPTY548REG (0x548) +#define COORDX_OFST (0) +#define COORDX_MSK (0x0000ffff << COORDX_OFST) +#define COORDY_OFST (16) +#define COORDY_MSK (0x0000ffff << COORDY_OFST) -#define EMPTY54CREG (0x54C) +#define PKTCOORDREG2 (0xA030) -#define EMPTY550REG (0x550) +#define COORDZ_OFST (0) +#define COORDZ_MSK (0x0000ffff << COORDZ_OFST) -#define EMPTY554REG (0x554) +#define FLOW_STATUS_REG (0xB000) -#define EMPTY558REG (0x558) +#define RSM_BUSY_OFST (0) +#define RSM_BUSY_MSK (0x00000001 << RSM_BUSY_OFST) +#define RSM_TRG_WAIT_OFST (3) +#define RSM_TRG_WAIT_MSK (0x00000001 << RSM_TRG_WAIT_OFST) +#define CSM_BUSY_OFST (17) +#define CSM_BUSY_MSK (0x00000001 << CSM_BUSY_OFST) -#define EMPTY55CREG (0x55C) +#define FLOW_CONTROL_REG (0xB004) -#define EMPTY560REG (0x560) +#define START_F_OFST (0) +#define START_F_MSK (0x00000001 << START_F_OFST) +#define STOP_F_OFST (1) +#define STOP_F_MSK (0x00000001 << STOP_F_OFST) +#define RST_F_OFST (2) +#define RST_F_MSK (0x00000001 << RST_F_OFST) +#define SW_TRIGGER_F_OFST (3) +#define SW_TRIGGER_F_MSK (0x00000001 << SW_TRIGGER_F_OFST) +#define TRIGGER_ENABLE_OFST (4) +#define TRIGGER_ENABLE_MSK (0x00000001 << TRIGGER_ENABLE_OFST) -#define EMPTY564REG (0x564) +#define TIME_FROM_START_OUT_REG_1 (0xB008) -#define EMPTY568REG (0x568) +#define TIME_FROM_START_OUT_REG_2 (0xB00C) -#define EMPTY56CREG (0x56C) +#define FRAMES_FROM_START_OUT_REG_1 (0xB010) -#define EMPTY570REG (0x570) +#define FRAMES_FROM_START_OUT_REG_2 (0xB014) -#define EMPTY574REG (0x574) +#define FRAME_TIME_OUT_REG_1 (0xB018) -#define EMPTY578REG (0x578) +#define FRAME_TIME_OUT_REG_2 (0xB01C) -#define EMPTY57CREG (0x57C) +#define DELAY_OUT_REG_1 (0xB020) -#define A_FIFO_OVERFLOW_STATUS_REG (0x580) +#define DELAY_OUT_REG_2 (0xB024) -#define EMPTY584REG (0x584) +#define CYCLES_OUT_REG_1 (0xB028) -#define A_FIFO_EMPTY_STATUS_REG (0x588) +#define CYCLES_OUT_REG_2 (0xB02C) -#define EMPTY58CREG (0x58C) +#define FRAMES_OUT_REG_1 (0xB030) -#define A_FIFO_FULL_STATUS_REG (0x590) +#define FRAMES_OUT_REG_2 (0xB034) -#define EMPTY594REG (0x594) +#define PERIOD_OUT_REG_1 (0xB038) -#define D_FIFO_OVERFLOW_STATUS_REG (0x598) +#define PERIOD_OUT_REG_2 (0xB03C) -#define D_FIFO_OVERFLOW_STATUS_OFST (0) -#define D_FIFO_OVERFLOW_STATUS_MSK (0x00000001 << D_FIFO_OVERFLOW_STATUS_OFST) +#define DELAY_IN_REG_1 (0xB040) -#define EMPTY59CREG (0x59C) +#define DELAY_IN_REG_2 (0xB044) -#define D_FIFO_EMPTY_STATUS_REG (0x5A0) +#define CYCLES_IN_REG_1 (0xB048) -#define D_FIFO_EMPTY_STATUS_OFST (0) -#define D_FIFO_EMPTY_STATUS_MSK (0x00000001 << D_FIFO_EMPTY_STATUS_OFST) +#define CYCLES_IN_REG_2 (0xB04C) -#define EMPTY5A4REG (0x5A4) +#define FRAMES_IN_REG_1 (0xB050) -#define D_FIFO_FULL_STATUS_REG (0x5A8) +#define FRAMES_IN_REG_2 (0xB054) -#define D_FIFO_FULL_STATUS_OFST (0) -#define D_FIFO_FULL_STATUS_MSK (0x00000001 << D_FIFO_FULL_STATUS_OFST) +#define PERIOD_IN_REG_1 (0xB058) -#define EMPTY5ACREG (0x5AC) +#define PERIOD_IN_REG_2 (0xB05C) -#define X_FIFO_OVERFLOW_STATUS_REG (0x5B0) +#define PATTERN_OUT_LSB_REG (0xB100) -#define X_FIFO_OVERFLOW_STATUS_OFST (0) -#define X_FIFO_OVERFLOW_STATUS_MSK (0x0000000f << X_FIFO_OVERFLOW_STATUS_OFST) +#define PATTERN_OUT_MSB_REG (0xB104) -#define EMPTY5B4REG (0x5B4) +#define PATTERN_IN_LSB_REG (0xB108) -#define X_FIFO_EMPTY_STATUS_REG (0x5B8) +#define PATTERN_IN_MSB_REG (0xB10C) -#define X_FIFO_EMPTY_STATUS_OFST (0) -#define X_FIFO_EMPTY_STATUS_MSK (0x0000000f << X_FIFO_EMPTY_STATUS_OFST) +#define PATTERN_MASK_LSB_REG (0xB110) -#define EMPTY5BCREG (0x5BC) +#define PATTERN_MASK_MSB_REG (0xB114) -#define X_FIFO_FULL_STATUS_REG (0x5C0) +#define PATTERN_SET_LSB_REG (0xB118) -#define X_FIFO_FULL_STATUS_OFST (0) -#define X_FIFO_FULL_STATUS_MSK (0x0000000f << X_FIFO_FULL_STATUS_OFST) +#define PATTERN_SET_MSB_REG (0xB11C) -#define EMPTY5C4REG (0x5C4) +#define PATTERN_CNTRL_REG (0xB120) -#define A_FIFO_CLEAN_REG (0x5C8) +#define PATTERN_CNTRL_WR_OFST (0) +#define PATTERN_CNTRL_WR_MSK (0x00000001 << PATTERN_CNTRL_WR_OFST) +#define PATTERN_CNTRL_RD_OFST (1) +#define PATTERN_CNTRL_RD_MSK (0x00000001 << PATTERN_CNTRL_RD_OFST) +#define PATTERN_CNTRL_ADDR_OFST (16) +#define PATTERN_CNTRL_ADDR_MSK (0x00001fff << PATTERN_CNTRL_ADDR_OFST) -#define EMPTY5CCREG (0x5CC) +#define PATTERN_LIMIT_REG (0xB124) -#define D_FIFO_CLEAN_REG (0x5D0) +#define PATTERN_LIMIT_STRT_OFST (0) +#define PATTERN_LIMIT_STRT_MSK (0x00001fff << PATTERN_LIMIT_STRT_OFST) +#define PATTERN_LIMIT_STP_OFST (16) +#define PATTERN_LIMIT_STP_MSK (0x00001fff << PATTERN_LIMIT_STP_OFST) -#define D_FIFO_CLEAN_OFST (0) -#define D_FIFO_CLEAN_MSK (0x00000001 << D_FIFO_CLEAN_OFST) +#define PATTERN_LOOP_0_ADDR_REG (0xB128) -#define EMPTY5D4REG (0x5D4) +#define PATTERN_LOOP_0_ADDR_STRT_OFST (0) +#define PATTERN_LOOP_0_ADDR_STRT_MSK \ + (0x00001fff << PATTERN_LOOP_0_ADDR_STRT_OFST) +#define PATTERN_LOOP_0_ADDR_STP_OFST (16) +#define PATTERN_LOOP_0_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_0_ADDR_STP_OFST) -#define X_FIFO_CLEAN_REG (0x5D8) +#define PATTERN_LOOP_0_ITERATION_REG (0xB12C) -#define X_FIFO_CLEAN_OFST (0) -#define X_FIFO_CLEAN_MSK (0x0000000f << X_FIFO_CLEAN_OFST) +#define PATTERN_WAIT_0_ADDR_REG (0xB130) -#define EMPTY5DCREG (0x5DC) +#define PATTERN_WAIT_0_ADDR_OFST (0) +#define PATTERN_WAIT_0_ADDR_MSK (0x00001fff << PATTERN_WAIT_0_ADDR_OFST) -#define EMPTY5E0REG (0x5E0) +#define PATTERN_WAIT_TIMER_0_LSB_REG (0xB134) -#define EMPTY5E4REG (0x5E4) +#define PATTERN_WAIT_TIMER_0_MSB_REG (0xB138) -#define EMPTY5E8REG (0x5E8) +#define PATTERN_LOOP_1_ADDR_REG (0xB13C) -#define EMPTY5ECREG (0x5EC) +#define PATTERN_LOOP_1_ADDR_STRT_OFST (0) +#define PATTERN_LOOP_1_ADDR_STRT_MSK \ + (0x00001fff << PATTERN_LOOP_1_ADDR_STRT_OFST) +#define PATTERN_LOOP_1_ADDR_STP_OFST (16) +#define PATTERN_LOOP_1_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_1_ADDR_STP_OFST) -#define EMPTY5F0REG (0x5F0) +#define PATTERN_LOOP_1_ITERATION_REG (0xB140) -#define EMPTY5F4REG (0x5F4) +#define PATTERN_WAIT_1_ADDR_REG (0xB144) -#define EMPTY5F8REG (0x5F8) +#define PATTERN_WAIT_1_ADDR_OFST (0) +#define PATTERN_WAIT_1_ADDR_MSK (0x00001fff << PATTERN_WAIT_1_ADDR_OFST) -#define EMPTY5FCREG (0x5FC) +#define PATTERN_WAIT_TIMER_1_LSB_REG (0xB148) -#define MATTERHORNSPIREG1 (0x600) +#define PATTERN_WAIT_TIMER_1_MSB_REG (0xB14C) -#define MATTERHORNSPIREG2 (0x604) +#define PATTERN_LOOP_2_ADDR_REG (0xB150) -#define MATTERHORNSPICTRL (0x608) +#define PATTERN_LOOP_2_ADDR_STRT_OFST (0) +#define PATTERN_LOOP_2_ADDR_STRT_MSK \ + (0x00001fff << PATTERN_LOOP_2_ADDR_STRT_OFST) +#define PATTERN_LOOP_2_ADDR_STP_OFST (16) +#define PATTERN_LOOP_2_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_2_ADDR_STP_OFST) + +#define PATTERN_LOOP_2_ITERATION_REG (0xB154) + +#define PATTERN_WAIT_2_ADDR_REG (0xB158) + +#define PATTERN_WAIT_2_ADDR_OFST (0) +#define PATTERN_WAIT_2_ADDR_MSK (0x00001fff << PATTERN_WAIT_2_ADDR_OFST) + +#define PATTERN_WAIT_TIMER_2_LSB_REG (0xB15C) + +#define PATTERN_WAIT_TIMER_2_MSB_REG (0xB160) + +#define PATTERN_LOOP_3_ADDR_REG (0xB164) + +#define PATTERN_LOOP_3_ADDR_STRT_OFST (0) +#define PATTERN_LOOP_3_ADDR_STRT_MSK \ + (0x00001fff << PATTERN_LOOP_3_ADDR_STRT_OFST) +#define PATTERN_LOOP_3_ADDR_STP_OFST (16) +#define PATTERN_LOOP_3_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_3_ADDR_STP_OFST) + +#define PATTERN_LOOP_3_ITERATION_REG (0xB168) + +#define PATTERN_WAIT_3_ADDR_REG (0xB16C) + +#define PATTERN_WAIT_3_ADDR_OFST (0) +#define PATTERN_WAIT_3_ADDR_MSK (0x00001fff << PATTERN_WAIT_3_ADDR_OFST) + +#define PATTERN_WAIT_TIMER_3_LSB_REG (0xB170) + +#define PATTERN_WAIT_TIMER_3_MSB_REG (0xB174) + +#define PATTERN_LOOP_4_ADDR_REG (0xB178) + +#define PATTERN_LOOP_4_ADDR_STRT_OFST (0) +#define PATTERN_LOOP_4_ADDR_STRT_MSK \ + (0x00001fff << PATTERN_LOOP_4_ADDR_STRT_OFST) +#define PATTERN_LOOP_4_ADDR_STP_OFST (16) +#define PATTERN_LOOP_4_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_4_ADDR_STP_OFST) + +#define PATTERN_LOOP_4_ITERATION_REG (0xB17C) + +#define PATTERN_WAIT_4_ADDR_REG (0xB180) + +#define PATTERN_WAIT_4_ADDR_OFST (0) +#define PATTERN_WAIT_4_ADDR_MSK (0x00001fff << PATTERN_WAIT_4_ADDR_OFST) + +#define PATTERN_WAIT_TIMER_4_LSB_REG (0xB184) + +#define PATTERN_WAIT_TIMER_4_MSB_REG (0xB188) + +#define PATTERN_LOOP_5_ADDR_REG (0xB18C) + +#define PATTERN_LOOP_5_ADDR_STRT_OFST (0) +#define PATTERN_LOOP_5_ADDR_STRT_MSK \ + (0x00001fff << PATTERN_LOOP_5_ADDR_STRT_OFST) +#define PATTERN_LOOP_5_ADDR_STP_OFST (16) +#define PATTERN_LOOP_5_ADDR_STP_MSK (0x00001fff << PATTERN_LOOP_5_ADDR_STP_OFST) + +#define PATTERN_LOOP_5_ITERATION_REG (0xB190) + +#define PATTERN_WAIT_5_ADDR_REG (0xB194) + +#define PATTERN_WAIT_5_ADDR_OFST (0) +#define PATTERN_WAIT_5_ADDR_MSK (0x00001fff << PATTERN_WAIT_5_ADDR_OFST) + +#define PATTERN_WAIT_TIMER_5_LSB_REG (0xB198) + +#define PATTERN_WAIT_TIMER_5_MSB_REG (0xB19C) + +#define PINIOCTRLREG (0xB1A0) + +#define DBITFIFOCTRLREG (0xB1A4) + +#define DBITRD_OFST (0) +#define DBITRD_MSK (0x00000001 << DBITRD_OFST) +#define DBITRST_OFST (1) +#define DBITRST_MSK (0x00000001 << DBITRST_OFST) +#define DBITFULL_OFST (2) +#define DBITFULL_MSK (0x00000001 << DBITFULL_OFST) +#define DBITEMPTY_OFST (3) +#define DBITEMPTY_MSK (0x00000001 << DBITEMPTY_OFST) +#define DBITUNDERFLOW_OFST (4) +#define DBITUNDERFLOW_MSK (0x00000001 << DBITUNDERFLOW_OFST) +#define DBITOVERFLOW_OFST (5) +#define DBITOVERFLOW_MSK (0x00000001 << DBITOVERFLOW_OFST) + +#define DBITFIFODATAREG1 (0xB1A8) + +#define DBITFIFODATAREG2 (0xB1AC) + +#define MATTERHORNSPIREG1 (0xB1B0) + +#define MATTERHORNSPIREG2 (0xB1B4) + +#define MATTERHORNSPICTRL (0xB1B8) #define CONFIGSTART_P_OFST (0) #define CONFIGSTART_P_MSK (0x00000001 << CONFIGSTART_P_OFST) @@ -828,41 +431,19 @@ #define READOUTFROMASIC_OFST (4) #define READOUTFROMASIC_MSK (0x00000001 << READOUTFROMASIC_OFST) -#define EMPTY60CREG (0x60C) +#define TRANSCEIVERRXCTRL0REG1 (0xB800) -#define EMPTY610REG (0x610) +#define TRANSCEIVERRXCTRL0REG2 (0xB804) -#define EMPTY614REG (0x614) +#define TRANSCEIVERRXCTRL1REG1 (0xB808) -#define EMPTY618REG (0x618) +#define TRANSCEIVERRXCTRL1REG2 (0xB80C) -#define EMPTY61CREG (0x61C) +#define TRANSCEIVERRXCTRL2REG (0xB810) -#define EMPTY620REG (0x620) +#define TRANSCEIVERRXCTRL3REG (0xB814) -#define EMPTY624REG (0x624) - -#define EMPTY628REG (0x628) - -#define EMPTY62CREG (0x62C) - -#define TRANSCEIVERRXCTRL0REG1 (0x630) - -#define TRANSCEIVERRXCTRL0REG2 (0x634) - -#define TRANSCEIVERRXCTRL1REG1 (0x638) - -#define TRANSCEIVERRXCTRL1REG2 (0x63C) - -#define TRANSCEIVERRXCTRL2REG (0x640) - -#define EMPTY644REG (0x644) - -#define TRANSCEIVERRXCTRL3REG (0x648) - -#define EMPTY64CREG (0x64C) - -#define TRANSCEIVERSTATUS (0x650) +#define TRANSCEIVERSTATUS (0xB818) #define LINKDOWNLATCHEDOUT_OFST (0) #define LINKDOWNLATCHEDOUT_MSK (0x00000001 << LINKDOWNLATCHEDOUT_OFST) @@ -889,9 +470,12 @@ #define GTTPOWERGOOD_OFST (26) #define GTTPOWERGOOD_MSK (0x0000000f << GTTPOWERGOOD_OFST) -#define EMPTY654REG (0x654) +#define TRANSCEIVERSTATUS2 (0xB81C) -#define TRANSCEIVERCONTROL (0x658) +#define RXLOCKED_OFST (0) +#define RXLOCKED_MSK (0x0000000f << RXLOCKED_OFST) + +#define TRANSCEIVERCONTROL (0xB820) #define GTWIZRESETALL_OFST (0) #define GTWIZRESETALL_MSK (0x00000001 << GTWIZRESETALL_OFST) @@ -905,116 +489,55 @@ #define RESETRXDATAPATHIN_MSK (0x00000001 << RESETRXDATAPATHIN_OFST) #define RXPOLARITY_OFST (5) #define RXPOLARITY_MSK (0x0000000f << RXPOLARITY_OFST) +#define RXERRORCNTRESET_OFST (9) +#define RXERRORCNTRESET_MSK (0x0000000f << RXERRORCNTRESET_OFST) +#define RXMSBLSBINVERT_OFST (13) +#define RXMSBLSBINVERT_MSK (0x0000000f << RXMSBLSBINVERT_OFST) -#define EMPTY65CREG (0x65C) +#define TRANSCEIVERERRCNT_REG0 (0xB824) -#define EMPTY660REG (0x660) +#define TRANSCEIVERERRCNT_REG1 (0xB828) -#define EMPTY664REG (0x664) +#define TRANSCEIVERERRCNT_REG2 (0xB82C) -#define EMPTY668REG (0x668) +#define TRANSCEIVERERRCNT_REG3 (0xB830) -#define EMPTY66CREG (0x66C) +#define TRANSCEIVERALIGNCNT_REG0 (0xB834) -#define EMPTY670REG (0x670) +#define RXALIGNCNTCH0_OFST (0) +#define RXALIGNCNTCH0_MSK (0x0000ffff << RXALIGNCNTCH0_OFST) -#define EMPTY674REG (0x674) +#define TRANSCEIVERALIGNCNT_REG1 (0xB838) -#define EMPTY678REG (0x678) +#define RXALIGNCNTCH1_OFST (0) +#define RXALIGNCNTCH1_MSK (0x0000ffff << RXALIGNCNTCH1_OFST) -#define EMPTY67CREG (0x67C) +#define TRANSCEIVERALIGNCNT_REG2 (0xB83C) -#define EMPTY680REG (0x680) +#define RXALIGNCNTCH2_OFST (0) +#define RXALIGNCNTCH2_MSK (0x0000ffff << RXALIGNCNTCH2_OFST) -#define EMPTY684REG (0x684) +#define TRANSCEIVERALIGNCNT_REG3 (0xB840) -#define EMPTY688REG (0x688) +#define RXALIGNCNTCH3_OFST (0) +#define RXALIGNCNTCH3_MSK (0x0000ffff << RXALIGNCNTCH3_OFST) -#define EMPTY68CREG (0x68C) +#define TRANSCEIVERLASTWORD_REG0 (0xB844) -#define EMPTY690REG (0x690) +#define RXDATACH0_OFST (0) +#define RXDATACH0_MSK (0x0000ffff << RXDATACH0_OFST) -#define EMPTY694REG (0x694) +#define TRANSCEIVERLASTWORD_REG1 (0xB848) -#define EMPTY698REG (0x698) +#define RXDATACH1_OFST (0) +#define RXDATACH1_MSK (0x0000ffff << RXDATACH1_OFST) -#define EMPTY69CREG (0x69C) +#define TRANSCEIVERLASTWORD_REG2 (0xB84C) -#define EMPTY6A0REG (0x6A0) +#define RXDATACH2_OFST (0) +#define RXDATACH2_MSK (0x0000ffff << RXDATACH2_OFST) -#define EMPTY6A4REG (0x6A4) +#define TRANSCEIVERLASTWORD_REG3 (0xB850) -#define EMPTY6A8REG (0x6A8) - -#define EMPTY6ACREG (0x6AC) - -#define EMPTY6B0REG (0x6B0) - -#define EMPTY6B4REG (0x6B4) - -#define EMPTY6B8REG (0x6B8) - -#define EMPTY6BCREG (0x6BC) - -#define EMPTY6C0REG (0x6C0) - -#define EMPTY6C4REG (0x6C4) - -#define EMPTY6C8REG (0x6C8) - -#define EMPTY6CCREG (0x6CC) - -#define EMPTY6D0REG (0x6D0) - -#define EMPTY6D4REG (0x6D4) - -#define EMPTY6D8REG (0x6D8) - -#define EMPTY6DCREG (0x6DC) - -#define EMPTY6E0REG (0x6E0) - -#define EMPTY6E4REG (0x6E4) - -#define EMPTY6E8REG (0x6E8) - -#define EMPTY6ECREG (0x6EC) - -#define EMPTY6F0REG (0x6F0) - -#define EMPTY6F4REG (0x6F4) - -#define EMPTY6F8REG (0x6F8) - -#define EMPTY6FCREG (0x6FC) - -#define DBITFIFOCTRLREG (0x700) - -#define DBITRD_OFST (0) -#define DBITRD_MSK (0x00000001 << DBITRD_OFST) -#define DBITRST_OFST (1) -#define DBITRST_MSK (0x00000001 << DBITRST_OFST) -#define DBITFULL_OFST (2) -#define DBITFULL_MSK (0x00000001 << DBITFULL_OFST) -#define DBITEMPTY_OFST (3) -#define DBITEMPTY_MSK (0x00000001 << DBITEMPTY_OFST) -#define DBITUNDERFLOW_OFST (4) -#define DBITUNDERFLOW_MSK (0x00000001 << DBITUNDERFLOW_OFST) -#define DBITOVERFLOW_OFST (5) -#define DBITOVERFLOW_MSK (0x00000001 << DBITOVERFLOW_OFST) - -#define EMPTYREG (0x704) - -#define DBITFIFODATAREG1 (0x708) - -#define DBITFIFODATAREG2 (0x70C) - -#define EMPTY710REG (0x710) - -#define EMPTY714REG (0x714) - -#define EMPTY718REG (0x718) - -#define EMPTY71CREG (0x71C) - -#define EMPTY720REG (0x720) +#define RXDATACH3_OFST (0) +#define RXDATACH3_MSK (0x0000ffff << RXDATACH3_OFST) diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer b/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer index 15bb18072..2617952ec 100755 Binary files a/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer and b/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer differ diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/chip_config_xilinx.txt b/slsDetectorServers/xilinx_ctbDetectorServer/chip_config_xilinx.txt new file mode 100644 index 000000000..0d9a5e05b --- /dev/null +++ b/slsDetectorServers/xilinx_ctbDetectorServer/chip_config_xilinx.txt @@ -0,0 +1,24 @@ +# Prepare MH02 configuration +reg 0xB1B0 0x00000041 +reg 0xB1B4 0x01200004 + +# configure Matterhorn SPI +setbit 0xB1B8 0 + +# wait till config is done +pollbit 0xB1B8 3 0 + +# reset transceiver +reg 0xB820 0x0 +reg 0xB820 0x1 +reg 0xB820 0x0 + +# set MSB LSB inversions and polarity for transceiver +reg 0xB820 0x61e0 + +# Enable MH02 PLL clock +pattern enable_clock_pattern.pyat +# start the flow +setbit 0xB004 0 +clearbit 0xB004 0 +sleep 1 diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/enable_clock_pattern.pyat b/slsDetectorServers/xilinx_ctbDetectorServer/enable_clock_pattern.pyat new file mode 100644 index 000000000..debfbbd27 --- /dev/null +++ b/slsDetectorServers/xilinx_ctbDetectorServer/enable_clock_pattern.pyat @@ -0,0 +1,8 @@ +patword 0x0000 0x0000000000000000 +patword 0x0001 0x0000000000008000 +patword 0x0002 0x0000000000008000 +patword 0x0003 0x0000000000008000 +patword 0x0004 0x0000000000008000 +patword 0x0005 0x0000000000008000 +patioctrl 0x01b3ffff +patlimits 0x0000 0x0005 diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/readout_pattern.pyat b/slsDetectorServers/xilinx_ctbDetectorServer/readout_pattern.pyat new file mode 100644 index 000000000..fb5520142 --- /dev/null +++ b/slsDetectorServers/xilinx_ctbDetectorServer/readout_pattern.pyat @@ -0,0 +1,22 @@ +patword 0x0000 0x0000000000008000 +patword 0x0001 0x0000000000008000 +patword 0x0002 0x0000000000008000 +patword 0x0003 0x0000000000008000 +patword 0x0004 0x0000000000008000 +patword 0x0005 0x0000000000008000 +patword 0x0006 0x0000000000008000 +patword 0x0007 0x0000000000008000 +patword 0x0008 0x0000000000008000 +patword 0x0009 0x0000000000008000 +patword 0x000a 0x0000000000008000 +patword 0x000b 0x0000000000108000 +patword 0x000c 0x0000000000108000 +patword 0x000d 0x0000000000108000 +patword 0x000e 0x0000000000108000 +patword 0x000f 0x0000000000008000 +patword 0x0010 0x0000000000008000 +patword 0x0011 0x0000000000008000 +patword 0x0012 0x0000000000008000 +patword 0x0013 0x0000000000008000 +patioctrl 0x01b3ffff +patlimits 0x0000 0x0013 \ No newline at end of file diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/reset_chip_xilinx.txt b/slsDetectorServers/xilinx_ctbDetectorServer/reset_chip_xilinx.txt new file mode 100644 index 000000000..769cdea10 --- /dev/null +++ b/slsDetectorServers/xilinx_ctbDetectorServer/reset_chip_xilinx.txt @@ -0,0 +1,40 @@ + +# turn off clock +setbit 0xB1B0 16 +setbit 0xB1B8 0 +sleep 1 + +# reset Matterhorn periphery +setbit 0xB1B8 1 +sleep 1 + +# turn on clock +clearbit 0xB1B0 16 +setbit 0xB1B8 0 +sleep 1 + +# reset rx transceiver datapath +setbit 0xB820 4 +sleep 1 + +# reset 8b10b counters +setbit 0xB820 9 +setbit 0xB820 10 +setbit 0xB820 11 +setbit 0xB820 12 +sleep 1 +clearbit 0xB820 9 +clearbit 0xB820 10 + +# reset buffer fifos +reg 0x9024 0xFFFFFFFF +reg 0x9028 0xFFFFFFFF +reg 0x902C 0xFFFFFFFF +reg 0x9024 0x0 +reg 0x9028 0x0 +reg 0x902C 0x0 +setbit 0xA000 18 + +# load default pattern +pattern readout_pattern.pyat + diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c index d0b42841a..a7b03db42 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c @@ -492,7 +492,16 @@ void setTransceiverAlignment(int align) { #endif int isTransceiverAligned() { - return (bus_r(TRANSCEIVERSTATUS) & RXBYTEISALIGNED_MSK); + int times = 0; + int retval = bus_r(TRANSCEIVERSTATUS2) & RXLOCKED_MSK; + while (retval) { + retval = bus_r(TRANSCEIVERSTATUS2) & RXLOCKED_MSK; + times++; + usleep(10); + if (times == 5) + return 1; + } + return retval; } int waitTransceiverAligned(char *mess) { @@ -511,7 +520,9 @@ int waitTransceiverAligned(char *mess) { int times = 0; while (transceiverWordAligned == 0) { if (times++ > WAIT_TIME_OUT_0US_TIMES) { - sprintf(mess, "Transceiver alignment timed out\n"); + sprintf(mess, "Transceiver alignment timed out. Check connection, " + "p-n inversions, LSB-MSB inversions, link error " + "counters and channel enable settings\n"); LOG(logERROR, (mess)); return FAIL; } @@ -587,34 +598,197 @@ int getPowerChip() { int configureChip(char *mess) { LOG(logINFOBLUE, ("\tConfiguring chip\n")); - - // enable correct endianness (Only for MH_PR_2) - // uint32_t addr = MATTERHORNSPIREG1; - // bus_w(addr, bus_r(addr) &~MATTERHORNSPI1_MSK); - // bus_w(addr, bus_r(addr) | ((0x40000 << MATTERHORNSPI1_OFST) & - // MATTERHORNSPI1_MSK)); - - // start configuration - uint32_t addr = MATTERHORNSPICTRL; - bus_w(addr, bus_r(addr) | CONFIGSTART_P_MSK); - bus_w(addr, bus_r(addr) & ~CONFIGSTART_P_MSK); - - // wait until configuration is done -#ifndef VIRTUAL - int configDone = (bus_r(MATTERHORNSPICTRL) & BUSY_MSK); - int times = 0; - while (configDone == 0) { - if (times++ > WAIT_TIME_OUT_0US_TIMES) { - sprintf(mess, "Configuration of chip timed out\n"); - LOG(logERROR, (mess)); - return FAIL; - } - usleep(0); - configDone = (bus_r(MATTERHORNSPICTRL) & BUSY_MSK); + chipConfigured = 0; + if (readConfigFile(mess, CONFIG_CHIP_FILE, "chip config") == FAIL) { + return FAIL; } -#endif + if (readConfigFile(mess, RESET_CHIP_FILE, "reset chip") == FAIL) { + return FAIL; + } + LOG(logINFOBLUE, ("Chip configured.\n")); chipConfigured = 1; - LOG(logINFOBLUE, ("\tChip configured\n")); + return OK; +} + +int readConfigFile(char *mess, char *fileName, char *fileType) { + const int fileNameSize = 128; + char fname[fileNameSize]; + if (getAbsPath(fname, fileNameSize, fileName) == FAIL) { + sprintf(mess, "Could not get full path for %s file [%s].\n", fileType, + fname); + LOG(logERROR, (mess)); + return FAIL; + } + if (access(fname, F_OK) != 0) { + sprintf(mess, "Could not find %s file [%s].\n", fileType, fname); + LOG(logERROR, (mess)); + return FAIL; + } + FILE *fd = fopen(fname, "r"); + if (fd == NULL) { + sprintf(mess, "Could not open on-board detector server %s file [%s].\n", + fileType, fname); + LOG(logERROR, (mess)); + return FAIL; + } + LOG(logINFOBLUE, ("Reading %s file %s\n", fileType, fname)); + + const size_t LZ = 256; + char line[LZ]; + memset(line, 0, LZ); + char command[LZ]; + + // keep reading a line + while (fgets(line, LZ, fd)) { + + // ignore comments + if (line[0] == '#') { + LOG(logDEBUG1, ("Ignoring Comment\n")); + continue; + } + + // ignore empty lines + if (strlen(line) <= 1) { + LOG(logDEBUG1, ("Ignoring Empty line\n")); + continue; + } + + // removing leading spaces + if (line[0] == ' ' || line[0] == '\t') { + int len = strlen(line); + // find first valid character + int i = 0; + for (i = 0; i < len; ++i) { + if (line[i] != ' ' && line[i] != '\t') { + break; + } + } + // ignore the line full of spaces (last char \n) + if (i >= len - 1) { + LOG(logDEBUG1, ("Ignoring line full of spaces\n")); + continue; + } + // copying only valid char + char temp[LZ]; + memset(temp, 0, LZ); + memcpy(temp, line + i, strlen(line) - i); + memset(line, 0, LZ); + memcpy(line, temp, strlen(temp)); + LOG(logDEBUG1, ("Removing leading spaces.\n")); + } + + LOG(logDEBUG1, ("Command to process: (size:%d) %.*s\n", strlen(line), + strlen(line) - 1, line)); + memset(command, 0, LZ); + + // reg command + if (!strncmp(line, "reg", strlen("reg"))) { + uint32_t addr = 0; + uint32_t val = 0; + if (sscanf(line, "%s %x %x", command, &addr, &val) != 3) { + sprintf(mess, "Could not scan reg command. Line:[%s].\n", line); + LOG(logERROR, (mess)); + return FAIL; + } + bus_w(addr, val); + LOG(logINFOBLUE, ("Wrote 0x%x to 0x%x\n", val, addr)); + } + + // setbit command + else if (!strncmp(line, "setbit", strlen("setbit"))) { + uint32_t addr = 0; + uint32_t bit = 0; + if (sscanf(line, "%s %x %d", command, &addr, &bit) != 3) { + sprintf(mess, "Could not scan setbit command. Line:[%s].\n", + line); + LOG(logERROR, (mess)); + return FAIL; + } + bus_w(addr, bus_r(addr) | (1 << bit)); + LOG(logINFOBLUE, ("Set bit %d in 0x%x\n", bit, addr)); + } + + // clearbit command + else if (!strncmp(line, "clearbit", strlen("clearbit"))) { + uint32_t addr = 0; + uint32_t bit = 0; + if (sscanf(line, "%s %x %d", command, &addr, &bit) != 3) { + sprintf(mess, "Could not scan clearbit command. Line:[%s].\n", + line); + LOG(logERROR, (mess)); + return FAIL; + } + bus_w(addr, bus_r(addr) & ~(1 << bit)); + LOG(logINFOBLUE, ("Cleared bit %d in 0x%x\n", bit, addr)); + } + + // pollbit command + else if (!strncmp(line, "pollbit", strlen("pollbit"))) { + uint32_t addr = 0; + uint32_t bit = 0; + uint32_t val = 0; + if (sscanf(line, "%s %x %d %d", command, &addr, &bit, &val) != 4) { + sprintf(mess, "Could not scan pollbit command. Line:[%s].\n", + line); + LOG(logERROR, (mess)); + return FAIL; + } +#ifndef VIRTUAL + int times = 0; + while (((bus_r(addr) >> bit) & 0x1) != val) { + if (times++ > WAIT_TIME_OUT_0US_TIMES) { + sprintf(mess, "Polling bit %d in 0x%x timed out\n", bit, + addr); + LOG(logERROR, (mess)); + return FAIL; + } + usleep(0); + } +#endif + LOG(logINFOBLUE, ("Polled bit %d in 0x%x\n", bit, addr)); + } + + // pattern command + else if (!strncmp(line, "pattern", strlen("pattern"))) { + // take a file name and call loadPatterFile + char patternFileName[LZ]; + if (sscanf(line, "%s %s", command, patternFileName) != 2) { + sprintf(mess, "Could not scan pattern command. Line:[%s].\n", + line); + LOG(logERROR, (mess)); + return FAIL; + } + if (loadPatternFile(patternFileName, mess) == FAIL) { + return FAIL; + } + LOG(logINFOBLUE, ("loaded pattern [%s].\n", patternFileName)); + } + + // sleep command + else if (!strncmp(line, "sleep", strlen("sleep"))) { + int time = 0; + if (sscanf(line, "%s %d", command, &time) != 2) { + sprintf(mess, "Could not scan sleep command. Line:[%s].\n", + line); + LOG(logERROR, (mess)); + return FAIL; + } + usleep(time * 1000 * 1000); + LOG(logINFOBLUE, ("Slept for %d s\n", time)); + } + + // other commands + else { + sprintf(mess, + "Could not scan command from on-board server " + "%s file. Line:[%s].\n", + fileType, line); + break; + } + memset(line, 0, LZ); + } + fclose(fd); + LOG(logINFOBLUE, ("Successfully read %s file.\n", fileType)); return OK; } @@ -1328,31 +1502,13 @@ int startStateMachine() { return OK; #endif - LOG(logINFOBLUE, ("Starting State Machine\n")); - // cleanFifos(); removing this for now as its done before readout pattern + LOG(logINFOBLUE, ("Starting readout\n")); - // start state machine - bus_w(FLOW_CONTROL_REG, bus_r(FLOW_CONTROL_REG) | START_F_MSK); - - LOG(logINFORED, ("Waiting for exposing to be done\n")); - int exposingDone = (bus_r(FLOW_STATUS_REG) & RSM_BUSY_MSK); - while (exposingDone != 0) { - usleep(0); - exposingDone = (bus_r(FLOW_STATUS_REG) & RSM_BUSY_MSK); - } - - LOG(logINFORED, ("Starting readout of chip to fifo\n")); + // MM:readout via pattern does not work right now due to firmware bug, + // readout via MatterhornCTRL for the moment + // bus_w(FLOW_CONTROL_REG, bus_r(FLOW_CONTROL_REG) | START_F_MSK); bus_w(MATTERHORNSPICTRL, bus_r(MATTERHORNSPICTRL) | STARTREAD_P_MSK); - LOG(logINFORED, ("Waiting until k-words or end of acquisition\n")); - usleep(0); - int commaDet = (bus_r(TRANSCEIVERSTATUS) & RXCOMMADET_MSK); - while (commaDet == 0) { - usleep(0); - commaDet = (bus_r(TRANSCEIVERSTATUS) & RXCOMMADET_MSK); - } - LOG(logINFORED, ("Kwords or end of acquisition detected\n")); - return OK; } @@ -1467,56 +1623,6 @@ int stopStateMachine() { return OK; } -int startReadOut() { - LOG(logINFOBLUE, ("Starting Readout\n")); -#ifdef VIRTUAL - // cannot set #frames and exptiem temporarily to 1 and 0, - // because have to set it back after readout (but this is non blocking) - return startStateMachine(); -#endif - // check if data in fifo - int ret = FAIL; - if (transceiverEnable) { - if ((bus_r(X_FIFO_EMPTY_STATUS_REG) & X_FIFO_EMPTY_STATUS_MSK) != - X_FIFO_EMPTY_STATUS_MSK) { - LOG(logINFO, ("Data in transceiver fifo\n")); - ret = OK; - } - } - if (analogEnable) { - if (bus_r(A_FIFO_EMPTY_STATUS_REG) != BIT32_MSK) { - LOG(logINFO, ("Data in analog fifo\n")); - ret = OK; - } - } - if (digitalEnable) { - if ((bus_r(D_FIFO_EMPTY_STATUS_REG) & D_FIFO_EMPTY_STATUS_MSK) != - D_FIFO_EMPTY_STATUS_MSK) { - LOG(logINFO, ("Data in digital fifo\n")); - ret = OK; - } - } - // if no module, dont check fifo empty - if (checkModuleFlag && ret == FAIL) { - LOG(logERROR, ("No data in fifo\n")); - return FAIL; - } - - LOG(logINFOBLUE, ("Streaming data from fifo\n")); - bus_w(FIFO_TO_GB_CONTROL_REG, - bus_r(FIFO_TO_GB_CONTROL_REG) | START_STREAMING_P_MSK); - - // wait until streaming is done (not same as fifo empty) - int streamingBusy = (bus_r(STATUSREG1) & TRANSMISSIONBUSY_MSK); - while (streamingBusy != 0) { - usleep(0); - streamingBusy = (bus_r(STATUSREG1) & TRANSMISSIONBUSY_MSK); - } - LOG(logINFORED, ("Streaming done\n")); - - return OK; -} - int softwareTrigger() { #ifndef VIRTUAL // ready for trigger @@ -1552,36 +1658,33 @@ enum runStatus getRunStatus() { LOG(logINFOBLUE, ("Status: IDLE\n")); return IDLE; #endif - uint32_t retval = bus_r(FLOW_STATUS_REG); - LOG(logINFO, ("Flow Status Register: %08x\n", retval)); + uint32_t retval = bus_r(STATUS_REG); + LOG(logINFO, ("Status Register: %08x\n", retval)); - if (retval & RSM_TRG_WAIT_MSK) { - LOG(logINFOBLUE, ("Status: WAITING\n")); - return WAITING; - } else if (retval & RSM_BUSY_MSK) { - LOG(logINFOBLUE, ("Status: RUNNING (exposing)\n")); - return RUNNING; - } else if (bus_r(MATTERHORNSPICTRL) & READOUTFROMASIC_MSK) { - LOG(logINFOBLUE, ("Status: RUNNING (data from chip to fifo)\n")); - return RUNNING; - } else if (bus_r(STATUSREG1) & TRANSMISSIONBUSY_MSK) { - LOG(logINFOBLUE, ("Status: TRANSMITTING\n")); - return TRANSMITTING; + if (retval == 0x0) { + return IDLE; } - LOG(logINFOBLUE, ("Status: IDLE\n")); - return IDLE; - // TODO: STOPPED, ERROR? + if (retval & RX_NOT_GOOD_MSK) { + LOG(logINFOBLUE, ("Status: ERROR\n")); + return ERROR; + } + + if (retval & WAIT_FOR_TRIGGER_MSK) { + LOG(logINFOBLUE, ("Status: WAITING\n")); + return WAITING; + } + + LOG(logINFOBLUE, ("Status: RUNNING\n")); + return RUNNING; + // TODO: STOPPED? } u_int32_t runBusy() { #ifdef VIRTUAL return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0); #endif - uint32_t exposingBusy = bus_r(FLOW_STATUS_REG) & RSM_BUSY_MSK; - uint32_t fillingFifoBusy = bus_r(MATTERHORNSPICTRL) & READOUTFROMASIC_MSK; - uint32_t streamingBusy = bus_r(STATUSREG1) & TRANSMISSIONBUSY_MSK; - return (exposingBusy || fillingFifoBusy || streamingBusy); + return (bus_r(STATUS_REG)); } void waitForAcquisitionEnd() { diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h index 54cb758de..df291c0d2 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h @@ -4,7 +4,7 @@ #include "RegisterDefs.h" #include "sls/sls_detector_defs.h" -#define REQRD_FRMWRE_VRSN (0x230710) +#define REQRD_FRMWRE_VRSN (0x250203) #define KERNEL_DATE_VRSN "Wed Nov 29 17:32:14 CET 2023" #define LINKED_SERVER_NAME "xilinx_ctbDetectorServer" @@ -40,6 +40,9 @@ #define SLOWADC_DRIVER_FILE_NAME CURRENT_BOARD_LINKS_FOLDER "/ai%d" #define TEMP_DRIVER_FILE_NAME DEVICE_TREE_DST "0/in_temp7_input" +#define CONFIG_CHIP_FILE "chip_config_xilinx.txt" +#define RESET_CHIP_FILE "reset_chip_xilinx.txt" + /** Default Parameters */ #define DEFAULT_NUM_FRAMES (1) #define DEFAULT_NUM_CYCLES (1) diff --git a/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh b/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh index f4ac7c107..d681a287e 100644 --- a/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh +++ b/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh @@ -80,7 +80,7 @@ _sd() { local IS_PATH=0 -local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clearroi clientversion clkdiv clkfreq clkphase collectionmode column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 exptimel extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit patternX patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga roi romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname sleep slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timing_info_decoder timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport " +local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clearroi clientversion clkdiv clkfreq clkphase collectionmode column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 exptimel extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit pattern patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga roi romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname sleep slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timing_info_decoder timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport " __acquire() { FCN_RETURN="" return 0 @@ -1447,18 +1447,82 @@ return 0 } __patloop() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patloop0() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patloop1() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patloop2() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patmask() { @@ -1472,18 +1536,70 @@ return 0 } __patnloop() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patnloop0() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patnloop1() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patnloop2() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patsetbit() { @@ -1495,7 +1611,7 @@ fi fi return 0 } -__patternX() { +__pattern() { FCN_RETURN="" if [[ ${IS_GET} -eq 1 ]]; then if [[ "${cword}" == "2" ]]; then @@ -1522,18 +1638,70 @@ return 0 } __patwait() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patwait0() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patwait1() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patwait2() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patwaittime() { diff --git a/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh b/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh index 313108167..28b16cc22 100644 --- a/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh +++ b/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh @@ -4,7 +4,7 @@ _sd() { -local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clearroi clientversion clkdiv clkfreq clkphase collectionmode column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 exptimel extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit patternX patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga roi romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname sleep slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timing_info_decoder timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport " +local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clearroi clientversion clkdiv clkfreq clkphase collectionmode column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 exptimel extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit pattern patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga roi romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname sleep slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timing_info_decoder timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport " __acquire() { FCN_RETURN="" return 0 @@ -1371,18 +1371,82 @@ return 0 } __patloop() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patloop0() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patloop1() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patloop2() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "4" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patmask() { @@ -1396,18 +1460,70 @@ return 0 } __patnloop() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patnloop0() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patnloop1() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patnloop2() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patsetbit() { @@ -1419,7 +1535,7 @@ fi fi return 0 } -__patternX() { +__pattern() { FCN_RETURN="" if [[ ${IS_GET} -eq 1 ]]; then if [[ "${cword}" == "2" ]]; then @@ -1446,18 +1562,70 @@ return 0 } __patwait() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patwait0() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patwait1() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patwait2() { FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +fi +if [[ ${IS_GET} -eq 0 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +fi +if [[ "${cword}" == "3" ]]; then +FCN_RETURN="" +fi +fi return 0 } __patwaittime() { diff --git a/slsDetectorSoftware/generator/commands.yaml b/slsDetectorSoftware/generator/commands.yaml index be298d0fd..99d1996e0 100644 --- a/slsDetectorSoftware/generator/commands.yaml +++ b/slsDetectorSoftware/generator/commands.yaml @@ -468,7 +468,7 @@ subdeadtime: function: setSubDeadTime compdisabletime: - help: "[duration] [(optional unit) ns|us|ms|s]\n\t[Jungfrau] Time before end of exposure when comparator is disabled. It is only possible for chipv1.1." + help: "[duration] [(optional unit) ns|us|ms|s]\n\t[Jungfrau] Time before end of exposure when comparator is disabled." inherit_actions: TIME_COMMAND actions: GET: @@ -1123,7 +1123,7 @@ temp_control: input_types: [ bool ] autocompdisable: - help: "[0, 1]\n\t[Jungfrau] Auto comparator disable mode. By default, the on-chip gain switching is active during the entire exposure.This mode disables the on - chip gain switching comparator automatically after 93.75% (only for chipv1.0) of exposure time (only for longer than 100us). It is possible to set the duration for chipv1.1 using compdisabletime command.\n\tDefault is 0 or this mode disabled(comparator enabled throughout). 1 enables mode. 0 disables mode. " + help: "[0, 1]\n\t[Jungfrau] Auto comparator disable mode. By default, the on-chip gain switching is active during the entire exposure.This mode disables the on - chip gain switching comparator automatically and the duration is set using compdisabletime command.\n\tDefault is 0 or this mode disabled(comparator enabled throughout). 1 enables mode. 0 disables mode. " inherit_actions: INTEGER_COMMAND_VEC_ID actions: GET: @@ -1210,7 +1210,7 @@ polarity: input_types: [ defs::polarity ] timing_info_decoder: - help: "[swissfel|shine]\n\t[Jungfrau] Advanced Command and only for Swissfel and Shine. Sets the bunch id or timing info decoder. Default is swissfel." + help: "[swissfel|shine]\n\t[Jungfrau] Advanced Command and only for Swissfel and Shine. Sets the bunch id or timing info decoder. Default is swissfel. Only allowed for pcbv2.0." inherit_actions: INTEGER_COMMAND_VEC_ID actions: GET: @@ -3467,7 +3467,7 @@ udp_dstlist: output: [ ToString(args) ] txdelay: - help: "[n_delay]\n\t[Eiger][Jungfrau][Moench][Mythen3] Set transmission delay for all modules in the detector using the step size provided.Sets up \n\t[Eiger] txdelay_left to (2 * mod_index * n_delay), \n\t[Eiger] txdelay_right to ((2 * mod_index + 1) * n_delay) and \n\t[Eiger] txdelay_frame to (2 *num_modules * n_delay)\n\t[Jungfrau][Moench][Mythen3] txdelay_frame to (num_modules * n_delay) for every module." + help: "[n_delay]\n\t[Eiger][Jungfrau][Moench][Mythen3] Set transmission delay for all modules in the detector using the step size provided.Sets up \n\t[Eiger] txdelay_left to (2 * mod_index * n_delay), \n\t[Eiger] txdelay_right to ((2 * mod_index + 1) * n_delay) and \n\t[Eiger] txdelay_frame to (2 * num_modules * n_delay)\n\t[Jungfrau][Moench][Mythen3] txdelay_frame to (num_modules * n_delay) for every module." actions: GET: argc: 0 @@ -3912,8 +3912,7 @@ diodelay: cast_input: [ true, true ] output: [ ToString(args) ] -# pattern is a keyword in yaml, so patternX is used to avoid it -patternX: +pattern: help: "[fname]\n\t[Mythen3][Ctb][Xilinx Ctb] Loads ASCII pattern file directly to server (instead of executing line by line)" command_name: "pattern" actions: diff --git a/slsDetectorSoftware/generator/deprecated_commands.yaml b/slsDetectorSoftware/generator/deprecated_commands.yaml index 22788505d..1958cb350 100644 --- a/slsDetectorSoftware/generator/deprecated_commands.yaml +++ b/slsDetectorSoftware/generator/deprecated_commands.yaml @@ -164,6 +164,7 @@ i_d: im_d i_io: im_io #Pattern +patternX: pattern #Moench #Advanced diff --git a/slsDetectorSoftware/generator/extended_commands.yaml b/slsDetectorSoftware/generator/extended_commands.yaml index 6f4d7b583..d9114762e 100644 --- a/slsDetectorSoftware/generator/extended_commands.yaml +++ b/slsDetectorSoftware/generator/extended_commands.yaml @@ -762,10 +762,9 @@ autocompdisable: function_alias: autocompdisable help: "[0, 1]\n\t[Jungfrau] Auto comparator disable mode. By default, the on-chip\ \ gain switching is active during the entire exposure.This mode disables the on\ - \ - chip gain switching comparator automatically after 93.75% (only for chipv1.0)\ - \ of exposure time (only for longer than 100us). It is possible to set the duration\ - \ for chipv1.1 using compdisabletime command.\n\tDefault is 0 or this mode disabled(comparator\ - \ enabled throughout). 1 enables mode. 0 disables mode. " + \ - chip gain switching comparator automatically and the duration is set using\ + \ compdisabletime command.\n\tDefault is 0 or this mode disabled(comparator enabled\ + \ throughout). 1 enables mode. 0 disables mode. " infer_action: true template: true badchannels: @@ -1607,7 +1606,7 @@ compdisabletime: command_name: compdisabletime function_alias: compdisabletime help: "[duration] [(optional unit) ns|us|ms|s]\n\t[Jungfrau] Time before end of\ - \ exposure when comparator is disabled. It is only possible for chipv1.1." + \ exposure when comparator is disabled." infer_action: true template: true confadc: @@ -6534,7 +6533,7 @@ patsetbit: \ pattern to the selected bits." infer_action: true template: true -patternX: +pattern: actions: PUT: args: @@ -11386,7 +11385,8 @@ timing_info_decoder: command_name: timing_info_decoder function_alias: timing_info_decoder help: "[swissfel|shine]\n\t[Jungfrau] Advanced Command and only for Swissfel and\ - \ Shine. Sets the bunch id or timing info decoder. Default is swissfel." + \ Shine. Sets the bunch id or timing info decoder. Default is swissfel. Only allowed\ + \ for pcbv2.0." infer_action: true template: true timinglist: @@ -11813,7 +11813,7 @@ txdelay: help: "[n_delay]\n\t[Eiger][Jungfrau][Moench][Mythen3] Set transmission delay for\ \ all modules in the detector using the step size provided.Sets up \n\t[Eiger]\ \ txdelay_left to (2 * mod_index * n_delay), \n\t[Eiger] txdelay_right to ((2\ - \ * mod_index + 1) * n_delay) and \n\t[Eiger] txdelay_frame to (2 *num_modules\ + \ * mod_index + 1) * n_delay) and \n\t[Eiger] txdelay_frame to (2 * num_modules\ \ * n_delay)\n\t[Jungfrau][Moench][Mythen3] txdelay_frame to (num_modules * n_delay)\ \ for every module." infer_action: true diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index eed90955b..becdde20d 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -65,7 +65,12 @@ class Detector { Result getHostname(Positions pos = {}) const; - /**Frees shared memory, adds detectors to the list. */ + /**Frees shared memory, adds detectors to the list. The row and column + * values in the udp/zmq header are affected by the order in this command + * and the setDetectorSize function. The modules are stacked row by row + * until they reach the y-axis limit set by detsize (if specified). Then, + * stacking continues in the next column and so on. This only affects row + * and column in udp/zmq header.*/ void setHostname(const std::vector &hostname); /** connects to n servers at local host starting at specific control port. @@ -1304,11 +1309,9 @@ class Detector { * //TODO naming * By default, the on-chip gain switching is active during the * entire exposure. This mode disables the on-chip gain switching comparator - * automatically after 93.75% of exposure time (only for longer than 100us). - * The % is for chipv1.0. One can set the duration for chipv1.1 using - * setComparatorDisableTime\n Default is false or this mode - * disabled(comparator enabled throughout). true enables mode. 0 disables - * mode. + * automatically and the duration is set using setComparatorDisableTime\n + * Default is false or this mode disabled(comparator enabled throughout). + * true enables mode. 0 disables mode. */ void setAutoComparatorDisable(bool value, Positions pos = {}); @@ -1316,7 +1319,7 @@ class Detector { Result getComparatorDisableTime(Positions pos = {}) const; /** [Jungfrau] Time before end of exposure when comparator is - * disabled. It is only possible for chipv1.1.*/ + * disabled.*/ void setComparatorDisableTime(ns t, Positions pos = {}); /** [Jungfrau] Advanced TODO naming */ @@ -1382,7 +1385,7 @@ class Detector { Result getTimingInfoDecoder(Positions pos = {}) const; - /** [Jungfrau] Advanced Command! */ + /** [Jungfrau] Advanced Command! Only for pcb v2.0 */ void setTimingInfoDecoder(defs::timingInfoDecoder value, Positions pos = {}); diff --git a/slsDetectorSoftware/src/Caller.cpp b/slsDetectorSoftware/src/Caller.cpp index 96fd229a1..189e063b5 100644 --- a/slsDetectorSoftware/src/Caller.cpp +++ b/slsDetectorSoftware/src/Caller.cpp @@ -1018,7 +1018,7 @@ std::string Caller::autocompdisable(int action) { // print help if (action == slsDetectorDefs::HELP_ACTION) { os << R"V0G0N([0, 1] - [Jungfrau] Auto comparator disable mode. By default, the on-chip gain switching is active during the entire exposure.This mode disables the on - chip gain switching comparator automatically after 93.75% (only for chipv1.0) of exposure time (only for longer than 100us). It is possible to set the duration for chipv1.1 using compdisabletime command. + [Jungfrau] Auto comparator disable mode. By default, the on-chip gain switching is active during the entire exposure.This mode disables the on - chip gain switching comparator automatically and the duration is set using compdisabletime command. Default is 0 or this mode disabled(comparator enabled throughout). 1 enables mode. 0 disables mode. )V0G0N" << std::endl; return os.str(); @@ -2108,7 +2108,7 @@ std::string Caller::compdisabletime(int action) { // print help if (action == slsDetectorDefs::HELP_ACTION) { os << R"V0G0N([duration] [(optional unit) ns|us|ms|s] - [Jungfrau] Time before end of exposure when comparator is disabled. It is only possible for chipv1.1. )V0G0N" + [Jungfrau] Time before end of exposure when comparator is disabled. )V0G0N" << std::endl; return os.str(); } @@ -14655,7 +14655,7 @@ std::string Caller::timing_info_decoder(int action) { // print help if (action == slsDetectorDefs::HELP_ACTION) { os << R"V0G0N([swissfel|shine] - [Jungfrau] Advanced Command and only for Swissfel and Shine. Sets the bunch id or timing info decoder. Default is swissfel. )V0G0N" + [Jungfrau] Advanced Command and only for Swissfel and Shine. Sets the bunch id or timing info decoder. Default is swissfel. Only allowed for pcbv2.0. )V0G0N" << std::endl; return os.str(); } @@ -15276,7 +15276,7 @@ std::string Caller::txdelay(int action) { [Eiger][Jungfrau][Moench][Mythen3] Set transmission delay for all modules in the detector using the step size provided.Sets up [Eiger] txdelay_left to (2 * mod_index * n_delay), [Eiger] txdelay_right to ((2 * mod_index + 1) * n_delay) and - [Eiger] txdelay_frame to (2 *num_modules * n_delay) + [Eiger] txdelay_frame to (2 * num_modules * n_delay) [Jungfrau][Moench][Mythen3] txdelay_frame to (num_modules * n_delay) for every module. )V0G0N" << std::endl; return os.str(); diff --git a/slsDetectorSoftware/src/Caller.h b/slsDetectorSoftware/src/Caller.h index 65958653c..475a879f6 100644 --- a/slsDetectorSoftware/src/Caller.h +++ b/slsDetectorSoftware/src/Caller.h @@ -543,7 +543,7 @@ class Caller { {"patnloop1", &Caller::patnloop1}, {"patnloop2", &Caller::patnloop2}, {"patsetbit", &Caller::patsetbit}, - {"patternX", &Caller::pattern}, + {"pattern", &Caller::pattern}, {"patternstart", &Caller::patternstart}, {"patwait", &Caller::patwait}, {"patwait0", &Caller::patwait0}, @@ -872,6 +872,7 @@ class Caller { {"i_c", "im_c"}, {"i_d", "im_d"}, {"i_io", "im_io"}, + {"patternX", "pattern"}, {"copydetectorserver", "updatedetectorserver"}, {"nframes", "framecounter"}, {"now", "runtime"}, diff --git a/slsDetectorSoftware/src/CallerSpecial.cpp b/slsDetectorSoftware/src/CallerSpecial.cpp index 12e02b0ff..078c383f3 100644 --- a/slsDetectorSoftware/src/CallerSpecial.cpp +++ b/slsDetectorSoftware/src/CallerSpecial.cpp @@ -198,7 +198,12 @@ std::string Caller::hostname(int action) { os << "\n\tFrees shared memory and sets hostname (or IP address) of " "all modules concatenated by +.\n\t Virtual servers can already " "use the port in hostname separated by ':' and ports incremented " - "by 2 to accomodate the stop server as well." + "by 2 to accomodate the stop server as well. The row and column " + "values in the udp/zmq header are affected by the order in this " + "command and the detsize command. The modules are stacked row by " + "row until they reach the y-axis limit set by detsize (if " + "specified). Then, stacking continues in the next column and so " + "on. This only affects row and column in udp/zmq header." << '\n'; } else if (action == defs::GET_ACTION) { if (!args.empty()) { diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index d8d78f9d7..947668c33 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -99,6 +99,12 @@ void Detector::loadParameters(const std::vector ¶meters) { CmdParser parser; for (const auto ¤t_line : parameters) { parser.Parse(current_line); + if (parser.multi_id() != 0) { + throw RuntimeError( + "Multi-detector indices [" + std::to_string(parser.multi_id()) + + "] are not allowed in the file. Instead, use the index for " + "'config' or 'parameters' command?"); + } caller.call(parser.command(), parser.arguments(), parser.detector_id(), defs::PUT_ACTION, std::cout, parser.receiver_id()); } diff --git a/slsDetectorSoftware/src/inferAction.h b/slsDetectorSoftware/src/inferAction.h index b09c505f7..a3116a3e1 100644 --- a/slsDetectorSoftware/src/inferAction.h +++ b/slsDetectorSoftware/src/inferAction.h @@ -488,7 +488,7 @@ class InferAction { {"patnloop1", &InferAction::patnloop1}, {"patnloop2", &InferAction::patnloop2}, {"patsetbit", &InferAction::patsetbit}, - {"patternX", &InferAction::pattern}, + {"pattern", &InferAction::pattern}, {"patternstart", &InferAction::patternstart}, {"patwait", &InferAction::patwait}, {"patwait0", &InferAction::patwait0}, diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-jungfrau.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-jungfrau.cpp index e63f99144..f6fb4260d 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-jungfrau.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-jungfrau.cpp @@ -262,8 +262,7 @@ TEST_CASE("compdisabletime", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::JUNGFRAU && - det.getChipVersion().squash() * 10 == 11) { + if (det_type == defs::JUNGFRAU) { auto prev_val = det.getComparatorDisableTime(); { std::ostringstream oss; @@ -670,7 +669,8 @@ TEST_CASE("pedestalmode", "[.cmdcall]") { TEST_CASE("timing_info_decoder", "[.cmdcall]") { Detector det; Caller caller(&det); - if (det.getDetectorType().squash() == defs::JUNGFRAU) { + if (det.getDetectorType().squash() == defs::JUNGFRAU && + det.getHardwareVersion().squash() == "2.0") { auto prev_val = det.getTimingInfoDecoder(); /*{ std::ostringstream oss; diff --git a/slsReceiverSoftware/CMakeLists.txt b/slsReceiverSoftware/CMakeLists.txt index 8ff2b1e6b..543ff7467 100755 --- a/slsReceiverSoftware/CMakeLists.txt +++ b/slsReceiverSoftware/CMakeLists.txt @@ -138,13 +138,34 @@ if (SLS_USE_RECEIVER_BINARIES) slsProjectWarnings ) - install(TARGETS slsReceiver slsMultiReceiver + add_executable(slsFrameSynchronizer + src/FrameSynchronizerApp.cpp + ) + + set_target_properties(slsFrameSynchronizer PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + ) + if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) + set_property(TARGET slsFrameSynchronizer PROPERTY INTERPROCEDURAL_OPTIMIZATION True) + endif() + + target_link_libraries(slsFrameSynchronizer + PUBLIC + slsReceiverStatic + pthread + rt + PRIVATE + slsProjectWarnings + "$" + ) + + install(TARGETS slsReceiver slsMultiReceiver slsFrameSynchronizer EXPORT "${TARGETS_EXPORT_NAME}" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sls -) + ) endif(SLS_USE_RECEIVER_BINARIES) diff --git a/slsReceiverSoftware/include/sls/Receiver.h b/slsReceiverSoftware/include/sls/Receiver.h index f3389c80e..eb7c4b214 100644 --- a/slsReceiverSoftware/include/sls/Receiver.h +++ b/slsReceiverSoftware/include/sls/Receiver.h @@ -45,9 +45,8 @@ class Receiver : private virtual slsDetectorDefs { * Call back arguments are: * - startCallbackHeader metadata */ - void registerCallBackStartAcquisition(int (*func)(const startCallbackHeader, - void *), - void *arg); + void registerCallBackStartAcquisition( + void (*func)(const startCallbackHeader, void *), void *arg); /** * Call back for acquisition finished diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index ce8702151..47914b7bc 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -33,6 +33,8 @@ using Interface = ServerInterface; #define gettid() syscall(SYS_gettid) #endif +std::mutex ClientInterface::callbackMutex; + ClientInterface::~ClientInterface() { killTcpThread = true; LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber; @@ -54,13 +56,15 @@ std::string ClientInterface::getReceiverVersion() { return APIRECEIVER; } /***callback functions***/ void ClientInterface::registerCallBackStartAcquisition( - int (*func)(const startCallbackHeader, void *), void *arg) { + void (*func)(const startCallbackHeader, void *), void *arg) { + std::lock_guard lock(callbackMutex); startAcquisitionCallBack = func; pStartAcquisition = arg; } void ClientInterface::registerCallBackAcquisitionFinished( void (*func)(const endCallbackHeader, void *), void *arg) { + std::lock_guard lock(callbackMutex); acquisitionFinishedCallBack = func; pAcquisitionFinished = arg; } @@ -69,6 +73,7 @@ void ClientInterface::registerCallBackRawDataReady( void (*func)(sls_receiver_header &, dataCallbackHeader, char *, size_t &, void *), void *arg) { + std::lock_guard lock(callbackMutex); rawDataReadyCallBack = func; pRawDataReady = arg; } @@ -461,15 +466,18 @@ void ClientInterface::setDetectorType(detectorType arg) { std::string(e.what()) + ']'); } // callbacks after (in setdetectortype, the object is reinitialized) - if (startAcquisitionCallBack != nullptr) - impl()->registerCallBackStartAcquisition(startAcquisitionCallBack, - pStartAcquisition); - if (acquisitionFinishedCallBack != nullptr) - impl()->registerCallBackAcquisitionFinished(acquisitionFinishedCallBack, - pAcquisitionFinished); - if (rawDataReadyCallBack != nullptr) - impl()->registerCallBackRawDataReady(rawDataReadyCallBack, - pRawDataReady); + { + std::lock_guard lock(callbackMutex); + if (startAcquisitionCallBack != nullptr) + impl()->registerCallBackStartAcquisition(startAcquisitionCallBack, + pStartAcquisition); + if (acquisitionFinishedCallBack != nullptr) + impl()->registerCallBackAcquisitionFinished( + acquisitionFinishedCallBack, pAcquisitionFinished); + if (rawDataReadyCallBack != nullptr) + impl()->registerCallBackRawDataReady(rawDataReadyCallBack, + pRawDataReady); + } impl()->setThreadIds(parentThreadId, tcpThreadId); } diff --git a/slsReceiverSoftware/src/ClientInterface.h b/slsReceiverSoftware/src/ClientInterface.h index 8bde90c64..0d9631870 100644 --- a/slsReceiverSoftware/src/ClientInterface.h +++ b/slsReceiverSoftware/src/ClientInterface.h @@ -34,9 +34,8 @@ class ClientInterface : private virtual slsDetectorDefs { //***callback functions*** /** params: file path, file name, file index, image size */ - void registerCallBackStartAcquisition(int (*func)(const startCallbackHeader, - void *), - void *arg); + void registerCallBackStartAcquisition( + void (*func)(const startCallbackHeader, void *), void *arg); /** params: total frames caught */ void registerCallBackAcquisitionFinished( @@ -180,8 +179,8 @@ class ClientInterface : private virtual slsDetectorDefs { //***callback parameters*** - int (*startAcquisitionCallBack)(const startCallbackHeader, - void *) = nullptr; + void (*startAcquisitionCallBack)(const startCallbackHeader, + void *) = nullptr; void *pStartAcquisition{nullptr}; void (*acquisitionFinishedCallBack)(const endCallbackHeader, void *) = nullptr; @@ -194,6 +193,8 @@ class ClientInterface : private virtual slsDetectorDefs { pid_t tcpThreadId{0}; std::vector udpips = std::vector(MAX_NUMBER_OF_LISTENING_THREADS); + // necessary if Receiver objects using threads with callbacks + static std::mutex callbackMutex; }; } // namespace sls diff --git a/slsReceiverSoftware/src/FrameSynchronizerApp.cpp b/slsReceiverSoftware/src/FrameSynchronizerApp.cpp new file mode 100644 index 000000000..790a30b7b --- /dev/null +++ b/slsReceiverSoftware/src/FrameSynchronizerApp.cpp @@ -0,0 +1,621 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +/* Creates the slsFrameSynchronizer for running multiple receivers in different + * threads form a single binary that will spit out zmq streams without + * reconstructing image. Sample python script for pull socket for this combiner + * in python/scripts folder. TODO: Not handling empty frames from one socket + */ +#include "sls/Receiver.h" +#include "sls/ToString.h" +#include "sls/container_utils.h" +#include "sls/logger.h" +#include "sls/sls_detector_defs.h" + +#include //SIGINT +#include +#include +#include +#include +#include +#include +#include +#include //wait +#include +#include + +#include +#include +#include + +std::vector threads; +std::vector semaphores; +sls::TLogLevel printHeadersLevel = sls::logDEBUG; + +/** Define Colors to print data call back in different colors for different + * recievers */ +#define PRINT_IN_COLOR(c, f, ...) \ + printf("\033[%dm" f RESET, 30 + c + 1, ##__VA_ARGS__) + +/** Structure handling different threads */ +using ZmqMsgList = std::vector; +using FrameMap = std::map; +using PortFrameMap = std::map; +struct FrameStatus { + bool starting = true; + bool terminate = false; + int num_receivers; + sem_t available; + std::mutex mtx; + ZmqMsgList headers; + PortFrameMap frames; + ZmqMsgList ends; + + FrameStatus(bool start, bool term, int num_recv) + : starting(start), terminate(term), num_receivers(num_recv) { + sem_init(&available, 0, 0); + } +}; +FrameStatus *global_frame_status = nullptr; + +/** + * Control+C Interrupt Handler + * to let all the processes know to exit properly + */ +void sigInterruptHandler(int p) { + for (size_t i = 0; i != semaphores.size(); ++i) { + sem_post(semaphores[i]); + } +} + +void cleanup() { + if (global_frame_status) { + std::lock_guard lock(global_frame_status->mtx); + for (auto &outer_pair : global_frame_status->frames) { + for (auto &inner_pair : outer_pair.second) { + for (zmq_msg_t *msg : inner_pair.second) { + if (msg) { + zmq_msg_close(msg); + delete msg; + } + } + inner_pair.second.clear(); + } + outer_pair.second.clear(); + } + global_frame_status->frames.clear(); + } +} + +/** + * prints usage of this example program + */ +std::string getHelpMessage() { + std::ostringstream os; + os << "\nUsage:\n" + "./slsFrameSynchronizer [start tcp port] [num recevers] [print " + "callback headers (optional)]\n" + << "\t - tcp port has to be non-zero and 16 bit\n" + << "\t - print callback headers option is 0 (disabled) by default\n"; + return os.str(); +} + +void zmq_free(void *data, void *hint) { delete[] static_cast(data); } + +void print_frames(const PortFrameMap &frame_port_map) { + LOG(sls::logDEBUG) << "Printing frames"; + for (const auto &it : frame_port_map) { + uint16_t udpPort = it.first; + const auto &frame_map = it.second; + LOG(sls::logDEBUG) << "UDP port: " << udpPort; + for (const auto &frame : frame_map) { + uint64_t fnum = frame.first; + const auto &msg_list = frame.second; + LOG(sls::logDEBUG) + << " acq index: " << fnum << '[' << msg_list.size() << ']'; + } + } +} + +/** Valid frame numbers mean they exist across all ports or + * has at least a larger fnum in the port with the missing fnum **/ +std::set get_valid_fnums(const PortFrameMap &port_frame_map) { + // empty list + std::set valid_fnums; + if (port_frame_map.empty()) { + return valid_fnums; + } + + // collect all unique frame numbers from all ports + std::set unique_fnums; + for (auto it = port_frame_map.begin(); it != port_frame_map.begin(); ++it) { + const FrameMap &frame_map = it->second; + for (auto frame = frame_map.begin(); frame != frame_map.end(); + ++frame) { + unique_fnums.insert(frame->first); + } + } + + // collect valid frame numbers + for (auto &fnum : unique_fnums) { + bool is_valid = true; + for (auto it = port_frame_map.begin(); it != port_frame_map.end(); + ++it) { + uint16_t port = it->first; + const FrameMap &frame_map = it->second; + auto frame = frame_map.find(fnum); + // invalid: fnum missing in one port + if (frame == frame_map.end()) { + LOG(sls::logDEBUG) + << "Fnum " << fnum << " is missing in port " << port; + // invalid: fnum greater than all in that port + auto last_frame = std::prev(frame_map.end()); + auto last_fnum = last_frame->first; + if (fnum > last_fnum) { + LOG(sls::logDEBUG) << "And no larger fnum found. Fnum " + << fnum << " is invalid.\n"; + is_valid = false; + break; + } + } + } + if (is_valid) { + valid_fnums.insert(fnum); + } + } + + return valid_fnums; +} + +int zmq_send_multipart(void *socket, const ZmqMsgList &messages) { + size_t num_messages = messages.size(); + for (size_t i = 0; i != num_messages; ++i) { + zmq_msg_t *msg = messages[i]; + // determine flags: ZMQ_SNDMORE for all messages except the last + int flags = (i == num_messages - 1) ? 0 : ZMQ_SNDMORE; + if (zmq_msg_send(msg, socket, flags) == -1) { + LOG(sls::logERROR) + << "Error sending message: " << zmq_strerror(zmq_errno()); + return slsDetectorDefs::FAIL; + } + } + return slsDetectorDefs::OK; +} + +void Correlate(FrameStatus *stat) { + void *context = zmq_ctx_new(); + + void *socket = zmq_socket(context, ZMQ_PUSH); + int rc = zmq_bind(socket, "tcp://*:5555"); + if (rc != 0) { + LOG(sls::logERROR) << "failed to bind"; + } + + while (true) { + sem_wait(&(stat->available)); + { + std::lock_guard lock(stat->mtx); + + if (stat->terminate) { + break; + } + + if (stat->starting) { + // sending all start packets + if (static_cast(stat->headers.size()) == + stat->num_receivers) { + stat->starting = false; + // clean up + zmq_send_multipart(socket, stat->headers); + for (zmq_msg_t *msg : stat->headers) { + if (msg) { + zmq_msg_close(msg); + delete msg; + } + } + stat->headers.clear(); + } + } else { + // print_frames(stat->frames); + auto valid_fnums = get_valid_fnums(stat->frames); + // sending all valid fnum data packets + for (const auto &fnum : valid_fnums) { + ZmqMsgList msg_list; + PortFrameMap &port_frame_map = stat->frames; + for (auto it = port_frame_map.begin(); + it != port_frame_map.end(); ++it) { + uint16_t port = it->first; + const FrameMap &frame_map = it->second; + auto frame = frame_map.find(fnum); + if (frame != frame_map.end()) { + msg_list.insert(msg_list.end(), + stat->frames[port][fnum].begin(), + stat->frames[port][fnum].end()); + // clean up + for (zmq_msg_t *msg : stat->frames[port][fnum]) { + if (msg) { + zmq_msg_close(msg); + delete msg; + } + } + stat->frames[port].erase(fnum); + } + } + LOG(printHeadersLevel) + << "Sending data packets for fnum " << fnum; + zmq_send_multipart(socket, msg_list); + } + } + // sending all end packets + if (static_cast(stat->ends.size()) == stat->num_receivers) { + zmq_send_multipart(socket, stat->ends); + // clean up + for (zmq_msg_t *msg : stat->ends) { + if (msg) { + zmq_msg_close(msg); + delete msg; + } + } + stat->ends.clear(); + } + } + } + zmq_close(socket); + zmq_ctx_destroy(context); +} + +void StartAcquisitionCallback( + const slsDetectorDefs::startCallbackHeader callbackHeader, + void *objectPointer) { + LOG(printHeadersLevel) + << "Start Acquisition:" + << "\n\t[" + << "\n\tUDP Port : " << sls::ToString(callbackHeader.udpPort) + << "\n\tDynamic Range : " << callbackHeader.dynamicRange + << "\n\tDetector Shape : " + << sls::ToString(callbackHeader.detectorShape) + << "\n\tImage Size : " << callbackHeader.imageSize + << "\n\tFile Path : " << callbackHeader.filePath + << "\n\tFile Name : " << callbackHeader.fileName + << "\n\tFile Index : " << callbackHeader.fileIndex + << "\n\tQuad Enable : " << callbackHeader.quad + << "\n\tAdditional Json Header : " + << sls::ToString(callbackHeader.addJsonHeader).c_str() << "\n\t]"; + std::ostringstream oss; + oss << "{\"htype\":\"header\"" + << ", \"udpPorts\":" << sls::ToString(callbackHeader.udpPort) + << ", \"bitmode\":" << callbackHeader.dynamicRange + << ", \"filePath\":\"" << callbackHeader.filePath + << "\", \"fileName\":\"" << callbackHeader.fileName + << "\", \"fileIndex\":" << callbackHeader.fileIndex + << ", \"detshape\":" << sls::ToString(callbackHeader.detectorShape) + << ", \"size\":" << callbackHeader.imageSize + << ", \"quad\":" << (callbackHeader.quad ? 1 : 0); + + if (!callbackHeader.addJsonHeader.empty()) { + oss << ", \"addJsonHeader\": {"; + for (auto it = callbackHeader.addJsonHeader.begin(); + it != callbackHeader.addJsonHeader.end(); ++it) { + if (it != callbackHeader.addJsonHeader.begin()) { + oss << ", "; + } + oss << "\"" << it->first.c_str() << "\":\"" << it->second.c_str() + << "\""; + } + oss << " } "; + } + oss << "}\n"; + + std::string message = oss.str(); + LOG(sls::logDEBUG) << "Start Acquisition message:" << std::endl << message; + + int length = message.length(); + char *hdata = new char[length]; + memcpy(hdata, message.c_str(), length); + zmq_msg_t *hmsg = new zmq_msg_t; + zmq_msg_init_data(hmsg, hdata, length, zmq_free, NULL); + + // push zmq msg into stat to be processed + FrameStatus *stat = static_cast(objectPointer); + { + std::lock_guard lock(stat->mtx); + stat->headers.push_back(hmsg); + stat->starting = true; + // clean up old frames + for (int port : callbackHeader.udpPort) { + for (auto &frame_map : stat->frames[port]) { + for (zmq_msg_t *msg : frame_map.second) { + if (msg) { + zmq_msg_close(msg); + delete msg; + } + } + frame_map.second.clear(); + } + stat->frames[port].clear(); + } + } + sem_post(&stat->available); +} + +void AcquisitionFinishedCallback( + const slsDetectorDefs::endCallbackHeader callbackHeader, + void *objectPointer) { + LOG(printHeadersLevel) << "Acquisition Finished:" + << "\n\t[" + << "\n\tUDP Port : " + << sls::ToString(callbackHeader.udpPort) + << "\n\tComplete Frames : " + << sls::ToString(callbackHeader.completeFrames) + << "\n\tLast Frame Index : " + << sls::ToString(callbackHeader.lastFrameIndex) + << "\n\t]"; + std::ostringstream oss; + oss << "{\"htype\":\"series_end\"" + << ", \"udpPorts\":" << sls::ToString(callbackHeader.udpPort) + << ", \"comleteFrames\":" + << sls::ToString(callbackHeader.completeFrames) + << ", \"lastFrameIndex\":" + << sls::ToString(callbackHeader.lastFrameIndex) << "}\n"; + std::string message = oss.str(); + int length = message.length(); + LOG(sls::logDEBUG) << "Acquisition Finished message:" << std::endl + << message; + + char *hdata = new char[length]; + memcpy(hdata, message.c_str(), length); + zmq_msg_t *hmsg = new zmq_msg_t; + zmq_msg_init_data(hmsg, hdata, length, zmq_free, NULL); + + // push zmq msg into stat to be processed + FrameStatus *stat = static_cast(objectPointer); + { + std::lock_guard lock(stat->mtx); + stat->ends.push_back(hmsg); + } + sem_post(&stat->available); +} + +void GetDataCallback(slsDetectorDefs::sls_receiver_header &header, + slsDetectorDefs::dataCallbackHeader callbackHeader, + char *dataPointer, size_t &imageSize, + void *objectPointer) { + + slsDetectorDefs::sls_detector_header detectorHeader = header.detHeader; + + if (printHeadersLevel < sls::logDEBUG) { + // print in different color for each udp port + PRINT_IN_COLOR((callbackHeader.udpPort % 10), + "Data: " + "\n\tCallback Header: " + "\n\t[" + "\n\tUDP Port: %u" + "\n\tShape: [%u, %u]" + "\n\tAcq Index : %lu" + "\n\tFrame Index :%lu" + "\n\tProgress : %.2f%%" + "\n\tComplete Image :%s" + "\n\tFlip Rows :%s" + "\n\tAdditional Json Header : %s" + "\n\t]" + "\n\ttReceiver Header: " + "\n\t[" + "\n\tFrame Number : %lu" + "\n\tExposure Length :%u" + "\n\tPackets Caught :%u" + "\n\tDetector Specific 1: %lu" + "\n\tTimestamp : %lu" + "\n\tModule Id :%u" + "\n\tRow : %u" + "\n\tColumn :%u" + "\n\tDetector Specific 2 : %u" + "\n\tDetector Specific 3 : %u" + "\n\tDetector Specific 4 : %u" + "\n\tDetector Type : %s" + "\n\tVersion: %u" + "\n\t]" + "\n\tFirst Byte Data: 0x%x" + "\n\tImage Size: %zu\n\n", + callbackHeader.udpPort, callbackHeader.shape.x, + callbackHeader.shape.y, callbackHeader.acqIndex, + callbackHeader.frameIndex, callbackHeader.progress, + sls::ToString(callbackHeader.completeImage).c_str(), + sls::ToString(callbackHeader.flipRows).c_str(), + sls::ToString(callbackHeader.addJsonHeader).c_str(), + detectorHeader.frameNumber, detectorHeader.expLength, + detectorHeader.packetNumber, detectorHeader.detSpec1, + detectorHeader.timestamp, detectorHeader.modId, + detectorHeader.row, detectorHeader.column, + detectorHeader.detSpec2, detectorHeader.detSpec3, + detectorHeader.detSpec4, + sls::ToString(detectorHeader.detType).c_str(), + detectorHeader.version, + // header->packetsMask.to_string().c_str(), + ((uint8_t)(*((uint8_t *)(dataPointer)))), imageSize); + } + std::ostringstream oss; + oss << "{\"htype\":\"module\"" + << ", \"port\":" << callbackHeader.udpPort + << ", \"shape\":" << sls::ToString(callbackHeader.shape) + << ", \"acqIndex\":" << callbackHeader.acqIndex + << ", \"frameIndex\":" << callbackHeader.frameIndex + << ", \"flipRows\":" << (callbackHeader.flipRows ? 1 : 0) + << ", \"progress\":" << callbackHeader.progress + << ", \"completeImage\":" << (callbackHeader.completeImage ? 1 : 0) + << ", \"imageSize\":" << imageSize + << ", \"frameNumber\":" << detectorHeader.frameNumber + << ", \"expLength\":" << detectorHeader.expLength + << ", \"packetNumber\":" << detectorHeader.packetNumber + << ", \"detSpec1\":" << detectorHeader.detSpec1 + << ", \"timestamp\":" << detectorHeader.timestamp + << ", \"modId\":" << detectorHeader.modId + << ", \"row\":" << detectorHeader.row + << ", \"column\":" << detectorHeader.column + << ", \"detSpec2\":" << detectorHeader.detSpec2 + << ", \"detSpec3\":" << detectorHeader.detSpec3 + << ", \"detSpec4\":" << detectorHeader.detSpec4 + << ", \"detType\":" << static_cast(detectorHeader.detType) + << ", \"version\":" << static_cast(detectorHeader.version); + + if (!callbackHeader.addJsonHeader.empty()) { + oss << ", \"addJsonHeader\": {"; + for (auto it = callbackHeader.addJsonHeader.begin(); + it != callbackHeader.addJsonHeader.end(); ++it) { + if (it != callbackHeader.addJsonHeader.begin()) { + oss << ", "; + } + oss << "\"" << it->first.c_str() << "\":\"" << it->second.c_str() + << "\""; + } + oss << " } "; + } + oss << "}\n"; + std::string message = oss.str(); + LOG(sls::logDEBUG) << "Data message:" << std::endl << message; + + // creating header part of data packet + int length = message.length(); + char *hdata = new char[length]; + memcpy(hdata, message.c_str(), length); + zmq_msg_t *hmsg = new zmq_msg_t; + zmq_msg_init_data(hmsg, hdata, length, zmq_free, NULL); + + // created data part of data packet + char *data = new char[imageSize]; + zmq_msg_t *msg = new zmq_msg_t; + zmq_msg_init_data(msg, data, imageSize, zmq_free, NULL); + + // push both parts into stat to be processed + FrameStatus *stat = static_cast(objectPointer); + { + std::lock_guard lock(stat->mtx); + stat->frames[callbackHeader.udpPort][header.detHeader.frameNumber] + .push_back(hmsg); + stat->frames[callbackHeader.udpPort][header.detHeader.frameNumber] + .push_back(msg); + } + sem_post(&stat->available); +} + +/** + * Example of main program using the Receiver class + * + * - Defines in file for: + * - Default Number of receivers is 1 + * - Default Start TCP port is 1954 + */ +int main(int argc, char *argv[]) { + + /** - set default values */ + int numReceivers = 1; + uint16_t startTCPPort = DEFAULT_TCP_RX_PORTNO; + bool printHeaders = false; + + /** - get number of receivers and start tcp port from command line + * arguments */ + if (argc > 1) { + try { + if (argc == 3 || argc == 4) { + startTCPPort = sls::StringTo(argv[1]); + if (startTCPPort == 0) { + throw std::runtime_error("Invalid start tcp port"); + } + numReceivers = std::stoi(argv[2]); + if (numReceivers > 1024) { + cprintf(RED, + "Did you mix up the order of the arguments?\n%s\n", + getHelpMessage().c_str()); + return EXIT_FAILURE; + } + if (numReceivers == 0) { + cprintf(RED, "Invalid number of receivers.\n%s\n", + getHelpMessage().c_str()); + return EXIT_FAILURE; + } + if (argc == 4) { + printHeaders = sls::StringTo(argv[3]); + if (printHeaders) { + printHeadersLevel = sls::logINFOBLUE; + } + } + } else + throw std::runtime_error("Invalid number of arguments"); + } catch (const std::exception &e) { + cprintf(RED, "Error: %s\n%s\n", e.what(), getHelpMessage().c_str()); + return EXIT_FAILURE; + } + } + + cprintf(RESET, "Number of Receivers: %d\n", numReceivers); + cprintf(RESET, "Start TCP Port: %hu\n", startTCPPort); + cprintf(RESET, "Print Callback Headers: %s\n\n", + (printHeaders ? "Enabled" : "Disabled")); + + /** - Catch signal SIGINT to close files and call destructors properly */ + struct sigaction sa; + sa.sa_flags = 0; // no flags + sa.sa_handler = sigInterruptHandler; // handler function + sigemptyset(&sa.sa_mask); // dont block additional signals during invocation + // of handler + if (sigaction(SIGINT, &sa, nullptr) == -1) { + cprintf(RED, "Could not set handler function for SIGINT\n"); + } + + /** - Ignore SIG_PIPE, prevents global signal handler, handle locally, + instead of a server crashing due to client crash when writing, it just + gives error */ + struct sigaction asa; + asa.sa_flags = 0; // no flags + asa.sa_handler = SIG_IGN; // handler function + sigemptyset(&asa.sa_mask); // dont block additional signals during + // invocation of handler + if (sigaction(SIGPIPE, &asa, nullptr) == -1) { + cprintf(RED, "Could not set handler function for SIGPIPE\n"); + } + + FrameStatus stat{true, false, numReceivers}; + // store pointer for signal handler + global_frame_status = &stat; + + // thread synchronizing all packets + void *user_data = static_cast(&stat); + std::thread combinerThread(Correlate, &stat); + + for (int i = 0; i != numReceivers; ++i) { + sem_t *semaphore = new sem_t; + sem_init(semaphore, 1, 0); + semaphores.push_back(semaphore); + + uint16_t port = startTCPPort + i; + threads.emplace_back([i, semaphore, port, user_data]() { + sls::Receiver receiver(port); + receiver.registerCallBackStartAcquisition(StartAcquisitionCallback, + user_data); + receiver.registerCallBackAcquisitionFinished( + AcquisitionFinishedCallback, user_data); + receiver.registerCallBackRawDataReady(GetDataCallback, user_data); + /** - as long as no Ctrl+C */ + sem_wait(semaphore); + sem_destroy(semaphore); + delete semaphore; + + // clean up frames + if (i == 0) + cleanup(); + }); + } + + for (auto &thread : threads) { + thread.join(); + } + + { + std::lock_guard lock(stat.mtx); + stat.terminate = true; + sem_post(&stat.available); + } + combinerThread.join(); + sem_destroy(&stat.available); + + LOG(sls::logINFOBLUE) << "Goodbye!"; + return EXIT_SUCCESS; +} diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index f7aed96ef..dbacf6eaf 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -1802,7 +1802,7 @@ void Implementation::setTransceiverEnableMask(uint32_t mask) { * * * ************************************************/ void Implementation::registerCallBackStartAcquisition( - int (*func)(const startCallbackHeader, void *), void *arg) { + void (*func)(const startCallbackHeader, void *), void *arg) { startAcquisitionCallBack = func; pStartAcquisition = arg; } diff --git a/slsReceiverSoftware/src/Implementation.h b/slsReceiverSoftware/src/Implementation.h index 671f6deb2..d32b491ea 100644 --- a/slsReceiverSoftware/src/Implementation.h +++ b/slsReceiverSoftware/src/Implementation.h @@ -265,9 +265,8 @@ class Implementation : private virtual slsDetectorDefs { * * * ************************************************/ /** params: file path, file name, file index, image size */ - void registerCallBackStartAcquisition(int (*func)(const startCallbackHeader, - void *), - void *arg); + void registerCallBackStartAcquisition( + void (*func)(const startCallbackHeader, void *), void *arg); /** params: total frames caught */ void registerCallBackAcquisitionFinished( void (*func)(const endCallbackHeader, void *), void *arg); @@ -374,7 +373,8 @@ class Implementation : private virtual slsDetectorDefs { int ctbDbitOffset{0}; // callbacks - int (*startAcquisitionCallBack)(const startCallbackHeader, void *){nullptr}; + void (*startAcquisitionCallBack)(const startCallbackHeader, + void *){nullptr}; void *pStartAcquisition{nullptr}; void (*acquisitionFinishedCallBack)(const endCallbackHeader, void *){nullptr}; diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp index 7dac8952a..9bf3742a1 100644 --- a/slsReceiverSoftware/src/Listener.cpp +++ b/slsReceiverSoftware/src/Listener.cpp @@ -149,12 +149,12 @@ void Listener::CreateUDPSocket(int &actualSize) { packetSize = generalData->vetoPacketSize; } - std::string ip = - (eth.length() ? InterfaceNameToIp(eth).str().c_str() : ""); - + std::string ip; + if (eth.length() > 0) + ip = InterfaceNameToIp(eth).str(); udpSocket = nullptr; udpSocket = make_unique( - udpPortNumber, packetSize, (ip.length() ? ip.c_str() : nullptr), + udpPortNumber, packetSize, (ip.empty() ? nullptr : ip.c_str()), generalData->udpSocketBufferSize); LOG(logINFO) << index << ": UDP port opened at port " << udpPortNumber << " (" << (ip.length() ? ip : "any") << ')'; @@ -213,10 +213,13 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int &actualSize) { try { // to allowe ports to be bound from udpsocket udpSocket.reset(); - UdpRxSocket g( - udpPortNumber, packetSize, - (eth.length() ? InterfaceNameToIp(eth).str().c_str() : nullptr), - generalData->udpSocketBufferSize); + + std::string ip; + if (eth.length() > 0) + ip = InterfaceNameToIp(eth).str(); + UdpRxSocket g(udpPortNumber, packetSize, + (ip.empty() ? nullptr : ip.c_str()), + generalData->udpSocketBufferSize); // doubled due to kernel bookkeeping (could also be less due to // permissions) diff --git a/slsReceiverSoftware/src/MultiReceiverApp.cpp b/slsReceiverSoftware/src/MultiReceiverApp.cpp index 7e6b3656b..061c9a441 100644 --- a/slsReceiverSoftware/src/MultiReceiverApp.cpp +++ b/slsReceiverSoftware/src/MultiReceiverApp.cpp @@ -53,8 +53,8 @@ std::string getHelpMessage() { * enabled) if registerCallBackRawDataReady or * registerCallBackRawDataModifyReady registered, users get data */ -int StartAcq(const slsDetectorDefs::startCallbackHeader callbackHeader, - void *objectPointer) { +void StartAcq(const slsDetectorDefs::startCallbackHeader callbackHeader, + void *objectPointer) { LOG(sls::logINFOBLUE) << "#### Start Acquisition:" << "\n\t[" << "\n\tUDP Port : " @@ -71,7 +71,6 @@ int StartAcq(const slsDetectorDefs::startCallbackHeader callbackHeader, << "\n\tAdditional Json Header : " << sls::ToString(callbackHeader.addJsonHeader) << "\n\t]"; - return 0; } /** Acquisition Finished Call back */ diff --git a/slsReceiverSoftware/src/Receiver.cpp b/slsReceiverSoftware/src/Receiver.cpp index d7c676366..d2d5593d5 100644 --- a/slsReceiverSoftware/src/Receiver.cpp +++ b/slsReceiverSoftware/src/Receiver.cpp @@ -134,7 +134,7 @@ std::string Receiver::getReceiverVersion() { } void Receiver::registerCallBackStartAcquisition( - int (*func)(const startCallbackHeader, void *), void *arg) { + void (*func)(const startCallbackHeader, void *), void *arg) { tcpipInterface->registerCallBackStartAcquisition(func, arg); } diff --git a/slsSupportLib/include/sls/logger.h b/slsSupportLib/include/sls/logger.h index 437f7e905..9b949d802 100644 --- a/slsSupportLib/include/sls/logger.h +++ b/slsSupportLib/include/sls/logger.h @@ -16,6 +16,8 @@ enum TLogLevel { logINFOBLUE, logINFOGREEN, logINFORED, + logINFOCYAN, + logINFOMAGENTA, logINFO, logDEBUG, logDEBUG1, @@ -60,16 +62,25 @@ class Logger { // Danger this buffer need as many elements as TLogLevel static const char *Color(TLogLevel level) noexcept { static const char *const colors[] = { - RED BOLD, YELLOW BOLD, BLUE, GREEN, RED, RESET, - RESET, RESET, RESET, RESET, RESET, RESET}; + RED BOLD, YELLOW BOLD, BLUE, GREEN, RED, CYAN, MAGENTA, + RESET, RESET, RESET, RESET, RESET, RESET, RESET}; + // out of bounds + if (level < 0 || level >= sizeof(colors) / sizeof(colors[0])) { + return RESET; + } return colors[level]; } // Danger this buffer need as many elements as TLogLevel static std::string ToString(TLogLevel level) { static const char *const buffer[] = { - "ERROR", "WARNING", "INFO", "INFO", "INFO", "INFO", - "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4", "DEBUG5"}; + "ERROR", "WARNING", "INFO", "INFO", "INFO", + "INFO", "INFO", "INFO", "DEBUG", "DEBUG1", + "DEBUG2", "DEBUG3", "DEBUG4", "DEBUG5"}; + // out of bounds + if (level < 0 || level >= sizeof(buffer) / sizeof(buffer[0])) { + return "UNKNOWN"; + } return buffer[level]; } diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 649399f08..666ea2628 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -5,9 +5,9 @@ #define APIGOTTHARD2 "developer 0x241107" #define APIMOENCH "developer 0x241107" #define APIEIGER "developer 0x241107" -#define APIJUNGFRAU "developer 0x241120" #define APILIB "developer 0x241122" #define APIRECEIVER "developer 0x241122" -#define APIXILINXCTB "developer 0x250131" #define APICTB "developer 0x250131" -#define APIMYTHEN3 "developer 0x250131" +#define APIXILINXCTB "developer 0x250213" +#define APIJUNGFRAU "developer 0x250224" +#define APIMYTHEN3 "developer 0x250304"