8000 monitor: add Pico comms messages. · lucid281/micropython-async@057ae66 · GitHub
[go: up one dir, main page]

Skip to content

Commit 057ae66

Browse files
committed
monitor: add Pico comms messages.
1 parent 58a2bf2 commit 057ae66

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

v3/as_demos/monitor/README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ and `bar` tasks.
2828
### Breaking changes to support SPI
2929

3030
The `set_uart` method is replaced by `set_device`. Pin mappings on the Pico
31-
have changed.
31+
have changed. Barring bug fixes or user suggestions I consider this project to
32+
be complete.
3233

3334
## 1.1 Pre-requisites
3435

@@ -134,6 +135,9 @@ going pulse is produced on pin 28, along with the console message "Hog". The
134135
pulse can be used to trigger a scope or logic analyser. The duration of the
135136
timer may be adjusted - see [section 4](./README.md~4-the-pico-code).
136137

138+
Note that hog detection will be triggered if the host application terminates.
139+
The Pico cannot determine the reason why the `hog_detect` task has stopped.
140+
137141
# 2. Monitoring synchronous code
138142

139143
In general there are easier ways to debug synchronous code. However in the
@@ -218,12 +222,16 @@ Monitoring via the UART with default behaviour is started as follows:
218222
from monitor_pico import run
219223
run()
220224
```
221-
By default the Pico does not produce console output and the timer has a period
222-
of 100ms - pin 28 will pulse if ident 0 is inactive for over 100ms. These
223-
behaviours can be modified by the following `run` args:
225+
By default the Pico does not produce console output when tasks start and end.
226+
The timer has a period of 100ms - pin 28 will pulse if ident 0 is inactive for
227+
over 100ms. These behaviours can be modified by the following `run` args:
224228
1. `period=100` Define the hog_detect timer period in ms.
225-
2. `verbose=()` Determines which `ident` values should produce console output.
229+
2. `verbose=()` A list or tuple of `ident` values which should produce console
230+
output.
226231
3. `device="uart"` Set to "spi" for an SPI interface.
232+
4. `vb=True` By default the Pico issues console messages reporting on initial
233+
communication status, repeated each time the application under test restarts.
234+
Set `False` to disable these messages.
227235

228236
Thus to run such that idents 4 and 7 produce console output, with hogging
229237
reported if blocking is for more than 60ms, issue

v3/as_demos/monitor/monitor_pico.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _cb(_):
7272
# native reduced latency to 10μs but killed the hog detector: timer never timed out.
7373
# Also locked up Pico so ctrl-c did not interrupt.
7474
#@micropython.native
75-
def run(period=100, verbose=[], device="uart"):
75+
def run(period=100, verbose=(), device="uart", vb=True):
7676
global t_ms
7777
t_ms = period
7878
for x in verbose:
@@ -91,9 +91,11 @@ def read():
9191
else:
9292
raise ValueError("Unsupported device:", device)
9393

94+
vb and print('Awaiting communication')
9495
while True:
9596
if x := read(): # Get an initial 0 on UART
9697
if x == 0x7a: # Init: program under test has restarted
98+
vb and print('Got communication.')
9799
for pin in pins:
98100
pin[1] = 0
99101
continue

0 commit comments

Comments
 (0)
0