-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c935123
commit be4e63e
Showing
9 changed files
with
238 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
"""Power stress testing support. | ||
""" | ||
import logging | ||
import time | ||
|
||
from pubsub import pub # type: ignore[import-untyped] | ||
|
||
from meshtastic.protobuf import portnums_pb2 | ||
from meshtastic.protobuf.powermon_pb2 import PowerStressMessage | ||
|
||
|
||
def onPowerStressResponse(packet, interface): | ||
"""Delete me? FIXME""" | ||
logging.debug(f"packet:{packet} interface:{interface}") | ||
# interface.gotResponse = True | ||
|
||
|
||
class PowerStressClient: | ||
""" | ||
The client stub for talking to the firmware PowerStress module. | ||
""" | ||
|
||
def __init__(self, iface, node_id = None): | ||
""" | ||
Create a new PowerStressClient instance. | ||
iface is the already open MeshInterface instance | ||
""" | ||
self.iface = iface | ||
|
||
if not node_id: | ||
node_id = iface.myInfo.my_node_num | ||
|
||
self.node_id = node_id | ||
# No need to subscribe - because we | ||
# pub.subscribe(onGPIOreceive, "meshtastic.receive.powerstress") | ||
|
||
def sendPowerStress( | ||
self, cmd: PowerStressMessage.Opcode.ValueType, num_seconds: float = 0.0, onResponse=None | ||
): | ||
r = PowerStressMessage() | ||
r.cmd = cmd | ||
r.num_seconds = num_seconds | ||
|
||
return self.iface.sendData( | ||
r, | ||
self.node_id, | ||
portnums_pb2.POWERSTRESS_APP, | ||
wantAck=True, | ||
wantResponse=False, | ||
onResponse=onResponse, | ||
onResponseAckPermitted=True | ||
) | ||
|
||
class PowerStress: | ||
"""Walk the UUT through a set of power states so we can capture repeatable power consumption measurements.""" | ||
|
||
def __init__(self, iface): | ||
self.client = PowerStressClient(iface) | ||
|
||
|
||
def run(self): | ||
"""Run the power stress test.""" | ||
# Send the power stress command | ||
gotAck = False | ||
|
||
def onResponse(packet, interface): | ||
nonlocal gotAck | ||
gotAck = True | ||
|
||
logging.info("Starting power stress test, attempting to contact UUT...") | ||
self.client.sendPowerStress(PowerStressMessage.PRINT_INFO, onResponse=onResponse) | ||
|
||
# Wait for the response | ||
while not gotAck: | ||
time.sleep(0.1) | ||
|
||
logging.info("Power stress test complete.") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule protobufs
updated
2 files
+5 −0 | meshtastic/portnums.proto | |
+52 −0 | meshtastic/powermon.proto |