fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42915?usp=email )
Change subject: library: add f_gsm_fn_{sum,sub,diff}()
......................................................................
library: add f_gsm_fn_{sum,sub,diff}()
Change-Id: Ie91ccef5d3f170f4a341a6cf9d3323a896b299e6
---
M library/GSM_Types.ttcn
1 file changed, 22 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks
refs/changes/15/42915/1
diff --git a/library/GSM_Types.ttcn b/library/GSM_Types.ttcn
index b3b6dc9..764b8ba 100644
--- a/library/GSM_Types.ttcn
+++ b/library/GSM_Types.ttcn
@@ -434,6 +434,28 @@
return (fn / 51) mod 8;
}
+/* 45.002 4.3.3: TDMA frame number modular arithmetic */
+
+/* Return the sum of two given TDMA frame numbers, wrapping around the
hyperframe */
+function f_gsm_fn_sum(GsmFrameNumber a, GsmFrameNumber b) return
GsmFrameNumber {
+ return (a + b) mod GsmMaxFrameNumber;
+}
+
+/* Return the difference of two given TDMA frame numbers, wrapping around the
hyperframe */
+function f_gsm_fn_sub(GsmFrameNumber a, GsmFrameNumber b) return
GsmFrameNumber {
+ return (a - b + GsmMaxFrameNumber) mod GsmMaxFrameNumber;
+}
+
+/* Return the *minimum* distance between two given TDMA frame numbers */
+function f_gsm_fn_diff(GsmFrameNumber a, GsmFrameNumber b) return
GsmFrameNumber {
+ var GsmFrameNumber d1 := f_gsm_fn_sub(a, b);
+ var GsmFrameNumber d2 := f_gsm_fn_sub(b, a);
+ if (d1 < d2) {
+ return d1;
+ }
+ return d2;
+}
+
type hexstring GsmBcdString with { variant "HEXORDER(low)" };
type GsmBcdString BcdMccMnc with { variant "FIELDLENGTH(6)" };
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42915?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ie91ccef5d3f170f4a341a6cf9d3323a896b299e6
Gerrit-Change-Number: 42915
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>