# HG changeset patch # User Mychaela Falconia # Date 1502527629 0 # Node ID 80281b67511f0306370b2c6e61aae4f4147ab1f2 # Parent b0618796d28d555b05357f6aea04ea00ffbc0f95 fc-rfcal-txband: fixed bug in the corner case when the target power level is above the highest basis point diff -r b0618796d28d -r 80281b67511f autocal/txlevels.c --- a/autocal/txlevels.c Fri Aug 11 03:20:43 2017 +0000 +++ b/autocal/txlevels.c Sat Aug 12 08:47:09 2017 +0000 @@ -22,7 +22,7 @@ double target_dbm; vout_t *pslope; { - vout_t target_vout; + vout_t target_vout, slope; unsigned n; int apc_delta; @@ -30,9 +30,13 @@ for (n = 0; n < num_basis_points - 1; n++) if (target_vout < tx_basis[n+1].vout) break; + if (n == num_basis_points - 1) + slope = tx_basis[n-1].slope; + else + slope = tx_basis[n].slope; if (pslope) - *pslope = tx_basis[n].slope; - apc_delta = (target_vout - tx_basis[n].vout) / tx_basis[n].slope; + *pslope = slope; + apc_delta = (target_vout - tx_basis[n].vout) / slope; return tx_basis[n].apc + apc_delta; }