Change in ...osmo-ttcn3-hacks[master]: BTS_Tests.ttcn: fix TRXC port mapping between test_CT and ConnHdlr

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Tue Jun 4 15:00:05 UTC 2019


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/14370


Change subject: BTS_Tests.ttcn: fix TRXC port mapping between test_CT and ConnHdlr
......................................................................

BTS_Tests.ttcn: fix TRXC port mapping between test_CT and ConnHdlr

Before this patch, sending special TRXC commands to FakeTRX, such as
FAKE_TOA and FAKE_RSSI, from ConnHdlr resulted in a receive timeout
waiting for the response.

As it turned out, both the test_CT and the ConnHdlr have a TRXC port,
as depending on the test one would want to globally control it
from test_CT or from within a ConnHdlr.

However, only one of the two should be active (connected) at any given
point in time. Otherwise we'll have two UDP sockets on the same bind
port, and it's more or less random on which of them it ends up.

Let's add an optional parameter 'trxc_comp', which would indicate
whether we need to control TRXC from ConnHdlr or not.

Let's get rid of both f_trxc_connect() and f_main_trxc_connect(),
which basically do the same, but run on different components.

Change-Id: Ie7d311bf8f03bf9b1d29b5bb28ffad793f215fd1
Closes: OS#4039
---
M bts/BTS_Tests.ttcn
1 file changed, 35 insertions(+), 37 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/70/14370/1

diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index ba67889..b9091cc 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -117,7 +117,7 @@
 	/* L1CTL port (for classic tests) */
 	port L1CTL_PT L1CTL;
 
-	/* TRXC port (for classic tests) */
+	/* Optional TRXC connection to FakeTRX (BTS side) */
 	port TRXC_CODEC_PT BTS_TRXC;
 	var integer g_bts_trxc_conn_id;
 
@@ -160,6 +160,7 @@
 type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT {
 	port L1CTL_PT L1CTL;
 
+	/* Optional TRXC connection to FakeTRX (BTS side) */
 	port TRXC_CODEC_PT BTS_TRXC;
 	var integer g_bts_trxc_conn_id;
 
@@ -333,6 +334,22 @@
 	}
 }
 
+private function f_init_trxc(TRXC_CODEC_PT pt, charstring id,
+			     out integer trxc_conn_id) {
+	var Result res;
+
+	map(self:BTS_TRXC, system:BTS_TRXC);
+
+	res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port,
+						       "", -1, -1, { udp := {} }, {});
+	if (not ispresent(res.connId)) {
+		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+					"Could not connect to the control (TRXC) interface " &
+					"of FakeTRX, check your configuration");
+	}
+	trxc_conn_id := res.connId;
+}
+
 /* global init function */
 function f_init() runs on test_CT {
 	var charstring id := testcasename();
@@ -399,7 +416,7 @@
 	if (mp_bts_trxc_port != -1) {
 		var TrxcMessage ret;
 		/* start with a default moderate timing offset equalling TA=2 */
-		f_main_trxc_connect();
+		f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
 		ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256)));
 	}
 
@@ -417,7 +434,9 @@
 type function void_fn(charstring id) runs on ConnHdlr;
 
 /* create a new test component */
-function f_start_handler(void_fn fn, ConnHdlrPars pars, boolean pcu_comp := false)
+function f_start_handler(void_fn fn, ConnHdlrPars pars,
+			 boolean pcu_comp := false,
+			 boolean trxc_comp := false)
 runs on test_CT return ConnHdlr {
 	var charstring id := testcasename();
 	var ConnHdlr vc_conn;
@@ -426,13 +445,18 @@
 	/* connect to RSL Emulation main component */
 	connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
 	connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
+
+	/* The ConnHdlr component may want to talk to some ports directly,
+	 * so we disconnect it from the test_CT and connect it to the component.
+	 * This obviously only works for one component, i.e. no concurrency. */
 	if (pcu_comp) {
-		/* the ConnHdlr component wants to talk directly to the PCU, so disconnect
-		 * it from the test_CT and connect it to the component.  This obviously only
-		 * works for one component, i.e. no concurrency */
 		unmap(self:PCU, system:PCU);
 		map(vc_conn:PCU, system:PCU);
 	}
+	if (trxc_comp) {
+		unmap(self:BTS_TRXC, system:BTS_TRXC);
+		map(vc_conn:BTS_TRXC, system:BTS_TRXC);
+	}
 
 	vc_conn.start(f_handler_init(fn, id, pars));
 	return vc_conn;
@@ -459,19 +483,6 @@
 	f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, ccch_mode, mp_rxlev_exp);
 }
 
-private function f_trxc_connect() runs on ConnHdlr {
-	map(self:BTS_TRXC, system:BTS_TRXC);
-	var Result res;
-	res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BTS_TRXC, mp_bts_trxc_ip, mp_bts_trxc_port,
-							"", -1, -1, {udp:={}}, {});
-	if (not ispresent(res.connId)) {
-		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-					"Could not connect to the control (TRXC) interface " &
-					"of FakeTRX, check your configuration");
-	}
-	g_bts_trxc_conn_id := res.connId;
-}
-
 private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr {
 	var TrxcMessage ret;
 	ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
@@ -492,7 +503,7 @@
 	f_connect_reset(L1CTL);
 
 	if (mp_bts_trxc_port != -1) {
-		f_trxc_connect();
+		f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
 	}
 
 	g_Tguard.start(pars.t_guard);
@@ -1430,21 +1441,6 @@
 	Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
 }
 
-
-
-private function f_main_trxc_connect() runs on test_CT {
-	map(self:BTS_TRXC, system:BTS_TRXC);
-	var Result res;
-	res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BTS_TRXC, mp_bts_trxc_ip, mp_bts_trxc_port,
-							"", -1, -1, {udp:={}}, {});
-	if (not ispresent(res.connId)) {
-		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-					"Could not connect to the control (TRXC) interface " &
-					"of FakeTRX, check your configuration");
-	}
-	g_bts_trxc_conn_id := res.connId;
-}
-
 private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
 	var TrxcMessage ret;
 	/* tell fake_trx to use a given timing offset for all bursts */
@@ -1897,7 +1893,8 @@
 	f_init();
 	for (var integer tn := 1; tn <= 4; tn := tn+1) {
 		pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
-		vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars);
+		vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
+					   pcu_comp := false, trxc_comp := true);
 		vc_conn.done;
 	}
 	Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
@@ -2064,7 +2061,8 @@
 	var ConnHdlrPars pars;
 	f_init();
 	pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
-	vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars);
+	vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars,
+				   pcu_comp := false, trxc_comp := true);
 	vc_conn.done;
 	Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
 }

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/14370
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ie7d311bf8f03bf9b1d29b5bb28ffad793f215fd1
Gerrit-Change-Number: 14370
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190604/9dc4b0d9/attachment.htm>


More information about the gerrit-log mailing list