diff --git a/config/obsw_com_config.py b/config/obsw_com_config.py index 7d9a8b9124a21ef04db90253c07a569e8cc279a2..e4e2449cf7211c5c8232535992362b3f5f0413d9 100644 --- a/config/obsw_com_config.py +++ b/config/obsw_com_config.py @@ -28,8 +28,8 @@ def set_communication_interface(tmtc_printer: TmTcPrinter) -> Union[Communicatio if g.G_COM_IF == g.ComIF.Ethernet: communication_interface = EthernetComIF( tmtc_printer=tmtc_printer, tm_timeout=g.G_TM_TIMEOUT, - tc_timeout_factor=g.G_TC_SEND_TIMEOUT_FACTOR, send_address=g.G_SEND_ADDRESS, - receive_address=g.G_REC_ADDRESS) + tc_timeout_factor=g.G_TC_SEND_TIMEOUT_FACTOR, send_address=g.G_ETHERNET_SEND_ADDRESS, + receive_address=g.G_ETHERNET_RECV_ADDRESS) elif g.G_COM_IF == g.ComIF.Serial: serial_baudrate = g.G_SERIAL_BAUDRATE serial_timeout = g.G_SERIAL_TIMEOUT diff --git a/config/obsw_config.py b/config/obsw_config.py index 6b9ebc476b96ff9e0960a1a160456826cd4bce39..e1de03e49c799122a5f23ed51651fb6e88ddec91 100644 --- a/config/obsw_config.py +++ b/config/obsw_config.py @@ -10,6 +10,7 @@ import struct import pprint import logging +from socket import INADDR_ANY from config.obsw_definitions import ModeList, ComIF """ @@ -76,8 +77,15 @@ G_TM_TIMEOUT = 6 G_TC_SEND_TIMEOUT_FACTOR = 2.0 # Ethernet connection settings -G_REC_ADDRESS = 0 -G_SEND_ADDRESS = (0, 0) +# Bind to localhost, change accordingly! +G_ETHERNET_SEND_ADDRESS_IP = '127.0.0.1' +G_ETHERNET_SEND_PORT = 7301 +# Bind to all interfaces, insecure! +G_ETHERNET_RECV_ADDRESS_IP = '' +G_ETHERNET_RECV_PORT = 7302 + +G_ETHERNET_RECV_ADDRESS = (G_ETHERNET_RECV_ADDRESS_IP, G_ETHERNET_RECV_PORT) +G_ETHERNET_SEND_ADDRESS = (G_ETHERNET_SEND_ADDRESS_IP, G_ETHERNET_SEND_PORT) # Print Settings G_PRINT_TO_FILE = True @@ -96,7 +104,7 @@ G_TMTC_PRINTER = None # noinspection PyUnusedLocal def set_globals(args): - global G_REC_ADDRESS, G_SEND_ADDRESS, G_SCRIPT_MODE, G_MODE_ID, G_SERVICE, G_DISPLAY_MODE,\ + global G_ETHERNET_RECV_ADDRESS, G_ETHERNET_SEND_ADDRESS, G_SCRIPT_MODE, G_MODE_ID, G_SERVICE, G_DISPLAY_MODE,\ G_COM_IF, G_COM_PORT, G_SERIAL_TIMEOUT, G_TM_TIMEOUT, G_TC_SEND_TIMEOUT_FACTOR, \ G_PRINT_TO_FILE, G_PRINT_HK_DATA, G_PRINT_RAW_TM, G_PRINT_TM if args.mode == 0: @@ -105,14 +113,6 @@ def set_globals(args): G_DISPLAY_MODE = "short" else: G_DISPLAY_MODE = "long" - # Board IP address and ethernet port IP address can be passed optionally - # by passing line parameter In PyCharm: Set parameters in run configuration - # Add IP address of Ethernet port. Use command ipconfig in windows console or ifconfig in Linux. - port_receive = 2008 - rec_address_to_set = (args.clientIP, port_receive) - # Static IP of board - port_send = 7 - send_address_to_set = (args.boardIP, port_send) if 0 <= args.mode <= 6: if args.mode == 0: G_MODE_ID = ModeList.GUIMode @@ -144,8 +144,6 @@ def set_globals(args): G_SERVICE = int(args.service) else: G_SERVICE = args.service - G_REC_ADDRESS = rec_address_to_set - G_SEND_ADDRESS = send_address_to_set G_MODE_ID = G_MODE_ID G_PRINT_HK_DATA = args.print_hk G_PRINT_TM = args.print_tm diff --git a/obsw_tmtc_client.py b/obsw_tmtc_client.py index 018d2e82dce8243a638ba0c2586a179021ac9e19..bac67ce2f73e50344bc34db8b641c147010aeafc 100755 --- a/obsw_tmtc_client.py +++ b/obsw_tmtc_client.py @@ -146,7 +146,11 @@ class TmTcHandler: self.handle_action() LOGGER.info("TMTC Client in idle mode") time.sleep(5) - except (IOError, KeyboardInterrupt): + except KeyboardInterrupt: + LOGGER.info("Closing TMTC client.") + sys.exit() + except IOError as e: + LOGGER.exception(e) LOGGER.info("Closing TMTC client.") sys.exit() diff --git a/obsw_user_code.py b/obsw_user_code.py index 8857cc1c4696f253d0bd72403a0c2a2870151c8d..4cfc48eba6b4266772ca1db8db9f2dbcb8781390 100644 --- a/obsw_user_code.py +++ b/obsw_user_code.py @@ -28,7 +28,7 @@ def global_setup_hook(): For example, device specific com ports or ethernet ports can be set here. The global variables in the config.obsw_config file can be edited here by using the handle. - For example: config.obsw_config.G_SEND_ADDRESS = new_send_address + For example: config.obsw_config.G_ETHERNET_SEND_ADDRESS = new_send_address """ if Developer == Developer.Robin: global_setup_hook_robin() @@ -42,12 +42,4 @@ def prepare_robins_commands(): def global_setup_hook_robin(): import config.obsw_config - # Static IP of board. - port_send = 7301 - destination_address = ('', port_send) - - # Socket will be bound to this address. - 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 = destination_address + pass diff --git a/tmtc_core b/tmtc_core index 9c509ddce9474dd29debfa9467386c0a32f46636..feb12905b6e515e3691d8bc743984498f91e9cfe 160000 --- a/tmtc_core +++ b/tmtc_core @@ -1 +1 @@ -Subproject commit 9c509ddce9474dd29debfa9467386c0a32f46636 +Subproject commit feb12905b6e515e3691d8bc743984498f91e9cfe