From: Steven Baltakatei Sandoval Date: Tue, 7 Jul 2020 09:59:26 +0000 (+0000) Subject: fix(bkgpslog):Fix float calc in buffer PID adjust X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02.git/commitdiff_plain/1d2b85aa3aad5e487eb619e373000c047be63143?ds=sidebyside;hp=3370febe9abfaa4da92ad57fc39b22295a160057 fix(bkgpslog):Fix float calc in buffer PID adjust --- 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";