From 6745eced497befc766c9421551c21e0e447439d3 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 6 Sep 2021 21:30:40 +0200 Subject: [PATCH] ssb: avoid NaN when SSB can't be detected when PSS+SSS can't be detected the RSRP was 0 and the resulting conversion to dB resulted in NaN. --- lib/src/phy/sync/ssb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/phy/sync/ssb.c b/lib/src/phy/sync/ssb.c index e79826d13..357ab7710 100644 --- a/lib/src/phy/sync/ssb.c +++ b/lib/src/phy/sync/ssb.c @@ -704,6 +704,11 @@ ssb_measure(srsran_ssb_t* q, const cf_t ssb_grid[SRSRAN_SSB_NOF_RE], uint32_t N_ float rsrp_sss = SRSRAN_CSQABS(corr_sss); float rsrp = (rsrp_pss + rsrp_sss) / 2.0f; + // avoid taking log of 0 (NaN) + if (rsrp == 0.0) { + rsrp = 1.0; + } + // Compute Noise float n0_pss = 1e-9; // Almost 0 float n0_sss = 1e-9; // Almost 0