summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-07-14 05:49:48 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2017-10-23 22:05:49 +0330
commit611f222172b33c9c33c428dcbda379c83c7bad03 (patch)
treefa37603a041d83af0080265a7b51123279a6be79
parenta11815672dd95176204eb5fff1babc1bd56258ff (diff)
fake_trx/ctrl_if.py: allow adding custom params to response
-rw-r--r--src/target/fake_trx/ctrl_if.py13
1 files changed, 11 insertions, 2 deletions
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 @@ class CTRLInterface(UDPLink):
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 @@ class CTRLInterface(UDPLink):
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"