33import logging
44import time
55
6- from pubsub import pub # type: ignore[import-untyped]
7-
8- from meshtastic .protobuf import portnums_pb2
9- from meshtastic .protobuf .powermon_pb2 import PowerStressMessage
6+ from ..protobuf import ( portnums_pb2 , powermon_pb2 )
107
118
129def onPowerStressResponse (packet , interface ):
@@ -20,7 +17,7 @@ class PowerStressClient:
2017 The client stub for talking to the firmware PowerStress module.
2118 """
2219
23- def __init__ (self , iface , node_id = None ):
20+ def __init__ (self , iface , node_id = None ):
2421 """
2522 Create a new PowerStressClient instance.
2623
@@ -31,14 +28,18 @@ def __init__(self, iface, node_id = None):
3128 if not node_id :
3229 node_id = iface .myInfo .my_node_num
3330
34- self .node_id = node_id
31+ self .node_id = node_id
3532 # No need to subscribe - because we
3633 # pub.subscribe(onGPIOreceive, "meshtastic.receive.powerstress")
3734
3835 def sendPowerStress (
39- self , cmd : PowerStressMessage .Opcode .ValueType , num_seconds : float = 0.0 , onResponse = None
36+ self ,
37+ cmd : powermon_pb2 .PowerStressMessage .Opcode .ValueType ,
38+ num_seconds : float = 0.0 ,
39+ onResponse = None ,
4040 ):
41- r = PowerStressMessage ()
41+ """Client goo for talking with the device side agent."""
42+ r = powermon_pb2 .PowerStressMessage ()
4243 r .cmd = cmd
4344 r .num_seconds = num_seconds
4445
@@ -49,16 +50,16 @@ def sendPowerStress(
4950 wantAck = True ,
5051 wantResponse = True ,
5152 onResponse = onResponse ,
52- onResponseAckPermitted = True
53+ onResponseAckPermitted = True ,
5354 )
5455
56+
5557class PowerStress :
5658 """Walk the UUT through a set of power states so we can capture repeatable power consumption measurements."""
5759
5860 def __init__ (self , iface ):
5961 self .client = PowerStressClient (iface )
6062
61-
6263 def run (self ):
6364 """Run the power stress test."""
6465 # Send the power stress command
@@ -68,11 +69,13 @@ def onResponse(packet: dict): # pylint: disable=unused-argument
6869 nonlocal gotAck
6970 gotAck = True
7071
71- logging .info ("Starting power stress test, attempting to contact UUT..." )
72- self .client .sendPowerStress (PowerStressMessage .PRINT_INFO , onResponse = onResponse )
72+ logging .info ("Starting power stress test, attempting to contact UUT..." )
73+ self .client .sendPowerStress (
74+ powermon_pb2 .PowerStressMessage .PRINT_INFO , onResponse = onResponse
75+ )
7376
7477 # Wait for the response
7578 while not gotAck :
7679 time .sleep (0.1 )
7780
78- logging .info ("Power stress test complete." )
81+ logging .info ("Power stress test complete." )
0 commit comments