Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerMon/StructuredLogging support #607

Merged
merged 64 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b41cb7d
Merge branch 'pr-poetry' into powermon
geeksville Jun 22, 2024
a3462e0
didn't mean to check in built protobufs
geeksville Jun 25, 2024
338f00a
minor cleanup on observable
geeksville Jun 22, 2024
21e5601
run linter as part of prerelease tests
geeksville Jun 22, 2024
a1f86a3
add typing hints
geeksville Jun 22, 2024
cc60f3e
begin support for multiple power meter types
geeksville Jun 22, 2024
362c1f3
remove python 3.8
geeksville Jun 22, 2024
be74c3e
fix linter warnings
geeksville Jun 22, 2024
0e45637
generalize the powermon stuff to become structured logging
geeksville Jun 22, 2024
79c65c1
make slog nicely add new rows
geeksville Jun 22, 2024
9c657c6
switch to latest protobufs
geeksville Jun 23, 2024
51c6c2c
The github action for building protobufs is using 0.4.6 so we should …
geeksville Jun 23, 2024
67e1e7c
move mypy and type info into dev-time only dependencies thx @njh
geeksville Jun 25, 2024
46edd78
For poetry change: need to put venv in our path so mypy protobuf plug…
geeksville Jun 25, 2024
7b18fd5
remove observable - switch because we are already using pubsub elsewhere
geeksville Jun 23, 2024
b7f7a40
document why using python 3.9
geeksville Jun 23, 2024
6c0e978
debugging config tweaks
geeksville Jun 23, 2024
8b781d3
fix #610: bump nanopb to 0.4.8
geeksville Jun 23, 2024
1add293
Add a whitelist of known meshtastic USB VIDs to use a default serial …
geeksville Jun 19, 2024
5ff4025
add NordicSemi Power Profiler Kit 2 device to the USB blacklist
geeksville Jun 24, 2024
ea18057
Add support for NRF PPK2 power testing board.
geeksville Jun 24, 2024
26a672e
ppk2 tweaks
geeksville Jun 24, 2024
dc8348b
add (optional) poe tool config for easy running of external commands
geeksville Jun 24, 2024
43e1f65
"python" is deprecated vscode now wants "pydebug"
geeksville Jun 24, 2024
7ce7d73
Switch from pandas to apache arrow for live data logging (better stre…
geeksville Jun 24, 2024
91066f6
add powermon_sim support
geeksville Jun 25, 2024
9cdfde4
store slogs in correct default directory (OS dependent)
geeksville Jun 25, 2024
c656171
don't let daemon keep process alive
geeksville Jun 25, 2024
07fc991
clean up slog closing
geeksville Jun 25, 2024
1b045be
fix linter warnings
geeksville Jun 25, 2024
8d94458
flake8 has different settings than trunk, don't confict in vscode
geeksville Jun 25, 2024
9b61f11
temporarily suppress warning about main.py being too long
geeksville Jun 25, 2024
2202414
more fighting with trunk
geeksville Jun 25, 2024
402622f
fix type warnings
geeksville Jun 25, 2024
d448ea5
keep a symbolic link "latest" that points to the latest slog dir
geeksville Jun 25, 2024
d1aadf0
close power meter gracefully
geeksville Jun 25, 2024
f8ad4fe
deferred execution thread should be named and marked as daemon
geeksville Jun 25, 2024
ff20ad5
group power options in --help. add --power-wait to support some boards
geeksville Jun 25, 2024
231bc25
PPK2 based power measurements seem to approximately work
geeksville Jun 25, 2024
4ca9aa2
beginnings of meshtastic.analysis
geeksville Jun 26, 2024
8761b32
Merge remote-tracking branch 'root/master' into pr-powermon
geeksville Jun 26, 2024
b063d33
don't git jupyter temp directories
geeksville Jun 26, 2024
ef4b534
Merge branch 'pr-moveproto' into pr-powermon
geeksville Jun 26, 2024
f2c4274
Update protobufs to master (required for powermon stuff)
geeksville Jun 26, 2024
320bb30
Use .feather files as our long-term representation
geeksville Jun 26, 2024
047a56d
speed up file writing
geeksville Jun 26, 2024
715a085
add more dataviz tooling
geeksville Jun 26, 2024
1587c31
Merge remote-tracking branch 'root/master' into pr-powermon
geeksville Jun 26, 2024
67bb666
the stock PPK2 API is super inefficient, remove lots of buffering
geeksville Jun 26, 2024
2294546
fix bogus high current reading on first ppk2 read
geeksville Jun 26, 2024
c935123
blacklist hantek oscilliscope
geeksville Jun 27, 2024
119be81
PowerStress WIP
geeksville Jun 27, 2024
dabb4ea
PowerStress client approximately works
geeksville Jun 28, 2024
542f99b
handle the new LogRecord protobufs
geeksville Jun 28, 2024
821d3e9
remvoe unneeded paren
geeksville Jun 29, 2024
42236f2
Merge branch 'ble-logging' into pr-powermon
geeksville Jun 29, 2024
1da687c
move @thebentern spiffy logging so it is shared with !ble log sources
geeksville Jun 29, 2024
13ca8fd
debug launch configs
geeksville Jun 30, 2024
8f98878
Merge branch 'ble-logging' into pr-powermon
geeksville Jun 30, 2024
6da04f7
Merge branch 'pr-bletweak' into pr-powermon
geeksville Jun 30, 2024
2f5a736
Merge remote-tracking branch 'root/master' into pr-powermon
geeksville Jul 3, 2024
ae2ef78
fix linter warnings
geeksville Jul 3, 2024
5695ec7
change --slog to use nargs
geeksville Jul 3, 2024
6332798
fix incorrect Vid - thanks @ianmcorvidae for notixing.
geeksville Jul 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
Expand Down Expand Up @@ -56,7 +55,6 @@ jobs:
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ __pycache__
examples/__pycache__
meshtastic.spec
.hypothesis/
coverage.xml
coverage.xml
.ipynb_checkpoints
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ignore-patterns=mqtt_pb2.py,channel_pb2.py,telemetry_pb2.py,admin_pb2.py,config_
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
#
disable=invalid-name,fixme,logging-fstring-interpolation,too-many-statements,too-many-branches,too-many-locals,no-member,f-string-without-interpolation,protected-access,pointless-string-statement,too-few-public-methods,broad-except,no-else-return,no-else-raise,bare-except,too-many-public-methods
disable=invalid-name,fixme,logging-fstring-interpolation,too-many-statements,too-many-branches,too-many-locals,no-member,f-string-without-interpolation,protected-access,pointless-string-statement,too-few-public-methods,broad-except,no-else-return,no-else-raise,bare-except,too-many-public-methods,nested-min-max

[BASIC]

Expand Down
80 changes: 52 additions & 28 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"configurations": [
{
"name": "meshtastic BLE",
"type": "python",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(comment at random line in file)

I know basically nothing about vscode so I'm just gonna trust that these settings make sense. If someone else who actually uses vscode wants to validate, feel free.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yah - these are just vscode warned me that "python" is deprecated and the new recommended string is pydebug...

"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": false,
"args": ["--ble", "Meshtastic_9f6e"]
"args": ["--ble", "--info", "--seriallog", "stdout"]
},
{
"name": "meshtastic BLE scan",
Expand All @@ -22,63 +22,63 @@
},
{
"name": "meshtastic admin",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--setch-longslow", "--port", "/dev/ttyUSB1"]
},
{
"name": "meshtastic tunnel",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--tunnel", "--debug"]
},
{
"name": "meshtastic set chan",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--setchan", "psk", "0x1a1a1a1a2b2b2b2b1a1a1a1a2b2b2b2b1a1a1a1a2b2b2b2b1a1a1a1a2b2b2b2b", "--debug"]
},
{
"name": "meshtastic debug",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug"]
},
{
"name": "meshtastic listen",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--listen", "--debug"]
},
{
"name": "meshtastic debug getPref",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--get", "power.is_power_saving"]
},
{
"name": "meshtastic debug getPref telemetry",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--get", "telemetry.environment_update_interval"]
},
{
"name": "meshtastic debug info",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
Expand All @@ -94,71 +94,71 @@
},
{
"name": "meshtastic debug set region",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--set", "lora.region", "TW"]
},
{
"name": "meshtastic debug set bluetooth fixed pin",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--set", "bluetooth.fixed_pin", "555555"]
},
{
"name": "meshtastic debug get bluetooth fixed pin",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--get", "bluetooth.fixed_pin"]
},
{
"name": "meshtastic debug setPref",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--set", "power.is_power_saving", "1"]
"args": ["--set", "power.powermon_enables", "65527"]
},
{
"name": "meshtastic debug setPref telemetry.environment_measurement_enabled",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--set", "telemetry.environment_measurement_enabled", "1"]
},
{
"name": "meshtastic debug setPref telemetry.environment_screen_enabled",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--set", "telemetry.environment_screen_enabled", "1"]
},
{
"name": "meshtastic debug setPref telemetry",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--set", "telemetry.environment_measurement_enabled", "1"]
},
{
"name": "meshtastic setpref",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--setchan", "psk", ""]
},
{
"name": "meshtastic --ch-set",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
Expand All @@ -167,7 +167,7 @@

{
"name": "meshtastic seturl",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
Expand All @@ -176,39 +176,63 @@
},
{
"name": "meshtastic shell",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--seriallog"]
"justMyCode": false,
"args": ["--noproto", "--seriallog", "stdout"]
},
{
"name": "meshtastic powermon sim",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": false,
"args": ["--slog-out", "default", "--power-sim", "--power-voltage", "3.3", "--port", "/dev/ttyUSB0", "--noproto", "--seriallog", "stdout"]
},
{
"name": "meshtastic powermon ppk2",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": false,
"args": ["--slog-out", "default", "--power-ppk2-meter", "--power-wait", "--power-voltage", "3.3", "--noproto", "--seriallog", "stdout"]
},
{
"name": "meshtastic stress ppk2",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": false,
"args": ["--slog-out", "default", "--power-ppk2-meter", "--power-stress", "--power-voltage", "3.3", "--seriallog"]
},
{
"name": "meshtastic test",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--test"]
},
{
"name": "meshtastic settime",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--settime"]
},
{
"name": "meshtastic sendtext",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--sendtext", "pytest"]
},
{
"name": "meshtastic showNodes",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
Expand Down
10 changes: 9 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
{
"cSpell.words": [
"bitmask",
"boardid",
"Meshtastic",
"milliwatt",
"portnums",
"powermon",
"POWERSTRESS",
"pyarrow",
"TORADIO",
"Vids"
],
"python.pythonPath": "/usr/bin/python3"
"python.pythonPath": "/usr/bin/python3",
"flake8.enabled" : false // we are using trunk for formatting/linting rules, don't yell at us about line length
}
6 changes: 6 additions & 0 deletions bin/prerelease-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ set -e

# You may consider running: "pytest -m smoke1" instead of this test.

echo "Linting"
poetry run pylint meshtastic examples/ --ignore-patterns ".*_pb2.pyi?$"

echo "Checking types"
poetry run mypy meshtastic/

echo "Running (crude) prerelease tests to verify sanity"

# Use the python environment created by poetry
Expand Down
5 changes: 5 additions & 0 deletions meshtastic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- meshtastic.receive.user(packet)
- meshtastic.receive.data.portnum(packet) (where portnum is an integer or well known PortNum enum)
- meshtastic.node.updated(node = NodeInfo) - published when a node in the DB changes (appears, location changed, username changed, etc...)
- meshtastic.log.line(line) - a raw unparsed log line from the radio
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was mentioning before, I think I might change this, if that's okay (would do after merge, and I'd update the spot you've used it as well) -- I'd be changing it to pass the whole LogRecord as a dict, so that folks can pull out the message, level, and time/source (if those are provided) separately and do with them as they will. This will also mean I can have ble_interface output this same message and move all the log printing/colorizing stuff to one place, hopefully.

Copy link
Member Author

@geeksville geeksville Jul 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - I agree, LogRecord is what should be passed (using the automatic KnownProtocol translation). IMO coloring should be done at the end and only for the stdout printer when it is going to an interactive terminal.

We receive position, user, or data packets from the mesh. You probably only care about meshtastic.receive.data. The first argument for
that publish will be the packet. Text or binary data packets (from sendData or sendText) will both arrive this way. If you print packet
Expand Down Expand Up @@ -96,6 +97,7 @@ def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect
remote_hardware_pb2,
storeforward_pb2,
telemetry_pb2,
powermon_pb2
)
from . import (
util,
Expand Down Expand Up @@ -228,6 +230,9 @@ def _receiveInfoUpdate(iface, asDict):
portnums_pb2.PortNum.TRACEROUTE_APP: KnownProtocol(
"traceroute", mesh_pb2.RouteDiscovery
),
portnums_pb2.PortNum.POWERSTRESS_APP: KnownProtocol(
"powerstress", powermon_pb2.PowerStressMessage
),
portnums_pb2.PortNum.WAYPOINT_APP: KnownProtocol("waypoint", mesh_pb2.Waypoint),
portnums_pb2.PortNum.PAXCOUNTER_APP: KnownProtocol("paxcounter", paxcount_pb2.Paxcount),
portnums_pb2.PortNum.STORE_FORWARD_APP: KnownProtocol("storeforward", storeforward_pb2.StoreAndForward),
Expand Down
Loading
Loading