From 31b459d519841093e86e9050a416fd244d0992b7 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" <robin.mueller.m@gmail.com> Date: Sat, 18 Apr 2020 12:22:26 +0200 Subject: [PATCH] possible bugfix in ethernet interface --- .idea/runConfigurations/OBSW_UdpClient_Single_Command.xml | 4 ++-- comIF/obsw_ethernet_com_if.py | 8 ++++---- sendreceive/obsw_single_command_sender_receiver.py | 3 ++- sendreceive/obsw_tm_listener.py | 5 +++-- utility/obsw_tmtc_printer.py | 4 ++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.idea/runConfigurations/OBSW_UdpClient_Single_Command.xml b/.idea/runConfigurations/OBSW_UdpClient_Single_Command.xml index 9a5d03e..eefb361 100644 --- a/.idea/runConfigurations/OBSW_UdpClient_Single_Command.xml +++ b/.idea/runConfigurations/OBSW_UdpClient_Single_Command.xml @@ -12,8 +12,8 @@ <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> - <option name="SCRIPT_NAME" value="C:\Users\Robin\NoSyncDokumente\sourceobsw\tmtc\obsw_tmtc_client.py" /> - <option name="PARAMETERS" value="-m 2 -p" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/obsw_tmtc_client.py" /> + <option name="PARAMETERS" value="-m 2 --boardIP=169.254.86.53" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="false" /> <option name="MODULE_MODE" value="false" /> diff --git a/comIF/obsw_ethernet_com_if.py b/comIF/obsw_ethernet_com_if.py index 21b833c..a9516ab 100644 --- a/comIF/obsw_ethernet_com_if.py +++ b/comIF/obsw_ethernet_com_if.py @@ -45,9 +45,9 @@ class EthernetComIF(CommunicationInterface): def data_available(self, timeout: float = 0) -> bool: ready = select.select([self.sock_receive], [], [], timeout) - if ready is None: - return False - return ready + if ready[0]: + return True + return False def poll_interface(self, pollTimeout: float = 0) -> Tuple[bool, PusTmListT]: ready = self.data_available(pollTimeout) @@ -97,7 +97,7 @@ class EthernetComIF(CommunicationInterface): """ try: self.sock_receive.bind(self.receive_address) - self.sock_receive.setblocking(False) + self.sock_receive.setblocking(0) except OSError: print("Socket already set-up.") # print("Socket Receive Address: " + str(g.G_REC_ADDRESS)) diff --git a/sendreceive/obsw_single_command_sender_receiver.py b/sendreceive/obsw_single_command_sender_receiver.py index 4bb1674..8fd8b3d 100644 --- a/sendreceive/obsw_single_command_sender_receiver.py +++ b/sendreceive/obsw_single_command_sender_receiver.py @@ -28,7 +28,8 @@ class SingleCommandSenderReceiver(CommandSenderReceiver): :param tm_listener: TmListener object which runs in the background and receives all TM :param tmtc_printer: TmTcPrinter object, passed on to CommandSenderReceiver """ - super().__init__(com_interface=com_interface, tm_listener=tm_listener, tmtc_printer=tmtc_printer) + super().__init__(com_interface=com_interface, tm_listener=tm_listener, + tmtc_printer=tmtc_printer) self.faulty_input = False try: self.pus_packet, self.pus_packet_info = pusPacketTuple diff --git a/sendreceive/obsw_tm_listener.py b/sendreceive/obsw_tm_listener.py index 391dab0..8954462 100644 --- a/sendreceive/obsw_tm_listener.py +++ b/sendreceive/obsw_tm_listener.py @@ -14,7 +14,7 @@ import threading from collections import deque from typing import TypeVar -from comIF.obsw_com_interface import ComIfT +from comIF.obsw_com_interface import CommunicationInterface import config.obsw_config as g TmListenerT = TypeVar('TmListenerT', bound='TmListener') @@ -27,7 +27,8 @@ class TmListener: and changing the mode to do special mode operations. The mode operation ends as soon the modeOpFinished Event is set() ! """ - def __init__(self, comInterface: ComIfT, tmTimeout: float, tcTimeoutFactor: float): + def __init__(self, comInterface: CommunicationInterface, tmTimeout: float, + tcTimeoutFactor: float): self.tmTimeout = tmTimeout self.tcTimeoutFactor = tcTimeoutFactor self.comInterface = comInterface diff --git a/utility/obsw_tmtc_printer.py b/utility/obsw_tmtc_printer.py index 477a9dc..ec06146 100644 --- a/utility/obsw_tmtc_printer.py +++ b/utility/obsw_tmtc_printer.py @@ -264,10 +264,10 @@ class TmTcPrinter: """ if self.print_tc: if len(tc_packet) == 0: - print("TMTC Printer: Empty wiretapping_packet was sent, configuration error") + print("TMTC Printer: Empty packet was sent, configuration error") sys.exit() if tc_packet_info is None: - print("TMTC Printer: No wiretapping_packet info supplied to print") + print("TMTC Printer: No packet info supplied to print") return if self.display_mode == "short": self.__handle_short_tc_print(tc_packet_info) -- GitLab