From 1d2b85aa3aad5e487eb619e373000c047be63143 Mon Sep 17 00:00:00 2001 From: Steven Baltakatei Sandoval Date: Tue, 7 Jul 2020 09:59:26 +0000 Subject: [PATCH] fix(bkgpslog):Fix float calc in buffer PID adjust --- exec/bkgpslog | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/exec/bkgpslog b/exec/bkgpslog index 9e23f01..7a4487f 100755 --- a/exec/bkgpslog +++ b/exec/bkgpslog @@ -999,7 +999,10 @@ magicBufferSleepPID() { yell "WARNING:Buffer lag adjustment yielded negative seconds."; fi; ## Calculate nanosecond remainder - BUFFER_TTL_ADJ_FLOATFRAC="$((BUFFER_TTL_NS - (BUFFER_TTL_ADJ_INT*(10**9)) ))" && vbm "BUFFER_TTL_ADJ_FLOATFRAC:$BUFFER_TTL_ADJ_FLOATFRAC"; + ### Remove integer + BUFFER_TTL_ADJ_FLOATFRAC="$((BUFFER_TTL_ADJ_NS - (BUFFER_TTL_ADJ_INT*(10**9)) ))"; + ### Calc absolute value of fraction (by removing '-' if present; see https://stackoverflow.com/a/47240327 + BUFFER_TTL_ADJ_FLOATFRAC="${BUFFER_TTL_ADJ_FLOAT_FRAC#-}" && vbm "BUFFER_TTL_ADJ_FLOATFRAC:$BUFFER_TTL_ADJ_FLOATFRAC"; ## Form float BUFFER_TTL_ADJ_FLOAT BUFFER_TTL_ADJ_FLOAT="$BUFFER_TTL_ADJ_INT"."$BUFFER_TTL_ADJ_FLOATFRAC" && vbm "BUFFER_TTL_ADJ_FLOAT:$BUFFER_TTL_ADJ_FLOAT"; vbm "STATUS:Calculated adjusted BUFFER_TTL (seconds):$BUFFER_TTL_ADJ_FLOAT"; -- 2.30.2