Index: systrace/systrace/tracing_controller.py |
diff --git a/systrace/systrace/tracing_controller.py b/systrace/systrace/tracing_controller.py |
index d0d2d7c3735988f4b4904a0a980ae87baeee86c7..cf3764e09a9868668f1b67af78c89320c39682dc 100644 |
--- a/systrace/systrace/tracing_controller.py |
+++ b/systrace/systrace/tracing_controller.py |
@@ -18,6 +18,7 @@ import uuid |
from systrace import trace_result |
from systrace import tracing_agents |
+from systrace.tracing_agents import monsoon_agent |
from py_trace_event import trace_event |
@@ -117,9 +118,28 @@ class TracingController(object): |
self._child_agents_with_config = agents_with_config |
self._controller_agent = TracingControllerAgent() |
self._controller_config = controller_config |
+ self._monsoon_agent = None |
self._trace_in_progress = False |
self.all_results = None |
+ # If we have a monsoon power monitor controller in the group, make an |
Chris Craik
2017/09/19 18:47:02
I'm not especially happy with this, but I don't ha
Zhen Wang
2017/09/19 23:53:50
I see --usbpassthrough is set to off for monsoon.
|
+ # explicit reference to it. We need to collect data from it before any |
+ # other collectors as it re-enables USB for the subsequent collectors to |
+ # collect their data. |
+ # In addition, move this agent to the end of the list so it is the last |
+ # to start (it disables USB). |
+ monsoon_agent_with_config = None |
+ sorted_agents_with_config = [] |
+ for agent_with_config in self._child_agents_with_config: |
+ if isinstance(agent_with_config.agent, monsoon_agent.MonsoonTracingAgent): |
+ monsoon_agent_with_config = agent_with_config |
+ else: |
+ sorted_agents_with_config.append(agent_with_config) |
+ if monsoon_agent_with_config: |
+ sorted_agents_with_config.append(monsoon_agent_with_config) |
+ self._monsoon_agent = monsoon_agent_with_config.agent |
+ self._child_agents_with_config = sorted_agents_with_config |
+ |
@property |
def get_child_agents(self): |
return self._child_agents |
@@ -163,6 +183,7 @@ class TracingController(object): |
if ns < na: |
print 'Warning: Only %d of %d tracing agents started.' % (ns, na) |
self._child_agents = succ_agents |
+ |
return True |
def StopTracing(self): |
@@ -179,6 +200,13 @@ class TracingController(object): |
assert self._trace_in_progress, 'No trace in progress.' |
self._trace_in_progress = False |
+ # Explicity stop Monsoon tracing first, as it re-enables USB. |
+ if self._monsoon_agent: |
+ sync_id = GetUniqueSyncID() |
+ if not self._monsoon_agent.StopCollectionWithClockSync(sync_id, |
+ ControllerAgentClockSync): |
+ print 'Monsoon agent failed to stop collection.' |
+ |
# Issue the clock sync marker and stop the child tracing agents. |
self._IssueClockSyncMarker() |
succ_agents = [] |