Skip to content

Commit 2709c56

Browse files
committed
Docs: minor fixes.
1 parent 71ebf31 commit 2709c56

File tree

2 files changed

+39
-43
lines changed

2 files changed

+39
-43
lines changed

FASTPOLL.md

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# fast_io: An experimental modified version of uasyncio
1+
# fast_io: A modified version of uasyncio
22

33
MicroPython firmware now enables device drivers for stream devices to be
44
written in Python, via `uio.IOBase`. This mechanism can be applied to any
5-
situation where a piece of hardware or an aysnchronously set flag needs to be
5+
situation where a piece of hardware or an asynchronously set flag needs to be
66
polled. Such polling is efficient because it is handled in C using
77
`select.poll`, and because the coroutine accessing the device is descheduled
88
until polling succeeds.
@@ -16,7 +16,7 @@ This version has the following changes:
1616
[PR287](https://github.com/micropython/micropython-lib/pull/287).
1717
* The bug with read/write device drivers is fixed (forthcoming PR).
1818
* An assertion failure is produced if `create_task` or `run_until_complete`
19-
is called with a generator function [PR292](https://github.com/micropython/micropython-lib/pull/292)
19+
is called with a generator function [PR292](https://github.com/micropython/micropython-lib/pull/292).
2020

2121
A key advantage of this version is that priority device drivers are written
2222
entirely by using the officially-supported technique for writing stream I/O
@@ -25,32 +25,28 @@ means than by these proposals, application code changes are likely to be
2525
minimal. Using the priority mechanism in this version requires a change to just
2626
one line of code compared to an application running under the official version.
2727

28-
The high priority mechanism in `asyncio_priority.py` is replaced with a faster
29-
and more efficient way of handling asynchronous events with minimum latency.
30-
Consequently `asyncio_priority.py` is obsolete and should be deleted from your
31-
system. The facility for low priority coros is currently unavailable.
28+
The high priority mechanism formerly provided in `asyncio_priority.py` is
29+
replaced with a faster and more efficient way of handling asynchronous events
30+
with minimum latency. Consequently `asyncio_priority.py` is obsolete and should
31+
be deleted from your system. The facility for low priority coros is currently
32+
unavailable but will be reinstated.
33+
34+
This modified version also provides for ultra low power consumption using a
35+
module documented [here](./lowpower/README.md).
3236

3337
###### [Main README](./README.md)
3438

3539
# Contents
3640

37-
1. [Installation](./FASTPOLL.md#1-installation)
38-
39-
1.1 [Benchmarks](./FASTPOLL.md#11-benchmarks) Benchmark and demo programs.
40-
41-
2. [Rationale](./FASTPOLL.md#2-rationale)
42-
43-
2.1 [Latency](./FASTPOLL.md#21-latency)
44-
45-
2.2 [Timing accuracy](./FASTPOLL.md#22-timing-accuracy)
46-
47-
2.3 [Polling in uasyncio](./FASTPOLL.md#23-polling-in-usayncio)
48-
49-
3. [The modified version](./FASTPOLL.md#3-the-modified-version)
50-
51-
4. [ESP Platforms](./FASTPOLL.md#4-esp-platforms)
52-
53-
5. [Background](./FASTPOLL.md#4-background)
41+
1. [Installation](./FASTPOLL.md#1-installation)
42+
1.1 [Benchmarks](./FASTPOLL.md#11-benchmarks) Benchmark and demo programs.
43+
2. [Rationale](./FASTPOLL.md#2-rationale)
44+
2.1 [Latency](./FASTPOLL.md#21-latency)
45+
2.2 [Timing accuracy](./FASTPOLL.md#22-timing-accuracy)
46+
2.3 [Polling in uasyncio](./FASTPOLL.md#23-polling-in-usayncio)
47+
3. [The modified version](./FASTPOLL.md#3-the-modified-version)
48+
4. [ESP Platforms](./FASTPOLL.md#4-esp-platforms)
49+
5. [Background](./FASTPOLL.md#4-background)
5450

5551
# 1. Installation
5652

@@ -69,7 +65,7 @@ The benchmarks directory contains files demonstrating the performance gains
6965
offered by prioritisation. They also offer illustrations of the use of these
7066
features. Documentation is in the code.
7167

72-
* ``benchmarks/rate.py` Shows the frequency with which uasyncio schedules
68+
* `benchmarks/rate.py` Shows the frequency with which uasyncio schedules
7369
minimal coroutines (coros).
7470
* `benchmarks/rate_esp.py` As above for ESP32 and ESP8266.
7571
* `benchmarks/rate_fastio.py` Measures the rate at which coros can be scheduled
@@ -126,7 +122,7 @@ have ten instances of `foo()` and one instance of `handle_isr()`. When
126122
`handle_isr()` issues `yield`, its execution will pause for 40ms while each
127123
instance of `foo()` is scheduled and performs one iteration. This may be
128124
unacceptable: it may be necessary to poll and respond to the flag at a rate
129-
suficient to avoid overruns.
125+
sufficient to avoid overruns.
130126

131127
In this version `handle_isr()` would be rewritten as a stream device driver
132128
which could be expected to run with latency of just over 4ms.
@@ -225,7 +221,7 @@ This behaviour may be desired where short bursts of fast data are handled.
225221
Otherwise drivers of such hardware should be designed to avoid hogging, using
226222
techniques like buffering or timing.
227223

228-
The version also supports an `version` variable containing 'fast_io'. This
224+
The version also supports a `version` variable containing 'fast_io'. This
229225
enables the presence of this version to be determined at runtime.
230226

231227
It also supports a `got_event_loop()` function returning a `bool`: `True` if

TUTORIAL.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ asyncio and includes a section for complete beginners.
3838
5. [Interfacing hardware](./TUTORIAL.md#5-interfacing-hardware)
3939
5.1 [Timing issues](./TUTORIAL.md#51-timing-issues)
4040
5.2 [Polling hardware with a coroutine](./TUTORIAL.md#52-polling-hardware-with-a-coroutine)
41-
5.3 [Using the stream mechnanism](./TUTORIAL.md#53-using-the-stream-mechanism)
41+
5.3 [Using the stream mechanism](./TUTORIAL.md#53-using-the-stream-mechanism)
4242
5.3.1 [A UART driver example](./TUTORIAL.md#531-a-uart-driver-example)
4343
5.4 [Writing streaming device drivers](./TUTORIAL.md#54-writing-streaming-device-drivers)
4444
5.5 [A complete example: aremote.py](./TUTORIAL.md#55-a-complete-example-aremotepy)
@@ -86,8 +86,8 @@ Except where detailed below, `asyncio` features of versions >3.4 are
8686
unsupported. As stated above it is a subset; this document identifies supported
8787
features.
8888

89-
This tutoial advocates a consistent programming style with good compatibility
90-
with CPython V3.5 and above.
89+
This tutorial aims to present a consistent programming style compatible with
90+
CPython V3.5 and above.
9191

9292
## 0.1 Installing uasyncio on bare metal
9393

@@ -101,7 +101,7 @@ Libraries to be installed are:
101101
The `queues` and `synchro` modules are optional, but are required to run all
102102
the examples below.
103103

104-
The oficial approach is to use the `upip` utility as described
104+
The official approach is to use the `upip` utility as described
105105
[here](https://github.com/micropython/micropython-lib). Network enabled
106106
hardware has this included in the firmware so it can be run locally. This is
107107
the preferred approach.
@@ -114,7 +114,7 @@ then copying the library to the target.
114114
The need for Linux and the Unix build may be avoided by using
115115
[micropip.py](https://github.com/peterhinch/micropython-samples/tree/master/micropip).
116116
This runs under Python 3.2 or above. Create a temporary directory on your PC
117-
and install to that. Then copy the contents of the temporary direcory to the
117+
and install to that. Then copy the contents of the temporary directory to the
118118
device. The following assume Linux and a temporary directory named `~/syn` -
119119
adapt to suit your OS. The first option requires that `micropip.py` has
120120
executable permission.
@@ -374,7 +374,7 @@ offers "micro" implementations of `Event`, `Barrier`, `Semaphore` and
374374
`Condition` primitives. These are for use only with asyncio. They are not
375375
thread safe and should not be used with the `_thread` module or from an
376376
interrupt handler except where mentioned. A `Lock` primitive is provided which
377-
is an alterantive to the official implementation.
377+
is an alternative to the official implementation.
378378

379379
Another synchronisation issue arises with producer and consumer coros. The
380380
producer generates data which the consumer uses. Asyncio provides the `Queue`
@@ -474,7 +474,7 @@ async def foo(event):
474474
event.set()
475475
```
476476

477-
Where multiple coros wait on a single event synchronisationcan be achieved by
477+
Where multiple coros wait on a single event synchronisation can be achieved by
478478
means of an acknowledge event. Each coro needs a separate event.
479479

480480
```python
@@ -619,7 +619,7 @@ no mechanism for verifying when cancellation has actually occurred. The `asyn`
619619
library provides verification via the following classes:
620620

621621
1. `Cancellable` This allows one or more tasks to be assigned to a group. A
622-
coro can cancel all tasks in the group, pausing until this has been acheived.
622+
coro can cancel all tasks in the group, pausing until this has been achieved.
623623
Documentation may be found [here](./PRIMITIVES.md#42-class-cancellable).
624624
2. `NamedTask` This enables a coro to be associated with a user-defined name.
625625
The running status of named coros may be checked. For advanced usage more
@@ -1095,7 +1095,7 @@ class RecordOrientedUart():
10951095
def __iter__(self): # Not __await__ issue #2678
10961096
data = b''
10971097
while not data.endswith(self.DELIMITER):
1098-
yield from asyncio.sleep(0) # Neccessary because:
1098+
yield from asyncio.sleep(0) # Necessary because:
10991099
while not self.uart.any():
11001100
yield from asyncio.sleep(0) # timing may mean this is never called
11011101
data = b''.join((data, self.uart.read(self.uart.any())))
@@ -1152,7 +1152,7 @@ async def receiver():
11521152
sreader = asyncio.StreamReader(uart)
11531153
while True:
11541154
res = await sreader.readline()
1155-
print('Recieved', res)
1155+
print('Received', res)
11561156

11571157
loop = asyncio.get_event_loop()
11581158
loop.create_task(sender())
@@ -1357,7 +1357,7 @@ application design the [fast_io](./FASTPOLL.md) version can greatly reduce
13571357
this.
13581358

13591359
The demo program `iorw.py` illustrates a complete example. Note that, at the
1360-
time of writing there is a bug in `uasyncio` which prevents this from woking.
1360+
time of writing there is a bug in `uasyncio` which prevents this from working.
13611361
See [this GitHub thread](https://github.com/micropython/micropython/pull/3836#issuecomment-397317408).
13621362
There are two solutions. A workround is to write two separate drivers, one
13631363
read-only and the other write-only. Alternatively the
@@ -1406,7 +1406,7 @@ run while acquisition is in progress.
14061406

14071407
Hanging usually occurs because a task has blocked without yielding: this will
14081408
hang the entire system. When developing it is useful to have a coro which
1409-
periodically toggles an onboard LED. This provides confirmtion that the
1409+
periodically toggles an onboard LED. This provides confirmation that the
14101410
scheduler is running.
14111411

14121412
###### [Contents](./TUTORIAL.md#contents)
@@ -1470,7 +1470,7 @@ the outer loop:
14701470
def __await__(self):
14711471
data = b''
14721472
while not data.endswith(self.DELIMITER):
1473-
yield from asyncio.sleep(0) # Neccessary because:
1473+
yield from asyncio.sleep(0) # Necessary because:
14741474
while not self.uart.any():
14751475
yield from asyncio.sleep(0) # timing may mean this is never called
14761476
data = b''.join((data, self.uart.read(self.uart.any())))
@@ -1630,7 +1630,7 @@ def event_loop():
16301630
# handle UART input
16311631
```
16321632

1633-
This works for simple examples but event loops rapidly become unweildy as the
1633+
This works for simple examples but event loops rapidly become unwieldy as the
16341634
number of events increases. They also violate the principles of object oriented
16351635
programming by lumping much of the program logic in one place rather than
16361636
associating code with the object being controlled. We want to design a class
@@ -1800,7 +1800,7 @@ overrun the specified time. This is because while the delay is in progress
18001800
other tasks will run. When the delay period completes, execution will not
18011801
resume until the running task issues `await` or terminates. A well-behaved coro
18021802
will always issue `await` at regular intervals. Where a precise delay is
1803-
required, especially one below a few ms, it may be neccessary to use
1803+
required, especially one below a few ms, it may be necessary to use
18041804
`utime.sleep_us(us)`.
18051805

18061806
###### [Contents](./TUTORIAL.md#contents)
@@ -1812,7 +1812,7 @@ often one of disappointment. Surely pre-emptive is better? Why should I have to
18121812
explicitly yield control when the Python virtual machine can do it for me?
18131813

18141814
When it comes to embedded systems the cooperative model has two advantages.
1815-
Fistly, it is lightweight. It is possible to have large numbers of coroutines
1815+
Firstly, it is lightweight. It is possible to have large numbers of coroutines
18161816
because unlike descheduled threads, paused coroutines contain little state.
18171817
Secondly it avoids some of the subtle problems associated with pre-emptive
18181818
scheduling. In practice cooperative multi-tasking is widely used, notably in

0 commit comments

Comments
 (0)