Skip to content

Commit 47944b2

Browse files
committed
Provide monitor.init.
1 parent 4967b68 commit 47944b2

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

v3/as_demos/monitor/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ Example script `quick_test.py` provides a usage example.
3333

3434
An application to be monitored typically has the following setup code:
3535
```python
36-
from monitor import monitor, hog_detect, set_uart
36+
from monitor import monitor, monitor_init, hog_detect, set_uart
3737
set_uart(2) # Define device under test UART no.
3838
```
39-
39+
On application start it should issue
40+
```python
41+
monitor_init()
42+
```
4043
Coroutines to be monitored are prefixed with the `@monitor` decorator:
4144
```python
4245
@monitor(2, 3)

v3/as_demos/monitor/monitor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ async def wrapped_coro(*args, **kwargs):
5252
return wrapped_coro
5353
return decorator
5454

55+
def monitor_init():
56+
uart.write(b'z')
57+
5558
# Optionally run this to show up periods of blocking behaviour
5659
@monitor(0)
5760
async def _do_nowt():

v3/as_demos/monitor/monitor_pico.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ def run(period=100, verbose=[]):
3939
while not uart.any():
4040
pass
4141
x = ord(uart.read(1))
42-
#print('got', chr(x)) gets CcAa
4342
if not 0x40 <= x <= 0x7f: # Get an initial 0
4443
continue
44+
if x == 0x7a: # Init: program under test has restarted
45+
for w in range(len(pins)):
46+
pins[w][1] = 0
47+
continue
4548
if x == 0x40:
4649
tim.init(period=t_ms, mode=Timer.ONE_SHOT, callback=_cb)
4750
i = x & 0x1f # Key: 0x40 (ord('@')) is pin ID 0

v3/as_demos/monitor/monitor_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# monitor_test.py
22

33
import uasyncio as asyncio
4-
from monitor import monitor, mon_func, mon_call, set_uart
4+
from monitor import monitor, monitor_init, mon_func, mon_call, set_uart
55

66
set_uart(2) # Define interface to use
77

@@ -36,6 +36,7 @@ def another_sync_func():
3636
pass
3737

3838
async def main():
39+
monitor_init()
3940
sync_func()
4041
with mon_call(22):
4142
another_sync_func()

v3/as_demos/monitor/quick_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import uasyncio as asyncio
44
import time
5-
from monitor import monitor, hog_detect, set_uart
5+
from monitor import monitor, monitor_init, hog_detect, set_uart
66

77
set_uart(2) # Define interface to use
88

@@ -21,6 +21,7 @@ async def bar(t):
2121

2222

2323
async def main():
24+
monitor_init()
2425
asyncio.create_task(hog_detect())
2526
asyncio.create_task(hog()) # Will hog for 500ms after 5 secs
2627
while True:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy