Add new f_timer_safe_restart() function for warning-safe restart
TITAN will print warnings if a still-running timer is res-started.
It will also warn if a not-started timer is stopped, so we need
a conditional stop + start if we want to avoid any warnings in a
convenient way.
Change-Id: Iee83b4905cce3a84eb007ffd189b55f4b54f7cb6
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index 9cb0f72..8800139 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -544,8 +544,7 @@
alt {
[] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
rsl_chrqd := rsl_chrqd + 1;
- T.stop;
- T.start;
+ f_timer_safe_restart(T);
repeat;
}
[] RSL_CCHAN.receive { repeat; }
@@ -732,7 +731,7 @@
/* increment counter of next to-be-expected meas rep */
g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
/* Re-start the timer expecting the next MEAS RES */
- g_Tmeas_exp.start;
+ f_timer_safe_restart(g_Tmeas_exp);
repeat;
}
[] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn
index a6d5c82..e36d2dc 100644
--- a/library/Osmocom_Types.ttcn
+++ b/library/Osmocom_Types.ttcn
@@ -118,5 +118,13 @@
return false;
}
+/* re-start given timer in a warning-safe way: Stop (only if running) + start */
+function f_timer_safe_restart(timer T) {
+ if (T.running) {
+ T.stop;
+ }
+ T.start;
+}
+
} with { encode "RAW"; variant "FIELDORDER(msb)" }