You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This version is a subset of the original. Support was removed for features
126
-
thought unnecessary for microcontroller use. The principal example is that of
124
+
thought problematic for microcontroller use. The principal example is that of
127
125
timestamps. MicroPython does not support the `datetime` module. There are also
128
126
issues with platforms differing in their time handling, notably the epoch. On a
129
127
microcontroller it is simple to send the integer result from `time.time()` or
@@ -135,7 +133,6 @@ Supported types are fully compliant with a subset of the latest
135
133
In particular, it supports the new binary, UTF-8 string and application-defined
136
134
ext types. As stated above, timestamps are unsupported.
137
135
138
-
139
136
This MicroPython version uses various techniques to minimise RAM use including
140
137
"lazy imports": a module is only imported on first usage. For example an
141
138
application that only de-serialises data using synchronous code will not import
@@ -152,7 +149,7 @@ foreign language party.
152
149
The MessagePack specification does not distinguish between mutable and
153
150
immutable types. Consequently the non-extended module will be unable to
154
151
distinguish `tuple` and `list` items, also `bytes` and `bytearray`. The
155
-
extension module addresses this.
152
+
extension modules address this.
156
153
157
154
# 3. Installation
158
155
@@ -175,7 +172,7 @@ The following files are installed by `mpremote`:
175
172
7.`umsgpack/mpk_set.py` Extends support to `set`.
176
173
8.`umsgpack/mpk_tuple.py` Extends support to `tuple`.
177
174
9.`asyntest.py` Demo of asynchronous use of MessagePack.
178
-
10.`user_class.py` Demo of a user defined class that is serialisable by messagePack.
175
+
10.`user_class.py` Demo of a user defined class that is serialisable by MessagePack.
179
176
180
177
In a minimal installation only items 1-3 are required.
181
178
@@ -350,21 +347,20 @@ class Complex:
350
347
returncomplex(*struct.unpack(">ff", data))
351
348
```
352
349
The decorator takes two args, the extension type and the type to be handled.
353
-
A class defined with the two-arg decorator must provide the following methods:
350
+
A class defined with the two-arg decorator must provide the following static
351
+
methods:
354
352
355
353
*`packb` Takes two args, an instance of the type to be serialised and a
356
354
`dict` of pack options. Returns a `bytes` instance containing the serialised
357
-
object. The method can optionally access `.options`.
358
-
*`unpackb` Defined as a static method, this accepts a `bytes` instance of
359
-
packed data and a `dict` of unpack options. Returns a new instance of the
360
-
unpacked data type.
355
+
object. The method can optionally access `.options`.
356
+
*`unpackb` This accepts a `bytes` instance of packed data and a `dict` of
357
+
unpack options. Returns a new instance of the unpacked data type.
361
358
362
-
The options comprise any keyword args supplied to `dump(s)` and `load(s)`
359
+
The options comprise the keyword args supplied to `dump(s)` and `load(s)`
363
360
respectively.
364
361
365
-
Typically this packing and unpacking is done using the `struct` module, but in
366
-
some simple cases it may be done by `umsgpack` itself. For example
367
-
`mpk_set.py`:
362
+
Typically packing and unpacking is done using the `struct` module, but in some
363
+
simple cases it may be done by `umsgpack` itself. For example `mpk_set.py`:
368
364
```py
369
365
@umsgpack.ext_serializable(0x51, set)
370
366
classSet:
@@ -558,8 +554,9 @@ method.
558
554
On packing the `builtins` and `custom` dictionaries are used to locate the
559
555
appropriate packer with its `packb` method. Packers are never instantiated.
560
556
561
-
In both type of extensions the decorator populates a global `packers` dictionary: the key is the `ext_type` and the value is the packer class or user class. This
562
-
class is used on unpacking to run the `unpackb` static method.
557
+
In both type of extensions the decorator populates a global `packers`
558
+
dictionary: the key is the `ext_type` and the value is the packer class or user
559
+
class. This class is used on unpacking to run the `unpackb` static method.
563
560
564
561
This mechanism implies that the names of a packer class and the module
565
562
containing it are arbitrary.
@@ -577,6 +574,33 @@ they can convert between the supported data type and one natively supported,
577
574
and use `umsgpack` itself. See `mpk_set.py` which converts a `set` to a `list`
578
575
and _vice versa_.
579
576
577
+
# 12. Measurement of RAM usage
578
+
579
+
This test used an RP2040 with precompiled code in romfs. In each case the code
580
+
below was placed in `main.py`, the board re-booted, and the result observed.
0 commit comments