diff --git a/fm_agent/settings.json b/fm_agent/settings.json index 74fab7f..f5e56c6 100644 --- a/fm_agent/settings.json +++ b/fm_agent/settings.json @@ -16,13 +16,13 @@ "FVP_MPS2_M0": { "model_binary": "/opt/FM_FVP/FVP_MPS2_Cortex-M0", - "terminal_component": "component.FVP_MPS2_Cortex_M3.fvp_mps2.telnetterminal0" + "terminal_component": "component.FVP_MPS2_Cortex_M0.fvp_mps2.telnetterminal0" }, "FVP_MPS2_M0P": { "model_binary": "/opt/FM_FVP/FVP_MPS2_Cortex-M0plus", - "terminal_component": "component.FVP_MPS2_Cortex_M3.fvp_mps2.telnetterminal0" + "terminal_component": "component.FVP_MPS2_Cortex_M0plus.fvp_mps2.telnetterminal0" }, "FVP_MPS2_M3": { @@ -32,11 +32,11 @@ "FVP_MPS2_M4": { "model_binary": "/opt/FM_FVP/FVP_MPS2_Cortex-M4", - "terminal_component": "component.FVP_MPS2_Cortex_M3.fvp_mps2.telnetterminal0" + "terminal_component": "component.FVP_MPS2_Cortex_M4.fvp_mps2.telnetterminal0" }, "FVP_MPS2_M7": { "model_binary": "/opt/FM_FVP/FVP_MPS2_Cortex-M7", - "terminal_component": "component.FVP_MPS2_Cortex_M3.fvp_mps2.telnetterminal0" + "terminal_component": "component.FVP_MPS2_Cortex_M7.fvp_mps2.telnetterminal0" } } diff --git a/fm_agent/utils.py b/fm_agent/utils.py index 1c68eca..bdca1ba 100644 --- a/fm_agent/utils.py +++ b/fm_agent/utils.py @@ -16,15 +16,15 @@ limitations under the License. """ -import io -import platform import os import sys -import time -import socket import logging from functools import partial -from subprocess import Popen, PIPE, STDOUT, TimeoutExpired +from subprocess import Popen, PIPE, STDOUT +from threading import Thread +from queue import Queue, Empty +ON_POSIX = 'posix' in sys.builtin_module_names + class SimulatorError(Exception): """ @@ -128,20 +128,33 @@ def remove_gcda(rootdir="."): if file.endswith(".gcda"): os.remove(os.path.join(root, file)) -def launch_FVP_IRIS(model_exec, config_file='', lines_out=6): +def enqueue_output(out, queue): + for line in iter(out.readline, b''): + queue.put(line) + out.close() + +def launch_FVP_IRIS(model_exec, config_file=''): """Launch FVP with IRIS Server listening""" cmd_line = [model_exec, '-I', '-p'] if config_file: cmd_line.extend(['-f' , config_file]) - fm_proc = Popen(cmd_line,stdout=PIPE,stderr=STDOUT) + fm_proc = Popen(cmd_line,stdout=PIPE,stderr=STDOUT, close_fds=ON_POSIX) + out_q = Queue() + reader_t = Thread(target=enqueue_output, args=(fm_proc.stdout, out_q)) + reader_t.daemon = True + reader_t.start() stdout='' port = 0 - - for num in range(lines_out): - line = fm_proc.stdout.readline().decode() - if line.startswith("Iris server started listening to port"): - port = int(line[-5:]) - stdout += line + end = False + + while not end: + try: line = out_q.get(timeout=1).decode().strip() + except Empty: + end = True + else: + if line.startswith("Iris server started listening to port"): + port = int(line[-5:]) + stdout = stdout + line + "\n" return (fm_proc, port, stdout)