aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-trx/loops.c
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2019-11-14 15:37:16 +0100
committerfixeria <axilirator@gmail.com>2019-11-20 13:35:02 +0000
commit5c5ad3cb4afb131ce32cdc857899540c51aab604 (patch)
treef541e63f67984dc5d2fc1c04408e8fc6bcb7dea9 /src/osmo-bts-trx/loops.c
parentae5e1d7110f1c87a0c4458cba47149b18f4ed2b6 (diff)
scheduler_trx.c: avoid division by zero when calculating BER
There is theoretical risk that when calculating the BER that a division by zero occurrs. Lets add a check to avoid n_errors / n_bits_total when n_bits_total is zero. Change-Id: I1c0731b9a60be4b8c0c84b85b4403168120ceacd Fixes: CID#205696
Diffstat (limited to 'src/osmo-bts-trx/loops.c')
-rw-r--r--src/osmo-bts-trx/loops.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/osmo-bts-trx/loops.c b/src/osmo-bts-trx/loops.c
index e73d842c..47e9cf30 100644
--- a/src/osmo-bts-trx/loops.c
+++ b/src/osmo-bts-trx/loops.c
@@ -268,11 +268,19 @@ void trx_loop_sacch_clock(struct l1sched_trx *l1t, uint8_t chan_nr,
}
void trx_loop_amr_input(struct l1sched_trx *l1t, uint8_t chan_nr,
- struct l1sched_chan_state *chan_state, float ber)
+ struct l1sched_chan_state *chan_state,
+ int n_errors, int n_bits_total)
{
struct gsm_bts_trx *trx = l1t->trx;
struct gsm_lchan *lchan = &trx->ts[L1SAP_CHAN2TS(chan_nr)]
.lchan[l1sap_chan2ss(chan_nr)];
+ float ber;
+
+ /* calculate BER (Bit Error Ratio) */
+ if (n_bits_total == 0)
+ ber = 1.0; /* 100% BER */
+ else
+ ber = (float) n_errors / (float) n_bits_total;
/* check if loop is enabled */
if (!chan_state->amr_loop)