Skip to content

Commit 3a159c8

Browse files
author
Qinghao Shi
authored
fix bugs (#7)
1 parent 8f4b207 commit 3a159c8

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

fm_agent/settings.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
"FVP_MPS2_M0": {
1818
"model_binary": "/opt/FM_FVP/FVP_MPS2_Cortex-M0",
19-
"terminal_component": "component.FVP_MPS2_Cortex_M3.fvp_mps2.telnetterminal0"
19+
"terminal_component": "component.FVP_MPS2_Cortex_M0.fvp_mps2.telnetterminal0"
2020
},
2121

2222
"FVP_MPS2_M0P": {
2323

2424
"model_binary": "/opt/FM_FVP/FVP_MPS2_Cortex-M0plus",
25-
"terminal_component": "component.FVP_MPS2_Cortex_M3.fvp_mps2.telnetterminal0"
25+
"terminal_component": "component.FVP_MPS2_Cortex_M0plus.fvp_mps2.telnetterminal0"
2626
},
2727

2828
"FVP_MPS2_M3": {
@@ -32,11 +32,11 @@
3232

3333
"FVP_MPS2_M4": {
3434
"model_binary": "/opt/FM_FVP/FVP_MPS2_Cortex-M4",
35-
"terminal_component": "component.FVP_MPS2_Cortex_M3.fvp_mps2.telnetterminal0"
35+
"terminal_component": "component.FVP_MPS2_Cortex_M4.fvp_mps2.telnetterminal0"
3636
},
3737

3838
"FVP_MPS2_M7": {
3939
"model_binary": "/opt/FM_FVP/FVP_MPS2_Cortex-M7",
40-
"terminal_component": "component.FVP_MPS2_Cortex_M3.fvp_mps2.telnetterminal0"
40+
"terminal_component": "component.FVP_MPS2_Cortex_M7.fvp_mps2.telnetterminal0"
4141
}
4242
}

fm_agent/utils.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
limitations under the License.
1717
"""
1818

19-
import io
20-
import platform
2119
import os
2220
import sys
23-
import time
24-
import socket
2521
import logging
2622
from functools import partial
27-
from subprocess import Popen, PIPE, STDOUT, TimeoutExpired
23+
from subprocess import Popen, PIPE, STDOUT
24+
from threading import Thread
25+
from queue import Queue, Empty
26+
ON_POSIX = 'posix' in sys.builtin_module_names
27+
2828

2929
class SimulatorError(Exception):
3030
"""
@@ -128,20 +128,33 @@ def remove_gcda(rootdir="."):
128128
if file.endswith(".gcda"):
129129
os.remove(os.path.join(root, file))
130130

131-
def launch_FVP_IRIS(model_exec, config_file='', lines_out=6):
131+
def enqueue_output(out, queue):
132+
for line in iter(out.readline, b''):
133+
queue.put(line)
134+
out.close()
135+
136+
def launch_FVP_IRIS(model_exec, config_file=''):
132137
"""Launch FVP with IRIS Server listening"""
133138
cmd_line = [model_exec, '-I', '-p']
134139
if config_file:
135140
cmd_line.extend(['-f' , config_file])
136-
fm_proc = Popen(cmd_line,stdout=PIPE,stderr=STDOUT)
141+
fm_proc = Popen(cmd_line,stdout=PIPE,stderr=STDOUT, close_fds=ON_POSIX)
142+
out_q = Queue()
143+
reader_t = Thread(target=enqueue_output, args=(fm_proc.stdout, out_q))
144+
reader_t.daemon = True
145+
reader_t.start()
137146

138147
stdout=''
139148
port = 0
140-
141-
for num in range(lines_out):
142-
line = fm_proc.stdout.readline().decode()
143-
if line.startswith("Iris server started listening to port"):
144-
port = int(line[-5:])
145-
stdout += line
149+
end = False
150+
151+
while not end:
152+
try: line = out_q.get(timeout=1).decode().strip()
153+
except Empty:
154+
end = True
155+
else:
156+
if line.startswith("Iris server started listening to port"):
157+
port = int(line[-5:])
158+
stdout = stdout + line + "\n"
146159

147160
return (fm_proc, port, stdout)

0 commit comments

Comments
 (0)