[PATCH] osmocom-bb[master]: fake_trx/ctrl_if.py: allow adding custom params to response

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Feb 22 15:32:55 UTC 2018


Review at  https://gerrit.osmocom.org/6722

fake_trx/ctrl_if.py: allow adding custom params to response

Change-Id: I551bb425c25a5c978801d9e1e033b4ba352e259f
---
M src/target/fake_trx/ctrl_if.py
1 file changed, 11 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/22/6722/1

diff --git a/src/target/fake_trx/ctrl_if.py b/src/target/fake_trx/ctrl_if.py
index a87c4c4..e84c1c8 100644
--- a/src/target/fake_trx/ctrl_if.py
+++ b/src/target/fake_trx/ctrl_if.py
@@ -30,7 +30,11 @@
 		if self.verify_req(data):
 			request = self.prepare_req(data)
 			rc = self.parse_cmd(request)
-			self.send_response(request, rc)
+
+			if type(rc) is tuple:
+				self.send_response(request, rc[0], rc[1])
+			else:
+				self.send_response(request, rc)
 		else:
 			print("[!] Wrong data on CTRL interface")
 
@@ -62,9 +66,14 @@
 
 		return True
 
-	def send_response(self, request, response_code):
+	def send_response(self, request, response_code, params = None):
 		# Include status code, for example ["TXTUNE", "0", "941600"]
 		request.insert(1, str(response_code))
+
+		# Optionally append command specific parameters
+		if params is not None:
+			request += params
+
 		# Add the response signature, and join back to string
 		response = "RSP " + " ".join(request) + "\0"
 		# Now we have something like "RSP TXTUNE 0 941600"

-- 
To view, visit https://gerrit.osmocom.org/6722
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I551bb425c25a5c978801d9e1e033b4ba352e259f
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list