Skip to content

Commit 0177175

Browse files
committed
V0.15 Exception handling simplified. FULL_CHECK optional.
1 parent def82be commit 0177175

File tree

6 files changed

+149
-191
lines changed

6 files changed

+149
-191
lines changed

TUTORIAL.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,10 +1078,14 @@ The mechanism works because the device driver (written in C) implements the
10781078
following methods: `ioctl`, `read`, `write`, `readline` and `close`. See
10791079
section 5.3 for further discussion.
10801080

1081-
Applications using the UART should be designed such that all coros minimise
1082-
blocking periods. This is because blocking while the UART is receiving data can
1083-
lead to buffer overflows with consequent loss of data. This can be ameliorated
1084-
by using a larger UART read buffer length or a lower baudrate.
1081+
A UART can receive data at any time. The IORead mechanism checks for pending
1082+
incoming characters whenever the scheduler has control. When a coro is running
1083+
an interrupt service routine buffers incoming characters; these will be removed
1084+
when the coro yields to the scheduler. Consequently UART applications should be
1085+
designed such that all coros minimise blocking periods to avoid buffer
1086+
overflows and data loss. This can be ameliorated by using a larger UART read
1087+
buffer or a lower baudrate. Alternatively hardware flow control will provide a
1088+
solution if the data source supports it.
10851089

10861090
### 5.1.1 A UART driver example
10871091

gps/README.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
# 1. as_GPS
22

33
This repository offers a suite of asynchronous device drivers for GPS devices
4-
which communicate with the host via a UART. GPS NMEA sentence parsing is based
5-
on this excellent library [micropyGPS].
4+
which communicate with the host via a UART. GPS [NMEA-0183] sentence parsing is
5+
based on this excellent library [micropyGPS].
66

77
## 1.1 Driver characteristics
88

99
* Asynchronous: UART messaging is handled as a background task allowing the
1010
application to perform other tasks such as handling user interaction.
1111
* The read-only driver is suitable for resource constrained devices and will
1212
work with most GPS devices using a UART for communication.
13+
* Can write `.kml` files for displaying journeys on Google Earth.
1314
* The read-write driver enables altering the configuration of GPS devices
1415
based on the popular MTK3329/MTK3339 chips.
1516
* The above drivers are portable between [MicroPython] and Python 3.5 or above.
1617
* Timing drivers for [MicroPython] only extend the capabilities of the
1718
read-only and read-write drivers to provide accurate sub-ms GPS timing. On
1819
STM-based hosts (e.g. the Pyboard) the RTC may be set from GPS and calibrated
1920
to achieve timepiece-level accuracy.
20-
* Can write `.kml` files for displaying journeys on Google Earth.
2121
* Drivers may be extended via subclassing, for example to support additional
2222
sentence types.
2323

2424
Testing was performed using a [Pyboard] with the Adafruit
2525
[Ultimate GPS Breakout] board. Most GPS devices will work with the read-only
26-
driver as they emit NMEA sentences on startup.
26+
driver as they emit [NMEA-0183] sentences on startup.
2727

2828
## 1.2 Comparison with [micropyGPS]
2929

30-
NMEA sentence parsing is based on [micropyGPS] but with significant changes.
30+
[NMEA-0183] sentence parsing is based on [micropyGPS] but with significant
31+
changes.
3132

3233
* As asynchronous drivers they require `uasyncio` on [MicroPython] or
3334
`asyncio` under Python 3.5+.
@@ -47,8 +48,8 @@ NMEA sentence parsing is based on [micropyGPS] but with significant changes.
4748

4849
## 1.1 Overview
4950

50-
The `AS_GPS` object runs a coroutine which receives GPS NMEA sentences from the
51-
UART and parses them as they arrive. Valid sentences cause local bound
51+
The `AS_GPS` object runs a coroutine which receives [NMEA-0183] sentences from
52+
the UART and parses them as they arrive. Valid sentences cause local bound
5253
variables to be updated. These can be accessed at any time with minimal latency
5354
to access data such as position, altitude, course, speed, time and date.
5455

@@ -68,8 +69,8 @@ the Pyboard is run from a voltage >5V the Pyboard 3V3 pin should be used.
6869

6970
This is based on UART 4 as used in the test programs; any UART may be used. The
7071
UART Tx-GPS Rx connection is only necessary if using the read/write driver. The
71-
PPS connection is required only if using the device for precise timing
72-
(`as_tGPS.py`). Any pin may be used.
72+
PPS connection is required only if using the timing driver `as_tGPS.py`. Any
73+
pin may be used.
7374

7475
## 1.2 Basic Usage
7576

@@ -170,8 +171,7 @@ or later.
170171
Method calls and access to bound variables are nonblocking and return the most
171172
current data. This is updated transparently by a coroutine. In situations where
172173
updates cannot be achieved, for example in buildings or tunnels, values will be
173-
out of date. Whether this matters and any action to take is application
174-
dependent.
174+
out of date. The action to take (if any) is application dependent.
175175

176176
Three mechanisms exist for responding to outages.
177177
* Check the `time_since_fix` method [section 2.2.3](./README.md#223-time-and-date).
@@ -193,8 +193,7 @@ Optional positional args:
193193
* `fix_cb_args` A tuple of args for the callback (default `()`).
194194

195195
Notes:
196-
`local_offset` correctly alters the date where time passes the 00.00.00
197-
boundary.
196+
`local_offset` will alter the date when time passes the 00.00.00 boundary.
198197
If `sreader` is `None` a special test mode is engaged (see `astests.py`).
199198

200199
### 2.1.1 The fix callback
@@ -401,8 +400,8 @@ was received `reparse` would see
401400
## 2.6 Public class variable
402401

403402
* `FULL_CHECK` Default `True`. If set `False` disables CRC checking and other
404-
basic checks on received sentences. This is intended for use at high baudrates
405-
where the time consumed by these checks can be excessive.
403+
basic checks on received sentences. If GPS is linked directly to the target
404+
(rather than via long cables) these checks are arguably not neccessary.
406405

407406
# 3. The GPS class read-write driver
408407

@@ -875,7 +874,7 @@ Sources of fixed lag:
875874

876875
Sources of variable error:
877876
* Variations in interrupt latency (small on Pyboard).
878-
* Inaccuracy in the `ticks_us` timer (significant over 1 second).
877+
* Inaccuracy in the `ticks_us` timer (significant over a 1 second interval).
879878

880879
With correct usage when the PPS interrupt occurs the UART will not be receiving
881880
data (this can substantially affect ISR latency variability). Consequently, on

0 commit comments

Comments
 (0)