From 0cf45652ae81971f5fd0f3eed31c8d6cac6f9aff Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" <robin.mueller.m@gmail.com> Date: Wed, 8 Jul 2020 03:18:54 +0200 Subject: [PATCH] not really happy with custom config right now.. --- .idea/runConfigurations/tmtcclient_Help.xml | 2 +- .../tmtcclient_Service_17_UDP.xml | 2 +- ...mand.xml => tmtcclient_Single_Command.xml} | 4 ++-- comIF/obsw_ethernet_com_if.py | 6 +++++- obsw_user_code.py | 19 ++++++++++++------- utility/obsw_args_parser.py | 8 ++++---- 6 files changed, 25 insertions(+), 16 deletions(-) rename .idea/runConfigurations/{OBSW_UdpClient_Single_Command.xml => tmtcclient_Single_Command.xml} (81%) diff --git a/.idea/runConfigurations/tmtcclient_Help.xml b/.idea/runConfigurations/tmtcclient_Help.xml index 683cda5..6aece90 100644 --- a/.idea/runConfigurations/tmtcclient_Help.xml +++ b/.idea/runConfigurations/tmtcclient_Help.xml @@ -12,7 +12,7 @@ <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="SCRIPT_NAME" value="$PROJECT_DIR$/obsw_tmtc_client.py" /> <option name="PARAMETERS" value="-h" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="false" /> diff --git a/.idea/runConfigurations/tmtcclient_Service_17_UDP.xml b/.idea/runConfigurations/tmtcclient_Service_17_UDP.xml index 22544e6..4d49dab 100644 --- a/.idea/runConfigurations/tmtcclient_Service_17_UDP.xml +++ b/.idea/runConfigurations/tmtcclient_Service_17_UDP.xml @@ -12,7 +12,7 @@ <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="SCRIPT_NAME" value="$PROJECT_DIR$/obsw_tmtc_client.py" /> <option name="PARAMETERS" value="-m 3 -s 17 -p -t 5" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="true" /> diff --git a/.idea/runConfigurations/OBSW_UdpClient_Single_Command.xml b/.idea/runConfigurations/tmtcclient_Single_Command.xml similarity index 81% rename from .idea/runConfigurations/OBSW_UdpClient_Single_Command.xml rename to .idea/runConfigurations/tmtcclient_Single_Command.xml index eefb361..46d2403 100644 --- a/.idea/runConfigurations/OBSW_UdpClient_Single_Command.xml +++ b/.idea/runConfigurations/tmtcclient_Single_Command.xml @@ -1,5 +1,5 @@ <component name="ProjectRunConfigurationManager"> - <configuration default="false" name="OBSW_UdpClient Single Command" type="PythonConfigurationType" factoryName="Python" folderName="UDP Communication"> + <configuration default="false" name="tmtcclient Single Command" type="PythonConfigurationType" factoryName="Python" folderName="UDP Communication"> <module name="tmtc" /> <option name="INTERPRETER_OPTIONS" value="" /> <option name="PARENT_ENVS" value="true" /> @@ -13,7 +13,7 @@ <option name="ADD_SOURCE_ROOTS" value="true" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/obsw_tmtc_client.py" /> - <option name="PARAMETERS" value="-m 2 --boardIP=169.254.86.53" /> + <option name="PARAMETERS" value="-m 2 -c 3 --boardIP=127.0.0.1" /> <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 8a56d9a..13cb067 100644 --- a/comIF/obsw_ethernet_com_if.py +++ b/comIF/obsw_ethernet_com_if.py @@ -25,6 +25,10 @@ class EthernetComIF(CommunicationInterface): """ Communication interface for UDP communication. """ + + def send_data(self, data: bytearray): + self.sock_send.sendto(data, self.send_address) + def __init__(self, tmtc_printer: TmTcPrinter, tm_timeout: float, tc_timeout_factor: float, receive_address: g.ethernetAddressT, send_address: g.ethernetAddressT): super().__init__(tmtc_printer) @@ -40,7 +44,7 @@ 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.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: diff --git a/obsw_user_code.py b/obsw_user_code.py index 48bc76a..1b204fa 100644 --- a/obsw_user_code.py +++ b/obsw_user_code.py @@ -11,12 +11,13 @@ def command_preparation_hook() -> Tuple[bytearray, Union[None, PusTcInfo]]: Can be used to pack user-defined commands. """ command = PusTelecommand(service=17, subservice=1, ssc=20) - command2 = PusTelecommand(service=17, subservice=1, ssc=21) - tc_list = list() - tc_list.append(command) - tc_list.append(command2) - frame, frame_size, num_packets = pack_tc_frame(tc_list, 256) - return frame, None + # command2 = PusTelecommand(service=17, subservice=1, ssc=21) + # tc_list = list() + # tc_list.append(command) + # tc_list.append(command2) + # frame, frame_size, num_packets = pack_tc_frame(tc_list, 256) + + return command.pack_command_tuple() def global_setup_hook(): @@ -24,4 +25,8 @@ def global_setup_hook(): Can be used to alter the global variables in a custom defined way. For example, device specific com port can be set here. """ - pass + import config.obsw_config + # 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 diff --git a/utility/obsw_args_parser.py b/utility/obsw_args_parser.py index 39c7ea2..f269f4a 100644 --- a/utility/obsw_args_parser.py +++ b/utility/obsw_args_parser.py @@ -22,15 +22,15 @@ def parse_input_arguments(): '0: GUI Mode, 1:Listener Mode, 2: Single Command Mode, 3: Service Test Mode, ' '4: Software Test Mode, 5: Unit Test Mode ', default=0) arg_parser.add_argument( - '-c', '--com_if', type=int, help='Communication Interface. 0 for Ethernet, 1 for Serial, ' - '2 for virtual interface', default=2) + '-c', '--com_if', type=int, help='Communication Interface. 0: Dummy Interface, 1: Serial, ' + '2: QEMU, 3: UDP', default=2) arg_parser.add_argument('--clientIP', help='Client(Computer) IP. Default:\'\'', default='') arg_parser.add_argument( - '--boardIP', help='Board IP. Default: 169.254.1.38', default='169.254.1.38') + '--boardIP', help='Board IP. Default: Localhost 127.0.0.1', default='127.0.0.1') arg_parser.add_argument('-s', '--service', help='Service to test. Default: 17', default=17) arg_parser.add_argument( '-t', '--tm_timeout', type=float, help='TM Timeout when listening to verification sequence.' - ' Default: 12, 6(Serial)', default=6.0) + ' Default: 5 seconds', default=5.0) arg_parser.add_argument( '--nl', dest='print_log', help='Supply --nl to suppress print output to log files.', action='store_false') -- GitLab