From 0509ca7bfaf0110f05e23be2c822dc763104fdda Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" <robin.mueller.m@gmail.com> Date: Fri, 10 Jul 2020 12:38:22 +0200 Subject: [PATCH] exception handling for non-existing qemu files --- comIF/obsw_qemu_com_if.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/comIF/obsw_qemu_com_if.py b/comIF/obsw_qemu_com_if.py index 035ec6a..e38b104 100755 --- a/comIF/obsw_qemu_com_if.py +++ b/comIF/obsw_qemu_com_if.py @@ -22,12 +22,16 @@ import struct import json import re import errno +import sys import time from threading import Thread from typing import Tuple +from logging import getLogger from comIF.obsw_com_interface import CommunicationInterface, PusTcInfoT, PusTmListT from tm.obsw_pus_tm_factory import PusTelemetryFactory +LOGGER = getLogger() + # Paths to Unix Domain Sockets used by the emulator QEMU_ADDR_QMP = "/tmp/qemu" QEMU_ADDR_AT91_USART0 = "/tmp/qemu_at91_usart0" @@ -66,10 +70,13 @@ class QEMUComIF(CommunicationInterface): self.thread = Thread(target=start_background_loop, args=(self.loop,), daemon=True) self.thread.start() - - self.usart = asyncio.run_coroutine_threadsafe( - Usart.create_async(QEMU_ADDR_AT91_USART0), self.loop).result() - asyncio.run_coroutine_threadsafe(self.usart.open(), self.loop).result() + try: + self.usart = asyncio.run_coroutine_threadsafe( + Usart.create_async(QEMU_ADDR_AT91_USART0), self.loop).result() + asyncio.run_coroutine_threadsafe(self.usart.open(), self.loop).result() + except NotImplementedError: + LOGGER.exception("QEMU Initialization error, file does not exist!") + sys.exit() def close(self): self.usart.close() -- GitLab