aboutsummaryrefslogtreecommitdiffstats
path: root/python/trx/ctrl_if.py
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-08-09 19:30:39 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-08-10 16:38:59 +0700
commit0e246372bc692f2f12198b61010c4ea156056428 (patch)
treec48814ec8cf4a8c408d89689d2d7efedce0e50d4 /python/trx/ctrl_if.py
parentb085a2c8540ea89c49c7aa9eac543405a948196a (diff)
trx/ctrl_if.py: send control responses to where commands are from
When we receive a control command, we should not simply send the response to the default destination, but send it back to the exact IP/prt from which the command originated. This ensures correct routing of responses even in case multiple programs are interfacing concurrently with a control socket. Cherry-picked from: I24a0bba6eed059b101af95dac7d059f34dd715fc Change-Id: I1f304ea887dc957d3ad53adb1e3c56ab27d8f196
Diffstat (limited to 'python/trx/ctrl_if.py')
-rw-r--r--python/trx/ctrl_if.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/python/trx/ctrl_if.py b/python/trx/ctrl_if.py
index 7dee0f8..ae5cf05 100644
--- a/python/trx/ctrl_if.py
+++ b/python/trx/ctrl_if.py
@@ -25,15 +25,15 @@
from grgsm.trx import udp_link
class ctrl_if(udp_link):
- def handle_rx(self, data):
+ def handle_rx(self, data, remote):
if self.verify_req(data):
request = self.prepare_req(data)
rc = self.parse_cmd(request)
if type(rc) is tuple:
- self.send_response(request, rc[0], rc[1])
+ self.send_response(request, remote, rc[0], rc[1])
else:
- self.send_response(request, rc)
+ self.send_response(request, remote, rc)
else:
print("[!] Wrong data on CTRL interface")
@@ -65,7 +65,7 @@ class ctrl_if(udp_link):
return True
- def send_response(self, request, response_code, params = None):
+ def send_response(self, request, remote, response_code, params = None):
# Include status code, for example ["TXTUNE", "0", "941600"]
request.insert(1, str(response_code))
@@ -76,7 +76,7 @@ class ctrl_if(udp_link):
# Add the response signature, and join back to string
response = "RSP " + " ".join(request) + "\0"
# Now we have something like "RSP TXTUNE 0 941600"
- self.send(response)
+ self.send(response, remote)
def parse_cmd(self, request):
raise NotImplementedError