From 3d6f45c1caa53b8fa3dc24553aff88df4bcb17d2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20J=C3=BCrges?= <jurges@astron.nl>
Date: Tue, 13 Nov 2018 14:19:25 +0000
Subject: [PATCH] Task #11328:  Distinguish spectral and transient frame size

The TBB UDP frame sizes in transient and spectral mode are different.  In
spectral mode the frame size is only 2012 bytes where the transient mode has
a frame size of 2040 bytes.  This must be addressed in the code when the
number of samples per frame is calculated.
---
 RTCP/Cobalt/OutputProc/src/TBB_Frame.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/RTCP/Cobalt/OutputProc/src/TBB_Frame.h b/RTCP/Cobalt/OutputProc/src/TBB_Frame.h
index fda504b29d6..db308a1a0b1 100644
--- a/RTCP/Cobalt/OutputProc/src/TBB_Frame.h
+++ b/RTCP/Cobalt/OutputProc/src/TBB_Frame.h
@@ -77,11 +77,14 @@ namespace LOFAR
        * In the TBBs, transient samples are packed (2 samples per 3 bytes) with the checksum all the way at the end. This changes on transfer.
        *
        * TBB stores a frame in 2040 bytes (actually, 2048 with preamble and gaps). It sends a frame at a time, so derive our max from it.
+       *
+       * In spectral mode the frame size is only 2012 bytes!
        */
-#define MAX_TBB_DATA_SIZE               (2040 - sizeof(TBB_Header) - sizeof(uint32_t))  // 1948: TBB frame size without header and payload crc32.
+#define MAX_TBB_DATA_SIZE_SPECTRAL_MODE (2012 - sizeof(TBB_Header) - sizeof(uint32_t))
+#define MAX_TBB_DATA_SIZE_TRANSIENT_MODE (2040 - sizeof(TBB_Header) - sizeof(uint32_t))  // 1948: TBB frame size without header and payload crc32.
 
-#define MAX_TBB_TRANSIENT_NSAMPLES      (MAX_TBB_DATA_SIZE / 3 * 2)  // 1298 (.666: 1 byte padding when indeed 1298 samples would ever be stored in TBB)
-#define MAX_TBB_SPECTRAL_NSAMPLES       (MAX_TBB_DATA_SIZE / (2 * sizeof(int16_t)))     // 487
+#define MAX_TBB_TRANSIENT_NSAMPLES      (MAX_TBB_DATA_SIZE_TRANSIENT_MODE / 3 * 2)  // 1298 (.666: 1 byte padding when indeed 1298 samples would ever be stored in TBB)
+#define MAX_TBB_SPECTRAL_NSAMPLES       (MAX_TBB_DATA_SIZE_SPECTRAL_MODE / (2 * sizeof(int16_t)))     // 487
 
       // Unpacked, sign-extended (for transient) samples without padding, i.e. as received.
       // Frames might not be full; the doc says the crc32 is always sent right after (no padding),
-- 
GitLab