From 12e8ccd2200ddd5047939a000608fa1d700d36af Mon Sep 17 00:00:00 2001
From: "Robin.Mueller" <robin.mueller.m@gmail.com>
Date: Wed, 8 Jul 2020 15:06:06 +0200
Subject: [PATCH] no reply coming from linux

---
 comIF/obsw_com_interface.py   | 32 ----------------------------
 comIF/obsw_ethernet_com_if.py | 39 +++++------------------------------
 obsw_user_code.py             |  5 ++++-
 3 files changed, 9 insertions(+), 67 deletions(-)

diff --git a/comIF/obsw_com_interface.py b/comIF/obsw_com_interface.py
index 75e4bc3..d2a4090 100644
--- a/comIF/obsw_com_interface.py
+++ b/comIF/obsw_com_interface.py
@@ -75,35 +75,3 @@ class CommunicationInterface:
         :param parameters:
         :return:
         """
-
-    # def receive_telemetry_and_store_info(self, tm_info_queue: PusTmInfoQueueT) -> \
-    #         Union[None, PusTmInfoQueueT]:
-    #     """
-    #     Receive telemetry and store wiretapping_packet information in dict format into a queue.
-    #     If no _tm_data is available, don't do anything.
-    #     :param tm_info_queue:
-    #     :return:
-    #     """
-    #     print("No child implementation provided yet!")
-    #     return
-    #
-    # def receive_telemetry_and_store_tm(self, tm_queue: PusTmQueueT) -> Union[None, PusTmQueueT]:
-    #     """
-    #     Receive telemetry packets and store TM object into a queue.
-    #     If no _tm_data is available, don't do anything.
-    #     :param tm_queue:
-    #     :return:
-    #     """
-    #     print("No child implementation provided yet!")
-    #     return
-    #
-    # def receive_telemetry_and_store_tuple(self, tm_tuple_queue: PusTmTupleQueueT) -> \
-    #         Union[None, PusTmTupleQueueT]:
-    #     """
-    #     Poll telemetry and store a tuple consisting of TM information and the
-    #     TM wiretapping_packet into the queue. If no _tm_data is available, don't do anything.
-    #     :param tm_tuple_queue:
-    #     :return:
-    #     """
-    #     print("No child implementation provided yet!")
-    #     return
diff --git a/comIF/obsw_ethernet_com_if.py b/comIF/obsw_ethernet_com_if.py
index 13cb067..5818e0b 100644
--- a/comIF/obsw_ethernet_com_if.py
+++ b/comIF/obsw_ethernet_com_if.py
@@ -20,7 +20,6 @@ import config.obsw_config as g
 # pylint: disable=abstract-method
 # pylint: disable=arguments-differ
 # pylint: disable=too-many-arguments
-# TODO: decouple printing from receiving. Printing takes a long time and blocks!
 class EthernetComIF(CommunicationInterface):
     """
     Communication interface for UDP communication.
@@ -44,12 +43,13 @@ class EthernetComIF(CommunicationInterface):
         pass
 
     def send_telecommand(self, tc_packet: bytearray, tc_packet_info: PusTcInfoT = None) -> None:
-        # self.tmtc_printer.print_telecommand(tc_packet, tc_packet_info)
         self.sock_send.sendto(tc_packet, self.send_address)
 
     def data_available(self, timeout: float = 0) -> bool:
+        print("polling" + str(self.sock_receive))
         ready = select.select([self.sock_receive], [], [], timeout)
         if ready[0]:
+            print("test!")
             return True
         return False
 
@@ -57,8 +57,8 @@ class EthernetComIF(CommunicationInterface):
         ready = self.data_available(poll_timeout)
         if ready:
             data = self.sock_receive.recvfrom(1024)[0]
-            tm_packet = PusTelemetryFactory.create(data)
-            # self.tmtc_printer.print_telemetry(tm_packet)
+            tm_packet = PusTelemetryFactory.create(bytearray(data))
+            self.tmtc_printer.print_telemetry(tm_packet)
             packet_list = [tm_packet]
             return True, packet_list
         return False, []
@@ -79,9 +79,6 @@ class EthernetComIF(CommunicationInterface):
             self.sock_receive.setblocking(False)
         except OSError:
             print("Socket already set-up.")
-            # print("Socket Receive Address: " + str(g.G_REC_ADDRESS))
-            # logging.exception("Error: ")
-            # exit()
         except TypeError:
             print("Invalid Receive Address")
             sys.exit()
@@ -92,30 +89,4 @@ class EthernetComIF(CommunicationInterface):
         :return:
         """
         test = bytearray([])
-        self.send_telecommand(test)
-
-    # def receive_telemetry_and_store_info(self, tm_info_queue: PusTmInfoQueueT) -> \
-    #         Union[None, PusTmInfoQueueT]:
-    #     packets = self.receive_telemetry()
-    #     for packet in packets:
-    #         packet_info = packet.pack_tm_information()
-    #         if g.G_PRINT_TM:
-    #             self.tmtc_printer.print_telemetry(packet)
-    #         tm_info_queue.append(packet_info)
-    #     return tm_info_queue
-    #
-    # def receive_telemetry_and_store_tm(self, tm_queue: PusTmQueueT) -> Union[None, PusTmQueueT]:
-    #     packets = self.receive_telemetry()
-    #     for packet in packets:
-    #         tm_queue.append(packet)
-    #     return tm_queue
-    #
-    # def receive_telemetry_and_store_tuple(self, tm_tuple_queue):
-    #     packet_list = self.receive_telemetry()
-    #     for packet in packet_list:
-    #         packet_info = packet.pack_tm_information()
-    #         tm_tuple = (packet_info, packet)
-    #         if g.G_PRINT_TM:
-    #             self.tmtc_printer.print_telemetry(packet)
-    #         tm_tuple_queue.append(tm_tuple)
-    #     return tm_tuple_queue
\ No newline at end of file
+        self.send_telecommand(test)
\ No newline at end of file
diff --git a/obsw_user_code.py b/obsw_user_code.py
index 122dcfe..4bf1204 100644
--- a/obsw_user_code.py
+++ b/obsw_user_code.py
@@ -45,4 +45,7 @@ def global_setup_hook_robin():
     # Static IP of board
     port_send = 7301
     send_address_to_set = ("127.0.0.1", port_send)
-    config.obsw_config.G_SEND_ADDRESS = send_address_to_set
\ No newline at end of file
+    port_receive = 7302
+    recv_address_to_set = ("", port_receive)
+    config.obsw_config.G_REC_ADDRESS = recv_address_to_set
+    config.obsw_config.G_SEND_ADDRESS = send_address_to_set
-- 
GitLab