diff --git a/.github/workflows/cmake.yaml b/.github/workflows/cmake.yaml index c6903502b..10674332e 100644 --- a/.github/workflows/cmake.yaml +++ b/.github/workflows/cmake.yaml @@ -1,6 +1,6 @@ name: Native CMake Build -on: [push, pull_request, workflow_dispatch] +on: [push, workflow_dispatch] env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) diff --git a/.github/workflows/rh8-local-tests.yaml b/.github/workflows/rh8-local-tests.yaml index c4eb0aabc..6c5a66bf4 100644 --- a/.github/workflows/rh8-local-tests.yaml +++ b/.github/workflows/rh8-local-tests.yaml @@ -4,6 +4,11 @@ on: pull_request: workflow_dispatch: +# Cancel older runs of this workflow for the same PR/branch when a new push arrives +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Debug diff --git a/.github/workflows/rh8-nfs-deploy.yaml b/.github/workflows/rh8-nfs-deploy.yaml index 2d275dc0c..4112ce6da 100644 --- a/.github/workflows/rh8-nfs-deploy.yaml +++ b/.github/workflows/rh8-nfs-deploy.yaml @@ -27,6 +27,6 @@ jobs: - name: Deploy to NFS update server if: github.ref == 'refs/heads/developer' run: | - sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH8 <<< $'put build/bin' - sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH8 <<< $'put pyctbgui' - sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH8 <<< $'put slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer' \ No newline at end of file + cp -r build/bin /home/github_runner/slsDetectorSoftware/RH8 + cp slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer /home/github_runner/slsDetectorSoftware/RH8 + cp -r pyctbgui /home/github_runner/slsDetectorSoftware/RH8 \ No newline at end of file diff --git a/.github/workflows/rh9-local-tests.yaml b/.github/workflows/rh9-local-tests.yaml index 9671df226..38ff6fea1 100644 --- a/.github/workflows/rh9-local-tests.yaml +++ b/.github/workflows/rh9-local-tests.yaml @@ -4,6 +4,10 @@ on: pull_request: workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Debug diff --git a/.github/workflows/rh9-nfs-deploy.yaml b/.github/workflows/rh9-nfs-deploy.yaml index 5234f9fd3..745ede055 100644 --- a/.github/workflows/rh9-nfs-deploy.yaml +++ b/.github/workflows/rh9-nfs-deploy.yaml @@ -18,7 +18,6 @@ jobs: - name: Build library run: | mkdir build && cd build - conda activate det cmake .. -DSLS_USE_PYTHON=ON -DSLS_USE_SIMULATOR=ON -DSLS_USE_GUI=ON make -j 2 diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index 4941442b6..fc307c073 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index 0ef6c3721..36580b198 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -2193,10 +2193,9 @@ int configureMAC() { calcChecksum(udp); // force FPGA writes to be aligned and in order - uint32_t words[sizeof(udp_header) / sizeof(uint32_t)]; - memcpy(words, udp, sizeof(udp_header)); - for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { - bus_w(addr + i * 2, words[i]); + if (bus_w_block(addr, udp, sizeof(udp_header), false) == FAIL) { + LOG(logERROR, ("Failed to write UDP header\n")); + return FAIL; } cleanFifos(); // FIXME: resetPerpheral() for ctb? diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index e58bac667..7cf885bdf 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index 3fa7a1b35..7005516e2 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 50d148b06..dd9d82ede 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -2041,9 +2041,9 @@ void setFirstUDPDestination(int value) { PKT_CONFIG_RXR_START_ID_MSK)); } -void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip, - uint64_t destmac, uint16_t destport, uint64_t sourcemac, - uint32_t sourceip, uint16_t sourceport) { +int setupHeader(int iRxEntry, int vetoInterface, uint32_t destip, + uint64_t destmac, uint16_t destport, uint64_t sourcemac, + uint32_t sourceip, uint16_t sourceport) { // start addr uint32_t addr = BASE_UDP_RAM; @@ -2087,15 +2087,15 @@ void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip, calcChecksum(udp); // force FPGA writes to be aligned and in order - uint32_t words[sizeof(udp_header) / sizeof(uint32_t)]; - memcpy(words, udp, sizeof(udp_header)); - for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { - bus_w(addr + i * sizeof(uint32_t), words[i]); + if (bus_w_block(addr, udp, sizeof(udp_header), false) == FAIL) { + LOG(logERROR, ("Failed to write UDP header\n")); + return FAIL; } if (iRxEntry < numUdpDestinations) { LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum)); } + return OK; } void calcChecksum(udp_header *udp) { @@ -2209,13 +2209,23 @@ int configureMAC() { } #endif // data - setupHeader(iRxEntry, 0, dstip, dstmac, dstport, srcmac, srcip, - srcport); + if (setupHeader(iRxEntry, 0, dstip, dstmac, dstport, srcmac, srcip, + srcport) == FAIL) { + LOG(logERROR, ("could not set udp destination IP and port for " + "data interface [entry:%d] \n", + iRxEntry)); + return FAIL; + } // veto if (i10gbe) { - setupHeader(iRxEntry, 1, dstip2, dstmac2, dstport2, srcmac2, srcip2, - srcport2); + if (setupHeader(iRxEntry, 1, dstip2, dstmac2, dstport2, srcmac2, + srcip2, srcport2) == FAIL) { + LOG(logERROR, ("could not set udp destination IP and port for " + "veto interface [entry:%d] \n", + iRxEntry)); + return FAIL; + } } } cleanFifos(); @@ -2364,6 +2374,7 @@ int powerChip(bool on, char *mess) { if (on) { LOG(logINFO, ("Powering chip: on\n")); bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_PWR_CHIP_MSK); + usleep(50 * 1000); // wait for chip to be ready if (configureChip(mess) == FAIL) return FAIL; } else { diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.h index 124a058f8..ace6a6176 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.h @@ -146,6 +146,9 @@ int getNumberofDestinations(int *retval); int setNumberofDestinations(int value); int getFirstUDPDestination(); void setFirstUDPDestination(int value); +int setupHeader(int iRxEntry, int vetoInterface, uint32_t destip, + uint64_t destmac, uint16_t destport, uint64_t sourcemac, + uint32_t sourceip, uint16_t sourceport); void calcChecksum(udp_header *udp); int configureMAC(); int setDetectorPosition(int pos[]); diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index dffd0ef53..c09610a80 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 df7de6200..559509f53 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -1859,9 +1859,9 @@ int getPrimaryInterface() { return ((bus_r(CONFIG_REG) & CONFIG_INNR_PRIMRY_INTRFCE_MSK) ? 1 : 0); } -void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, - uint64_t destmac, uint16_t destport, uint64_t sourcemac, - uint32_t sourceip, uint16_t sourceport) { +int setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, + uint64_t destmac, uint16_t destport, uint64_t sourcemac, + uint32_t sourceip, uint16_t sourceport) { // start addr uint32_t addr = (type == INNER ? RXR_ENDPOINT_INNER_START_REG @@ -1903,15 +1903,15 @@ void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, calcChecksum(udp); // force FPGA writes to be aligned and in order - uint32_t words[sizeof(udp_header) / sizeof(uint32_t)]; - memcpy(words, udp, sizeof(udp_header)); - for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { - bus_w(addr + i * 2, words[i]); + if (bus_w_block(addr, udp, sizeof(udp_header), false) == FAIL) { + LOG(logERROR, ("Failed to write UDP header\n")); + return FAIL; } if (iRxEntry < numUdpDestinations) { LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum)); } + return OK; } void calcChecksum(udp_header *udp) { @@ -2028,21 +2028,41 @@ int configureMAC() { #endif if (numInterfaces == 2) { // bottom - setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, srcip, - srcport); + if (setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, + srcip, srcport) == FAIL) { + LOG(logERROR, ("could not set udp header for outer interface " + "[entry:%d]\n", + iRxEntry)); + return FAIL; + } // top - setupHeader(iRxEntry, INNER, dstip2, dstmac2, dstport2, srcmac2, - srcip2, srcport2); + if (setupHeader(iRxEntry, INNER, dstip2, dstmac2, dstport2, srcmac2, + srcip2, srcport2) == FAIL) { + LOG(logERROR, ("could not set udp header for inner interface " + "[entry:%d]\n", + iRxEntry)); + return FAIL; + } } // single interface else { // default if (selInterface == 0) { - setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, - srcip, srcport); + if (setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, + srcip, srcport) == FAIL) { + LOG(logERROR, ("could not set udp header for outer " + "interface [entry:%d]\n", + iRxEntry)); + return FAIL; + } } else { - setupHeader(iRxEntry, INNER, dstip, dstmac, dstport, srcmac, - srcip, srcport2); + if (setupHeader(iRxEntry, INNER, dstip, dstmac, dstport, srcmac, + srcip, srcport2) == FAIL) { + LOG(logERROR, ("could not set udp header for inner " + "interface [entry:%d]\n", + iRxEntry)); + return FAIL; + } } } } diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.h index ca729cf33..76841d577 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.h @@ -167,9 +167,9 @@ int getFirstUDPDestination(); void setFirstUDPDestination(int value); void selectPrimaryInterface(int val); int getPrimaryInterface(); -void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, - uint64_t destmac, uint16_t destport, uint64_t sourcemac, - uint32_t sourceip, uint16_t sourceport); +int setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, + uint64_t destmac, uint16_t destport, uint64_t sourcemac, + uint32_t sourceip, uint16_t sourceport); void calcChecksum(udp_header *udp); int configureMAC(); diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index 46e044d6d..2174affa6 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index 37cb91edb..e3236b44d 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -1194,9 +1194,9 @@ int getPrimaryInterface() { return ((bus_r(CONFIG_REG) & CONFIG_INNR_PRIMRY_INTRFCE_MSK) ? 1 : 0); } -void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, - uint64_t destmac, uint16_t destport, uint64_t sourcemac, - uint32_t sourceip, uint16_t sourceport) { +int setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, + uint64_t destmac, uint16_t destport, uint64_t sourcemac, + uint32_t sourceip, uint16_t sourceport) { // start addr uint32_t addr = (type == INNER ? RXR_ENDPOINT_INNER_START_REG @@ -1238,15 +1238,15 @@ void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, calcChecksum(udp); // force FPGA writes to be aligned and in order - uint32_t words[sizeof(udp_header) / sizeof(uint32_t)]; - memcpy(words, udp, sizeof(udp_header)); - for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { - bus_w(addr + i * 2, words[i]); + if (bus_w_block(addr, udp, sizeof(udp_header), false) == FAIL) { + LOG(logERROR, ("Failed to write UDP header\n")); + return FAIL; } if (iRxEntry < numUdpDestinations) { LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum)); } + return OK; } void calcChecksum(udp_header *udp) { @@ -1363,21 +1363,41 @@ int configureMAC() { #endif if (numInterfaces == 2) { // bottom - setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, srcip, - srcport); + if (setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, + srcip, srcport) == FAIL) { + LOG(logERROR, ("could not set udp header for outer interface " + "[entry:%d]\n", + iRxEntry)); + return FAIL; + } // top - setupHeader(iRxEntry, INNER, dstip2, dstmac2, dstport2, srcmac2, - srcip2, srcport2); + if (setupHeader(iRxEntry, INNER, dstip2, dstmac2, dstport2, srcmac2, + srcip2, srcport2) == FAIL) { + LOG(logERROR, ("could not set udp header for inner interface " + "[entry:%d]\n", + iRxEntry)); + return FAIL; + } } // single interface else { // default if (selInterface == 0) { - setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, - srcip, srcport); + if (setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, + srcip, srcport) == FAIL) { + LOG(logERROR, ("could not set udp header for outer " + "interface [entry:%d]\n", + iRxEntry)); + return FAIL; + } } else { - setupHeader(iRxEntry, INNER, dstip, dstmac, dstport, srcmac, - srcip, srcport2); + if (setupHeader(iRxEntry, INNER, dstip, dstmac, dstport, srcmac, + srcip, srcport2) == FAIL) { + LOG(logERROR, ("could not set udp header for inner " + "interface [entry:%d]\n", + iRxEntry)); + return FAIL; + } } } } diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.h index ef68e5685..66b25e63a 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.h @@ -147,9 +147,9 @@ int getFirstUDPDestination(); void setFirstUDPDestination(int value); void selectPrimaryInterface(int val); int getPrimaryInterface(); -void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, - uint64_t destmac, uint16_t destport, uint64_t sourcemac, - uint32_t sourceip, uint16_t sourceport); +int setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, + uint64_t destmac, uint16_t destport, uint64_t sourcemac, + uint32_t sourceip, uint16_t sourceport); void calcChecksum(udp_header *udp); int configureMAC(); int setDetectorPosition(int pos[]); diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index d6530e548..a70730fcc 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 8d9bc4881..e0cb517e6 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -2260,10 +2260,9 @@ int configureMAC() { calcChecksum(udp); // force FPGA writes to be aligned and in order - uint32_t words[sizeof(udp_header) / sizeof(uint32_t)]; - memcpy(words, udp, sizeof(udp_header)); - for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { - bus_w(addr + i * sizeof(uint32_t), words[i]); + if (bus_w_block(addr, udp, sizeof(udp_header), false) == FAIL) { + LOG(logERROR, ("Failed to write UDP header\n")); + return FAIL; } if (iRxEntry < numUdpDestinations) { @@ -2421,6 +2420,7 @@ int powerChip(int on) { if (on) { LOG(logINFO, ("Powering chip: on\n")); bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_PWR_CHIP_MSK); + usleep(50 * 1000); // wait for chip to be ready } else { LOG(logINFO, ("Powering chip: off\n")); bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_PWR_CHIP_MSK); diff --git a/slsDetectorServers/slsDetectorServer/include/arm64.h b/slsDetectorServers/slsDetectorServer/include/arm64.h index 3cf3e5aae..b6ee6dafb 100644 --- a/slsDetectorServers/slsDetectorServer/include/arm64.h +++ b/slsDetectorServers/slsDetectorServer/include/arm64.h @@ -3,17 +3,43 @@ #pragma once #include +#include #include +/** csp0base */ void bus_w(u_int32_t offset, u_int32_t data); -void bus_w_csp1(u_int32_t offset, u_int32_t data); -void bus_w_csp2(u_int32_t offset, u_int32_t data); u_int32_t bus_r(u_int32_t offset); + +/** udp header */ +void bus_w_csp1(u_int32_t offset, u_int32_t data); u_int32_t bus_r_csp1(u_int32_t offset); + +void bus_w_csp2(u_int32_t offset, u_int32_t data); u_int32_t bus_r_csp2(u_int32_t offset); + +/** + * Write `size` bytes from `src` to the FPGA as 32-bit words, + * one at a time and in order. + * @param fixedAddress true: every word goes to `offset` (e.g. a FIFO). + * false: words go to consecutive addresses from `offset`. + * @returns OK, or FAIL if `size` is 0 or not a multiple of 4 bytes. + */ +int bus_w_block(u_int32_t offset, const void *src, size_t size, + bool fixedAddress); +int bus_r_block(u_int32_t offset, void *dest, size_t size, bool fixedAddress); + +/** + * Force FPGA writes to be aligned and in order + * by writing 32 bit words to the bus (csp1: udp header) + * @returns FAIL if size is not a non-zero multiple of sizeof(uint32_t), else OK + */ +int bus_w_csp1_block(const void *src, size_t size); + uint64_t getU64BitReg(int aLSB, int aMSB); void setU64BitReg(uint64_t value, int aLSB, int aMSB); + +/** literal register address value provided by client */ u_int32_t readRegister(u_int32_t offset); u_int32_t writeRegister(u_int32_t offset, u_int32_t data); + int mapCSP0(void); -u_int32_t *Arm_getUDPBaseAddress(); diff --git a/slsDetectorServers/slsDetectorServer/include/blackfin.h b/slsDetectorServers/slsDetectorServer/include/blackfin.h index d6a14f134..a9b17d0fa 100644 --- a/slsDetectorServers/slsDetectorServer/include/blackfin.h +++ b/slsDetectorServers/slsDetectorServer/include/blackfin.h @@ -3,6 +3,7 @@ #pragma once #include +#include #include /** enable support for ARDY signal on interface to FPGA @@ -22,102 +23,40 @@ #define BFIN_AMC_ACCESS_EXTENSION_FNAME \ "/sys/kernel/debug/blackfin/ebiu_amc/EBIU_AMBCTL1" -/** - * Write into a 16 bit register - * @param offset address offset - * @param data 16 bit data - */ -void bus_w16(u_int32_t offset, u_int16_t data); +#define I2C_CLOCK_MHZ (131.25) -/** - * Read from a 16 bit register - * @param offset address offset - * @retuns 16 bit data read - */ +/* 16 bit register */ +void bus_w16(u_int32_t offset, u_int16_t data); u_int16_t bus_r16(u_int32_t offset); -/** - * Write into a 32 bit register - * @param offset address offset - * @param data 32 bit data - */ +/** 32 bit register */ void bus_w(u_int32_t offset, u_int32_t data); - -/** - * Read from a 32 bit register - * @param offset address offset - * @retuns 32 bit data read - */ u_int32_t bus_r(u_int32_t offset); /** - * Read from a 64 bit register - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns 64 bit data read + * Write `size` bytes from `src` to the FPGA as 32-bit words, + * one at a time and in order. + * @param fixedAddress true: every word goes to `offset` (e.g. a FIFO). + * false: words go to consecutive addresses from `offset`. + * @returns OK, or FAIL if `size` is 0 or not a multiple of 4 bytes. */ -int64_t get64BitReg(int aLSB, int aMSB); +int bus_w_block(u_int32_t offset, const void *src, size_t size, + bool fixedAddress); +int bus_r_block(u_int32_t offset, void *dest, size_t size, bool fixedAddress); -/** - * Write into a 64 bit register - * @param value 64 bit data - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns 64 bit data read - */ +/** legacy: to be replaced at some point (returns int64_t via tcp) */ +int64_t get64BitReg(int aLSB, int aMSB); int64_t set64BitReg(int64_t value, int aLSB, int aMSB); -/** - * Read unsigned 64 bit from a 64 bit register - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns unsigned 64 bit data read - */ uint64_t getU64BitReg(int aLSB, int aMSB); - -/** - * Write unsigned 64 bit into a 64 bit register - * @param value unsigned 64 bit data - * @param aLSB LSB offset address - * @param aMSB MSB offset address - */ void setU64BitReg(uint64_t value, int aLSB, int aMSB); -/** - * Read from a 32 bit register (literal register value provided by client) - * @param offset address offset - * @retuns 32 bit data read - */ +/** literal register address value provided by client */ u_int32_t readRegister(u_int32_t offset); - -/** - * Write into a 32 bit register (literal register value provided by client) - * @param offset address offset - * @param data 32 bit data - */ void writeRegister(u_int32_t offset, u_int32_t data); - -/** - * Read from a 16 bit register (literal register value provided by client) - * @param offset address offset - * @retuns 16 bit data read - */ u_int32_t readRegister16(u_int32_t offset); - -/** - * Write into a 16 bit register (literal register value provided by client) - * @param offset address offset - * @param data 16 bit data - */ void writeRegister16(u_int32_t offset, u_int32_t data); -/** - * Get base address for memory copy - */ -uint32_t *Blackfin_getBaseAddress(); -/** - * Map FPGA - */ int mapCSP0(void); /** diff --git a/slsDetectorServers/slsDetectorServer/include/nios.h b/slsDetectorServers/slsDetectorServer/include/nios.h index dc1ca24f4..d23862c1d 100644 --- a/slsDetectorServers/slsDetectorServer/include/nios.h +++ b/slsDetectorServers/slsDetectorServer/include/nios.h @@ -3,89 +3,36 @@ #pragma once #include +#include #include -/** - * Write into a 32 bit register for cspbase 1 - * @param offset address offset - * @param data 32 bit data - */ -void bus_w_csp1(u_int32_t offset, u_int32_t data); +/** csp0base */ +void bus_w(u_int32_t offset, u_int32_t data); +u_int32_t bus_r(u_int32_t offset); -/** - * Read from a 32 bit register for cspbase 1 - * @param offset address offset - * @retuns 32 bit data read - */ +void bus_w_csp1(u_int32_t offset, u_int32_t data); u_int32_t bus_r_csp1(u_int32_t offset); /** - * Write into a 32 bit register - * @param offset address offset - * @param data 32 bit data + * Write `size` bytes from `src` to the FPGA as 32-bit words, + * one at a time and in order. + * @param fixedAddress true: every word goes to `offset` (e.g. a FIFO). + * false: words go to consecutive addresses from `offset`. + * @returns OK, or FAIL if `size` is 0 or not a multiple of 4 bytes. */ -void bus_w(u_int32_t offset, u_int32_t data); +int bus_w_block(u_int32_t offset, const void *src, size_t size, + bool fixedAddress); +int bus_r_block(u_int32_t offset, void *dest, size_t size, bool fixedAddress); -/** - * Read from a 32 bit register - * @param offset address offset - * @retuns 32 bit data read - */ -u_int32_t bus_r(u_int32_t offset); - -/** - * Read from a 64 bit register - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns 64 bit data read - */ +/** legacy: to be replaced at some point (returns int64_t via tcp) */ int64_t get64BitReg(int aLSB, int aMSB); - -/** - * Write into a 64 bit register - * @param value 64 bit data - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns 64 bit data read - */ int64_t set64BitReg(int64_t value, int aLSB, int aMSB); -/** - * Read unsigned 64 bit from a 64 bit register - * @param aLSB LSB offset address - * @param aMSB MSB offset address - * @returns unsigned 64 bit data read - */ uint64_t getU64BitReg(int aLSB, int aMSB); - -/** - * Write unsigned 64 bit into a 64 bit register - * @param value unsigned 64 bit data - * @param aLSB LSB offset address - * @param aMSB MSB offset address - */ void setU64BitReg(uint64_t value, int aLSB, int aMSB); -/** - * Read from a 32 bit register (literal register value provided by client) - * @param offset address offset - * @retuns 32 bit data read - */ +/** literal register address value provided by client */ u_int32_t readRegister(u_int32_t offset); - -/** - * Write into a 32 bit register (literal register value provided by client) - * @param offset address offset - * @param data 32 bit data - */ void writeRegister(u_int32_t offset, u_int32_t data); -/** - * Map FPGA - */ int mapCSP0(void); - -/** - * Get Nios base address - */ -u_int32_t *Nios_getBaseAddress(); diff --git a/slsDetectorServers/slsDetectorServer/src/arm64.c b/slsDetectorServers/slsDetectorServer/src/arm64.c index 14ffa3385..c50ae343d 100644 --- a/slsDetectorServers/slsDetectorServer/src/arm64.c +++ b/slsDetectorServers/slsDetectorServer/src/arm64.c @@ -8,6 +8,7 @@ #include "sls/sls_detector_defs.h" #include // open +#include // memcpy #include // mmap /* global variables */ @@ -28,6 +29,12 @@ void bus_w(u_int32_t offset, u_int32_t data) { *ptr1 = data; } +u_int32_t bus_r(u_int32_t offset) { + volatile u_int32_t *ptr1; + ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t))); + return *ptr1; +} + void bus_w_csp1(u_int32_t offset, u_int32_t data) { volatile u_int32_t *ptr1; ptr1 = (u_int32_t *)(csp1base + offset / (sizeof(u_int32_t))); @@ -40,12 +47,6 @@ u_int32_t bus_r_csp1(u_int32_t offset) { return *ptr1; } -u_int32_t bus_r(u_int32_t offset) { - volatile u_int32_t *ptr1; - ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t))); - return *ptr1; -} - void bus_w_csp2(u_int32_t offset, u_int32_t data) { volatile u_int32_t *ptr1; ptr1 = (u_int32_t *)(csp2base + offset / (sizeof(u_int32_t))); @@ -58,6 +59,55 @@ u_int32_t bus_r_csp2(u_int32_t offset) { return *ptr1; } +int bus_w_block(u_int32_t offset, const void *src, size_t size, + bool fixedAddress) { + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not write block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + const uint32_t step = fixedAddress ? 0 : sizeof(uint32_t); + uint32_t words[size / sizeof(uint32_t)]; + memcpy(words, src, size); + for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { + bus_w(offset + i * step, words[i]); + } + return OK; +} + +int bus_r_block(u_int32_t offset, void *dst, size_t size, bool fixedAddress) { + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not read block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + const uint32_t step = fixedAddress ? 0 : sizeof(uint32_t); + uint32_t words[size / sizeof(uint32_t)]; + for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { + words[i] = bus_r(offset + i * step); + } + memcpy(dst, words, size); + return OK; +} + +int bus_w_csp1_block(const void *src, size_t size) { + uint32_t step = sizeof(uint32_t); + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not write block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + uint32_t words[size / sizeof(uint32_t)]; + memcpy(words, src, size); + for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { + bus_w_csp1(i * step, words[i]); + } + return OK; +} + uint64_t getU64BitReg(int aLSB, int aMSB) { uint64_t retval = bus_r(aMSB); retval = (retval << 32) | bus_r(aLSB); @@ -121,5 +171,3 @@ int mapCSP0(void) { } return OK; } - -u_int32_t *Arm_getUDPBaseAddress() { return csp1base; } diff --git a/slsDetectorServers/slsDetectorServer/src/blackfin.c b/slsDetectorServers/slsDetectorServer/src/blackfin.c index 868708ab0..e524e1110 100644 --- a/slsDetectorServers/slsDetectorServer/src/blackfin.c +++ b/slsDetectorServers/slsDetectorServer/src/blackfin.c @@ -9,6 +9,7 @@ #include // open #include // fopen +#include //memcpy #include // mmap #include // usleep @@ -46,6 +47,41 @@ u_int32_t bus_r(u_int32_t offset) { return *ptr1; } +int bus_w_block(u_int32_t offset, const void *src, size_t size, + bool fixedAddress) { + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not write block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + const uint32_t step = fixedAddress ? 0 : (1 << MEM_MAP_SHIFT); + // low memory on blackfin, so avoid array on stack + const char *p = src; + for (size_t i = 0; i != size / sizeof(uint32_t); ++i) { + uint32_t word = 0; + memcpy(&word, p + i * sizeof(word), sizeof(word)); + bus_w(offset + i * step, word); + } + return OK; +} + +int bus_r_block(u_int32_t offset, void *dst, size_t size, bool fixedAddress) { + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not read block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + const uint32_t step = fixedAddress ? 0 : (1 << MEM_MAP_SHIFT); + char *p = dst; + for (size_t i = 0; i != size / sizeof(uint32_t); ++i) { + uint32_t word = bus_r(offset + i * step); + memcpy(p + i * sizeof(word), &word, sizeof(word)); + } + return OK; +} + int64_t get64BitReg(int aLSB, int aMSB) { int64_t v64; u_int32_t vLSB, vMSB; @@ -134,8 +170,6 @@ int mapCSP0(void) { return OK; } -uint32_t *Blackfin_getBaseAddress() { return csp0base; } - /* BF537 core clock; refined from /proc/cpuinfo in initCycleCounter() */ #define BFIN_CCLK_HZ_DEFAULT 525000000UL static uint32_t bfinCyclesPerUs = BFIN_CCLK_HZ_DEFAULT / 1000000; diff --git a/slsDetectorServers/slsDetectorServer/src/nios.c b/slsDetectorServers/slsDetectorServer/src/nios.c index 7074db54a..40a91c0c5 100644 --- a/slsDetectorServers/slsDetectorServer/src/nios.c +++ b/slsDetectorServers/slsDetectorServer/src/nios.c @@ -8,6 +8,7 @@ #include "sls/sls_detector_defs.h" #include // open +#include // memcpy #include // mmap /* global variables */ @@ -20,6 +21,18 @@ u_int32_t *csp0base = 0; u_int32_t *csp1base = 0; #define CSP1 0x18040000 +void bus_w(u_int32_t offset, u_int32_t data) { + volatile u_int32_t *ptr1; + ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t))); + *ptr1 = data; +} + +u_int32_t bus_r(u_int32_t offset) { + volatile u_int32_t *ptr1; + ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t))); + return *ptr1; +} + void bus_w_csp1(u_int32_t offset, u_int32_t data) { volatile u_int32_t *ptr1; ptr1 = (u_int32_t *)(csp1base + offset / (sizeof(u_int32_t))); @@ -32,16 +45,37 @@ u_int32_t bus_r_csp1(u_int32_t offset) { return *ptr1; } -void bus_w(u_int32_t offset, u_int32_t data) { - volatile u_int32_t *ptr1; - ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t))); - *ptr1 = data; +int bus_w_block(u_int32_t offset, const void *src, size_t size, + bool fixedAddress) { + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not write block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + const uint32_t step = fixedAddress ? 0 : sizeof(uint32_t); + uint32_t words[size / sizeof(uint32_t)]; + memcpy(words, src, size); + for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { + bus_w(offset + i * step, words[i]); + } + return OK; } -u_int32_t bus_r(u_int32_t offset) { - volatile u_int32_t *ptr1; - ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t))); - return *ptr1; +int bus_r_block(u_int32_t offset, void *dst, size_t size, bool fixedAddress) { + if (size == 0 || size % sizeof(uint32_t) != 0) { + LOG(logERROR, ("Could not read block: size %zu is not a non-zero " + "multiple of %zu\n", + size, sizeof(uint32_t))); + return FAIL; + } + const uint32_t step = fixedAddress ? 0 : sizeof(uint32_t); + uint32_t words[size / sizeof(uint32_t)]; + for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { + words[i] = bus_r(offset + i * step); + } + memcpy(dst, words, size); + return OK; } int64_t get64BitReg(int aLSB, int aMSB) { @@ -124,6 +158,4 @@ int mapCSP0(void) { LOG(logINFO, ("Memory %s already mapped before\n", names[i])); } return OK; -} - -u_int32_t *Nios_getBaseAddress() { return csp0base; } +} \ No newline at end of file diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer b/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer index fac5a1915..4e619d4bb 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/slsDetectorFunctionList.c b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c index cffde6ef5..8cf755dda 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c @@ -1537,10 +1537,9 @@ int configureMAC() { calcChecksum(udp); // force FPGA writes to be aligned and in order - uint32_t words[sizeof(udp_header) / sizeof(uint32_t)]; - memcpy(words, udp, sizeof(udp_header)); - for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) { - bus_w_csp1(i * sizeof(uint32_t), words[i]); + if (bus_w_csp1_block(udp, sizeof(udp_header)) == FAIL) { + LOG(logERROR, ("Failed to write UDP header\n")); + return FAIL; } return OK; diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp index fa0f0d443..736417198 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp @@ -135,7 +135,8 @@ TEST_CASE("rx_missingpackets", det.setFileWrite(false); // avoid writing or error on file creation auto prev_frames = det.getNumberOfFrames().tsquash("inconsistent #frames in test"); - det.setNumberOfFrames(100); + int64_t num_frames = 100; + det.setNumberOfFrames(num_frames); { // some missing packets det.startReceiver(); @@ -166,6 +167,33 @@ TEST_CASE("rx_missingpackets", } else { REQUIRE(oss.str() == "rx_missingpackets [0, 0]\n"); } + + // readnrows + if (det_type == defs::EIGER || det_type == defs::JUNGFRAU || + det_type == defs::MOENCH) { + auto prev_readnrows = det.getReadNRows().squash(); + det.setReadNRows(16); + + // without discard partial policy + det.startReceiver(); + det.startDetector(); + acq::wait_until_idle(det); + det.stopReceiver(); + auto res = + det.getFramesCaught().tsquash("inconsistent frames caught"); + CHECK(res == std::vector(res.size(), num_frames)); + + // with discard partial policy + det.setRxFrameDiscardPolicy(defs::DISCARD_PARTIAL_FRAMES); + det.startReceiver(); + det.startDetector(); + acq::wait_until_idle(det); + det.stopReceiver(); + res = det.getFramesCaught().tsquash("inconsistent frames caught"); + CHECK(res == std::vector(res.size(), num_frames)); + + det.setReadNRows(prev_readnrows); + } } for (int i = 0; i != det.size(); ++i) { det.setFileWrite(prev_val[i], {i}); diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index 60c704578..0eaa429ea 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -194,6 +194,7 @@ void Implementation::SetupListener(int i) { listener[i]->SetIsOutsideRoi(portRois[i].noRoi()); listener[i]->SetUDPDatastream(udpDataStream[i]); listener[i]->SetSilentMode(silentMode); + listener[i]->SetReadNRows(readNRows); } void Implementation::SetupDataProcessor(int i) { @@ -626,14 +627,8 @@ double Implementation::getProgress() const { std::vector Implementation::getNumMissingPackets() const { std::vector mp(generalData->numUDPInterfaces); for (int i = 0; i < generalData->numUDPInterfaces; ++i) { - int np = generalData->packetsPerFrame; - uint64_t totnp = np; - // ReadNRows - if (readNRows != (int)generalData->maxRowsPerReadout) { - totnp = ((readNRows * np) / generalData->maxRowsPerReadout); - } - totnp *= numberOfTotalFrames; - mp[i] = listener[i]->GetNumMissingPacket(stoppedFlag, totnp); + mp[i] = + listener[i]->GetNumMissingPacket(stoppedFlag, numberOfTotalFrames); } return mp; } @@ -1768,6 +1763,8 @@ int Implementation::getReadNRows() const { return readNRows; } void Implementation::setReadNRows(const int value) { readNRows = value; + for (const auto &it : listener) + it->SetReadNRows(readNRows); LOG(logINFO) << "Number of rows: " << readNRows; } diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp index 08443b5cb..d91f09423 100644 --- a/slsReceiverSoftware/src/Listener.cpp +++ b/slsReceiverSoftware/src/Listener.cpp @@ -44,21 +44,31 @@ uint64_t Listener::GetLastFrameIndexCaught() const { } int64_t Listener::GetNumMissingPacket(bool stoppedFlag, - uint64_t numPackets) const { + uint64_t numFrames) const { if (disabledPort) { return 0; } + uint64_t pperFrame = GetNumPacketsPerFrameExpected(); if (!stoppedFlag) { - return (numPackets - numPacketsCaught); + return (numFrames * pperFrame - numPacketsCaught); } if (numPacketsCaught == 0) { return numPacketsCaught; } - return (lastCaughtFrameIndex - firstIndex + 1) * - generalData->packetsPerFrame - + return (lastCaughtFrameIndex - firstIndex + 1) * pperFrame - numPacketsCaught; } +uint32_t Listener::GetNumPacketsPerFrameExpected() const { + uint32_t pperFrame = generalData->packetsPerFrame; + uint32_t maxRows = generalData->maxRowsPerReadout; + // partial readout (readnrows) + if (maxRows != 0 && readNRows > 0 && readNRows < (int)maxRows) { + pperFrame = (readNRows * pperFrame) / maxRows; + } + return pperFrame; +} + bool Listener::GetStartedFlag() const { return startedFlag; } uint64_t Listener::GetCurrentFrameIndex() const { return lastCaughtFrameIndex; } @@ -100,6 +110,8 @@ void Listener::SetIsOutsideRoi(bool enable) { void Listener::SetSilentMode(bool enable) { silentMode = enable; } +void Listener::SetReadNRows(int value) { readNRows = value; } + void Listener::ResetParametersforNewAcquisition() { StopRunning(); startedFlag = false; @@ -321,6 +333,8 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header &dstHeader, standardHeader = false; } uint32_t pperFrame = generalData->packetsPerFrame; + // fewer packets in partial readout (only center rows sent) + uint32_t pperFrameExpected = GetNumPacketsPerFrameExpected(); bool isHeaderEmpty = true; uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - imageSize); sls_detector_header *srcDetHeader = nullptr; @@ -350,7 +364,7 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header &dstHeader, carryOverFlag = false; } - while (numpackets < pperFrame) { + while (numpackets < pperFrameExpected) { // listen to new packet if (!udpSocketAlive || !udpSocket->ReceivePacket(&listeningPacket[0])) { // end of acquisition @@ -404,7 +418,7 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header &dstHeader, // complete image dstHeader.detHeader.packetNumber = numpackets; - if (numpackets == pperFrame) { + if (numpackets == pperFrameExpected) { ++numCompleteFramesCaught; } ++currentFrameIndex; @@ -513,10 +527,10 @@ void Listener::GetPacketIndices(uint64_t &fnum, uint32_t &pnum, uint64_t &bnum, void Listener::PrintFifoStatistics() { LOG(logDEBUG1) << "numFramesStatistic:" << numFramesStatistic << " numPacketsStatistic:" << numPacketsStatistic - << " packetsperframe:" << generalData->packetsPerFrame; + << " packetsperframe:" << GetNumPacketsPerFrameExpected(); // calculate packet loss - int64_t totalP = numFramesStatistic * (generalData->packetsPerFrame); + int64_t totalP = numFramesStatistic * GetNumPacketsPerFrameExpected(); int64_t loss = totalP - numPacketsStatistic; int lossPercent = ((double)loss / (double)totalP) * 100.00; numPacketsStatistic = 0; diff --git a/slsReceiverSoftware/src/Listener.h b/slsReceiverSoftware/src/Listener.h index 57caacb57..db5b0fbe6 100644 --- a/slsReceiverSoftware/src/Listener.h +++ b/slsReceiverSoftware/src/Listener.h @@ -32,7 +32,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { uint64_t GetNumCompleteFramesCaught() const; uint64_t GetLastFrameIndexCaught() const; /** negative values in case of extra packets */ - int64_t GetNumMissingPacket(bool stoppedFlag, uint64_t numPackets) const; + int64_t GetNumMissingPacket(bool stoppedFlag, uint64_t numFrames) const; bool GetStartedFlag() const; uint64_t GetCurrentFrameIndex() const; uint64_t GetListenedIndex() const; @@ -45,6 +45,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { void SetUDPDatastream(bool enable); void SetIsOutsideRoi(bool enable); void SetSilentMode(bool enable); + void SetReadNRows(int value); void ResetParametersforNewAcquisition(); void CreateUDPSocket(int &actualSize); @@ -104,6 +105,10 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { void PrintFifoStatistics(); + /** packets per frame expected from detector (fewer than + * packetsPerFrame in partial readout, as only center rows are sent) */ + uint32_t GetNumPacketsPerFrameExpected() const; + static const std::string TypeName; GeneralData *generalData{nullptr}; Fifo *fifo; @@ -119,6 +124,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject { bool isOutsideRoi{false}; bool silentMode; bool disabledPort{false}; + int readNRows{0}; /** row hardcoded as 1D or 2d, * if detector does not send them yet or diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index fc707af1a..15e627284 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -3,11 +3,11 @@ /** API versions */ #define APILIB "0.0.0 0x250909" #define APIRECEIVER "0.0.0 0x250822" -#define APICTB "0.0.0 0x261103" -#define APIGOTTHARD2 "0.0.0 0x261103" -#define APIMOENCH "0.0.0 0x261103" -#define APIEIGER "0.0.0 0x261027" -#define APIXILINXCTB "0.0.0 0x261103" -#define APIJUNGFRAU "0.0.0 0x261104" -#define APIMYTHEN3 "0.0.0 0x261103" +#define APICTB "0.0.0 0x261109" +#define APIGOTTHARD2 "0.0.0 0x261112" +#define APIMOENCH "0.0.0 0x261109" +#define APIEIGER "0.0.0 0x261105" +#define APIXILINXCTB "0.0.0 0x261106" +#define APIJUNGFRAU "0.0.0 0x261109" +#define APIMYTHEN3 "0.0.0 0x261112" #define APIMATTERHORN "0.0.0 0x260529"