@@ -65,7 +65,9 @@ def onResponse(packet: dict): # pylint: disable=unused-argument
6565 nonlocal gotAck
6666 gotAck = True
6767
68- logging .info (f"Sending power stress command { powermon_pb2 .PowerStressMessage .Opcode .Name (cmd )} " )
68+ logging .info (
69+ f"Sending power stress command { powermon_pb2 .PowerStressMessage .Opcode .Name (cmd )} "
70+ )
6971 self .sendPowerStress (cmd , onResponse = onResponse , num_seconds = num_seconds )
7072
7173 if num_seconds == 0.0 :
@@ -74,12 +76,13 @@ def onResponse(packet: dict): # pylint: disable=unused-argument
7476 time .sleep (0.1 )
7577 else :
7678 # we wait a little bit longer than the time the UUT would be waiting (to make sure all of its messages are handled first)
77- time .sleep (num_seconds + 0.2 ) # completely block our thread for the duration of the test
79+ time .sleep (
80+ num_seconds + 0.2
81+ ) # completely block our thread for the duration of the test
7882 if not gotAck :
7983 logging .error ("Did not receive ack for power stress command!" )
8084
8185
82-
8386class PowerStress :
8487 """Walk the UUT through a set of power states so we can capture repeatable power consumption measurements."""
8588
@@ -88,24 +91,27 @@ def __init__(self, iface):
8891
8992 def run (self ):
9093 """Run the power stress test."""
91- # Send the power stress command
92-
93- self .client .syncPowerStress (powermon_pb2 .PowerStressMessage .PRINT_INFO )
94-
95- num_seconds = 5.0
96- states = [
97- powermon_pb2 .PowerStressMessage .LED_ON ,
98- powermon_pb2 .PowerStressMessage .LED_OFF ,
99- powermon_pb2 .PowerStressMessage .BT_OFF ,
100- powermon_pb2 .PowerStressMessage .BT_ON ,
101- powermon_pb2 .PowerStressMessage .CPU_FULLON ,
102- powermon_pb2 .PowerStressMessage .CPU_IDLE ,
103- # FIXME - can't test deepsleep yet because the ttyACM device disappears. Fix the python code to retry connections
104- # powermon_pb2.PowerStressMessage.CPU_DEEPSLEEP,
105- ]
106- for s in states :
107- s_name = powermon_pb2 .PowerStressMessage .Opcode .Name (s )
108- logging .info (f"Running power stress test { s_name } for { num_seconds } seconds" )
109- self .client .syncPowerStress (s , num_seconds )
110-
111- logging .info ("Power stress test complete." )
94+ try :
95+ self .client .syncPowerStress (powermon_pb2 .PowerStressMessage .PRINT_INFO )
96+
97+ num_seconds = 5.0
98+ states = [
99+ powermon_pb2 .PowerStressMessage .LED_ON ,
100+ powermon_pb2 .PowerStressMessage .LED_OFF ,
101+ powermon_pb2 .PowerStressMessage .BT_OFF ,
102+ powermon_pb2 .PowerStressMessage .BT_ON ,
103+ powermon_pb2 .PowerStressMessage .CPU_FULLON ,
104+ powermon_pb2 .PowerStressMessage .CPU_IDLE ,
105+ # FIXME - can't test deepsleep yet because the ttyACM device disappears. Fix the python code to retry connections
106+ # powermon_pb2.PowerStressMessage.CPU_DEEPSLEEP,
107+ ]
108+ for s in states :
109+ s_name = powermon_pb2 .PowerStressMessage .Opcode .Name (s )
110+ logging .info (
111+ f"Running power stress test { s_name } for { num_seconds } seconds"
112+ )
113+ self .client .syncPowerStress (s , num_seconds )
114+
115+ logging .info ("Power stress test complete." )
116+ except KeyboardInterrupt as e :
117+ logging .warning (f"Power stress interrupted: { e } " )
0 commit comments