Skip to content

Commit c049433

Browse files
authored
Merge pull request #607 from geeksville/pr-powermon
PowerMon/StructuredLogging support
2 parents 62cfe2d + 6332798 commit c049433

34 files changed

Lines changed: 3708 additions & 180 deletions

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313
strategy:
1414
matrix:
1515
python-version:
16-
- "3.8"
1716
- "3.9"
1817
- "3.10"
1918
- "3.11"
@@ -56,7 +55,6 @@ jobs:
5655
strategy:
5756
matrix:
5857
python-version:
59-
- "3.8"
6058
- "3.9"
6159
- "3.10"
6260
- "3.11"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ __pycache__
1616
examples/__pycache__
1717
meshtastic.spec
1818
.hypothesis/
19-
coverage.xml
19+
coverage.xml
20+
.ipynb_checkpoints

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ignore-patterns=mqtt_pb2.py,channel_pb2.py,telemetry_pb2.py,admin_pb2.py,config_
2323
# no Warning level messages displayed, use"--disable=all --enable=classes
2424
# --disable=W"
2525
#
26-
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
26+
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
2727

2828
[BASIC]
2929

.vscode/launch.json

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"configurations": [
77
{
88
"name": "meshtastic BLE",
9-
"type": "python",
9+
"type": "debugpy",
1010
"request": "launch",
1111
"module": "meshtastic",
1212
"justMyCode": false,
13-
"args": ["--ble", "Meshtastic_9f6e"]
13+
"args": ["--ble", "--info", "--seriallog", "stdout"]
1414
},
1515
{
1616
"name": "meshtastic BLE scan",
@@ -22,63 +22,63 @@
2222
},
2323
{
2424
"name": "meshtastic admin",
25-
"type": "python",
25+
"type": "debugpy",
2626
"request": "launch",
2727
"module": "meshtastic",
2828
"justMyCode": true,
2929
"args": ["--debug", "--setch-longslow", "--port", "/dev/ttyUSB1"]
3030
},
3131
{
3232
"name": "meshtastic tunnel",
33-
"type": "python",
33+
"type": "debugpy",
3434
"request": "launch",
3535
"module": "meshtastic",
3636
"justMyCode": true,
3737
"args": ["--tunnel", "--debug"]
3838
},
3939
{
4040
"name": "meshtastic set chan",
41-
"type": "python",
41+
"type": "debugpy",
4242
"request": "launch",
4343
"module": "meshtastic",
4444
"justMyCode": true,
4545
"args": ["--setchan", "psk", "0x1a1a1a1a2b2b2b2b1a1a1a1a2b2b2b2b1a1a1a1a2b2b2b2b1a1a1a1a2b2b2b2b", "--debug"]
4646
},
4747
{
4848
"name": "meshtastic debug",
49-
"type": "python",
49+
"type": "debugpy",
5050
"request": "launch",
5151
"module": "meshtastic",
5252
"justMyCode": true,
5353
"args": ["--debug"]
5454
},
5555
{
5656
"name": "meshtastic listen",
57-
"type": "python",
57+
"type": "debugpy",
5858
"request": "launch",
5959
"module": "meshtastic",
6060
"justMyCode": true,
6161
"args": ["--listen", "--debug"]
6262
},
6363
{
6464
"name": "meshtastic debug getPref",
65-
"type": "python",
65+
"type": "debugpy",
6666
"request": "launch",
6767
"module": "meshtastic",
6868
"justMyCode": true,
6969
"args": ["--debug", "--get", "power.is_power_saving"]
7070
},
7171
{
7272
"name": "meshtastic debug getPref telemetry",
73-
"type": "python",
73+
"type": "debugpy",
7474
"request": "launch",
7575
"module": "meshtastic",
7676
"justMyCode": true,
7777
"args": ["--debug", "--get", "telemetry.environment_update_interval"]
7878
},
7979
{
8080
"name": "meshtastic debug info",
81-
"type": "python",
81+
"type": "debugpy",
8282
"request": "launch",
8383
"module": "meshtastic",
8484
"justMyCode": true,
@@ -94,71 +94,71 @@
9494
},
9595
{
9696
"name": "meshtastic debug set region",
97-
"type": "python",
97+
"type": "debugpy",
9898
"request": "launch",
9999
"module": "meshtastic",
100100
"justMyCode": true,
101101
"args": ["--debug", "--set", "lora.region", "TW"]
102102
},
103103
{
104104
"name": "meshtastic debug set bluetooth fixed pin",
105-
"type": "python",
105+
"type": "debugpy",
106106
"request": "launch",
107107
"module": "meshtastic",
108108
"justMyCode": true,
109109
"args": ["--debug", "--set", "bluetooth.fixed_pin", "555555"]
110110
},
111111
{
112112
"name": "meshtastic debug get bluetooth fixed pin",
113-
"type": "python",
113+
"type": "debugpy",
114114
"request": "launch",
115115
"module": "meshtastic",
116116
"justMyCode": true,
117117
"args": ["--debug", "--get", "bluetooth.fixed_pin"]
118118
},
119119
{
120120
"name": "meshtastic debug setPref",
121-
"type": "python",
121+
"type": "debugpy",
122122
"request": "launch",
123123
"module": "meshtastic",
124124
"justMyCode": true,
125-
"args": ["--debug", "--set", "power.is_power_saving", "1"]
125+
"args": ["--set", "power.powermon_enables", "65527"]
126126
},
127127
{
128128
"name": "meshtastic debug setPref telemetry.environment_measurement_enabled",
129-
"type": "python",
129+
"type": "debugpy",
130130
"request": "launch",
131131
"module": "meshtastic",
132132
"justMyCode": true,
133133
"args": ["--debug", "--set", "telemetry.environment_measurement_enabled", "1"]
134134
},
135135
{
136136
"name": "meshtastic debug setPref telemetry.environment_screen_enabled",
137-
"type": "python",
137+
"type": "debugpy",
138138
"request": "launch",
139139
"module": "meshtastic",
140140
"justMyCode": true,
141141
"args": ["--debug", "--set", "telemetry.environment_screen_enabled", "1"]
142142
},
143143
{
144144
"name": "meshtastic debug setPref telemetry",
145-
"type": "python",
145+
"type": "debugpy",
146146
"request": "launch",
147147
"module": "meshtastic",
148148
"justMyCode": true,
149149
"args": ["--debug", "--set", "telemetry.environment_measurement_enabled", "1"]
150150
},
151151
{
152152
"name": "meshtastic setpref",
153-
"type": "python",
153+
"type": "debugpy",
154154
"request": "launch",
155155
"module": "meshtastic",
156156
"justMyCode": true,
157157
"args": ["--debug", "--setchan", "psk", ""]
158158
},
159159
{
160160
"name": "meshtastic --ch-set",
161-
"type": "python",
161+
"type": "debugpy",
162162
"request": "launch",
163163
"module": "meshtastic",
164164
"justMyCode": true,
@@ -167,7 +167,7 @@
167167

168168
{
169169
"name": "meshtastic seturl",
170-
"type": "python",
170+
"type": "debugpy",
171171
"request": "launch",
172172
"module": "meshtastic",
173173
"justMyCode": true,
@@ -176,39 +176,63 @@
176176
},
177177
{
178178
"name": "meshtastic shell",
179-
"type": "python",
179+
"type": "debugpy",
180180
"request": "launch",
181181
"module": "meshtastic",
182-
"justMyCode": true,
183-
"args": ["--debug", "--seriallog"]
182+
"justMyCode": false,
183+
"args": ["--noproto", "--seriallog", "stdout"]
184+
},
185+
{
186+
"name": "meshtastic powermon sim",
187+
"type": "debugpy",
188+
"request": "launch",
189+
"module": "meshtastic",
190+
"justMyCode": false,
191+
"args": ["--slog-out", "default", "--power-sim", "--power-voltage", "3.3", "--port", "/dev/ttyUSB0", "--noproto", "--seriallog", "stdout"]
192+
},
193+
{
194+
"name": "meshtastic powermon ppk2",
195+
"type": "debugpy",
196+
"request": "launch",
197+
"module": "meshtastic",
198+
"justMyCode": false,
199+
"args": ["--slog-out", "default", "--power-ppk2-meter", "--power-wait", "--power-voltage", "3.3", "--noproto", "--seriallog", "stdout"]
200+
},
201+
{
202+
"name": "meshtastic stress ppk2",
203+
"type": "debugpy",
204+
"request": "launch",
205+
"module": "meshtastic",
206+
"justMyCode": false,
207+
"args": ["--slog-out", "default", "--power-ppk2-meter", "--power-stress", "--power-voltage", "3.3", "--seriallog"]
184208
},
185209
{
186210
"name": "meshtastic test",
187-
"type": "python",
211+
"type": "debugpy",
188212
"request": "launch",
189213
"module": "meshtastic",
190214
"justMyCode": true,
191215
"args": ["--debug", "--test"]
192216
},
193217
{
194218
"name": "meshtastic settime",
195-
"type": "python",
219+
"type": "debugpy",
196220
"request": "launch",
197221
"module": "meshtastic",
198222
"justMyCode": true,
199223
"args": ["--debug", "--settime"]
200224
},
201225
{
202226
"name": "meshtastic sendtext",
203-
"type": "python",
227+
"type": "debugpy",
204228
"request": "launch",
205229
"module": "meshtastic",
206230
"justMyCode": true,
207231
"args": ["--debug", "--sendtext", "pytest"]
208232
},
209233
{
210234
"name": "meshtastic showNodes",
211-
"type": "python",
235+
"type": "debugpy",
212236
"request": "launch",
213237
"module": "meshtastic",
214238
"justMyCode": true,

.vscode/settings.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
{
22
"cSpell.words": [
3+
"bitmask",
4+
"boardid",
35
"Meshtastic",
6+
"milliwatt",
7+
"portnums",
8+
"powermon",
9+
"POWERSTRESS",
10+
"pyarrow",
411
"TORADIO",
512
"Vids"
613
],
7-
"python.pythonPath": "/usr/bin/python3"
14+
"python.pythonPath": "/usr/bin/python3",
15+
"flake8.enabled" : false // we are using trunk for formatting/linting rules, don't yell at us about line length
816
}

bin/prerelease-tests.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ set -e
22

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

5+
echo "Linting"
6+
poetry run pylint meshtastic examples/ --ignore-patterns ".*_pb2.pyi?$"
7+
8+
echo "Checking types"
9+
poetry run mypy meshtastic/
10+
511
echo "Running (crude) prerelease tests to verify sanity"
612

713
# Use the python environment created by poetry

meshtastic/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- meshtastic.receive.user(packet)
3232
- meshtastic.receive.data.portnum(packet) (where portnum is an integer or well known PortNum enum)
3333
- meshtastic.node.updated(node = NodeInfo) - published when a node in the DB changes (appears, location changed, username changed, etc...)
34+
- meshtastic.log.line(line) - a raw unparsed log line from the radio
3435
3536
We receive position, user, or data packets from the mesh. You probably only care about meshtastic.receive.data. The first argument for
3637
that publish will be the packet. Text or binary data packets (from sendData or sendText) will both arrive this way. If you print packet
@@ -96,6 +97,7 @@ def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect
9697
remote_hardware_pb2,
9798
storeforward_pb2,
9899
telemetry_pb2,
100+
powermon_pb2
99101
)
100102
from . import (
101103
util,
@@ -228,6 +230,9 @@ def _receiveInfoUpdate(iface, asDict):
228230
portnums_pb2.PortNum.TRACEROUTE_APP: KnownProtocol(
229231
"traceroute", mesh_pb2.RouteDiscovery
230232
),
233+
portnums_pb2.PortNum.POWERSTRESS_APP: KnownProtocol(
234+
"powerstress", powermon_pb2.PowerStressMessage
235+
),
231236
portnums_pb2.PortNum.WAYPOINT_APP: KnownProtocol("waypoint", mesh_pb2.Waypoint),
232237
portnums_pb2.PortNum.PAXCOUNTER_APP: KnownProtocol("paxcounter", paxcount_pb2.Paxcount),
233238
portnums_pb2.PortNum.STORE_FORWARD_APP: KnownProtocol("storeforward", storeforward_pb2.StoreAndForward),

0 commit comments

Comments
 (0)