From ce2714eae4b72ff61c38e3a96143f2e73f3eaa74 Mon Sep 17 00:00:00 2001
From: arnaud <arnaud.watlet@umons.ac.be>
Date: Wed, 26 Oct 2022 15:52:57 +0200
Subject: [PATCH] Renames webserver.py as mqtt_interface.py. Sets
 http_interface.py as default in config. Cleans commented lines...

---
 config.py                         | 2 +-
 webserver.py => http_interface.py | 0
 mqtt_interface.py                 | 5 -----
 ohmpi.py                          | 4 +---
 ohmpi_settings.json               | 2 +-
 5 files changed, 3 insertions(+), 10 deletions(-)
 rename webserver.py => http_interface.py (100%)

diff --git a/config.py b/config.py
index 25f6efb4..e8e74a6d 100644
--- a/config.py
+++ b/config.py
@@ -20,7 +20,7 @@ OHMPI_CONFIG = {
 
 CONTROL_CONFIG = {
     'tcp_port': 5555,
-    'interface': 'mqtt_interface.py'
+    'interface': 'http_interface.py' # 'mqtt_interface'
 }
 # Execution logging configuration
 EXEC_LOGGING_CONFIG = {
diff --git a/webserver.py b/http_interface.py
similarity index 100%
rename from webserver.py
rename to http_interface.py
diff --git a/mqtt_interface.py b/mqtt_interface.py
index 24124527..ed5837ae 100644
--- a/mqtt_interface.py
+++ b/mqtt_interface.py
@@ -14,11 +14,6 @@ def on_message(client, userdata, message):
     socket.send(message.payload)
 
     #  Get the reply
-    # event = socket.poll(timeout=1000)
-    # if event == 0:
-    #     print('timeout')
-    #     reply = 'no reply...'
-    # else:
     reply = socket.recv()
 
     print(f'Received reply {message.payload.decode("utf-8")}: {reply}')
diff --git a/ohmpi.py b/ohmpi.py
index 2d0ac6a7..c066a368 100644
--- a/ohmpi.py
+++ b/ohmpi.py
@@ -656,9 +656,6 @@ class OhmPi(object):
         self.exec_logger.debug(f'Start listening for commands on port {tcp_port}')
         while self.cmd_listen:
             try:
-                #id_sock = socket.recv()
-                #assert not socket.recv()    # empty data here
-                #assert socket.recv() == id_sock
                 message = socket.recv(flags=zmq.NOBLOCK)
                 self.exec_logger.debug(f'Received command: {message}')
                 e = None
@@ -673,6 +670,7 @@ class OhmPi(object):
                     if cmd is not None and cmd_id is not None:
                         if cmd == 'update_settings' and args is not None:
                             self._update_acquisition_settings(args)
+                            status = True
                         elif cmd == 'start':
                             self.measure(cmd_id)
                             while not self.status == 'idle':
diff --git a/ohmpi_settings.json b/ohmpi_settings.json
index 273f2290..fe28a272 100644
--- a/ohmpi_settings.json
+++ b/ohmpi_settings.json
@@ -1,6 +1,6 @@
 {
     "nb_electrodes": 64,
-    "injection_duration":0.2,
+    "injection_duration": 0.2,
     "nbr_meas": 1,
     "sequence_delay": 1,
     "nb_stack": 1,
-- 
GitLab