|
2 | 2 | EP-235: DAQ data package |
3 | 3 | =========================================== |
4 | 4 |
|
| 5 | +.. sectnum:: |
| 6 | + :suffix: . |
| 7 | + |
5 | 8 | .. image:: https://img.shields.io/badge/Status-Draft-blue |
6 | 9 |
|
7 | 10 | .. image:: https://img.shields.io/badge/plumCore-0.8.0--dev-gray?labelColor=purple |
8 | 11 |
|
9 | 12 |
|
| 13 | +.. contents:: |
| 14 | + |
| 15 | + |
| 16 | +Introduction |
| 17 | +===================== |
| 18 | + |
| 19 | +As the plumCore framework continues to develop into a generic DAQ platform, managing data processing, |
| 20 | +transmission, and storage is becoming increasingly challenging. To address this, it would be beneficial |
| 21 | +for the platform to adopt a universal, generic storage format that can be used across various media, including: |
| 22 | + |
| 23 | +- FIFO buffers in RAM for short-term storage |
| 24 | +- FIFO buffers in flash for long-term, power outage-resistant storage |
| 25 | +- Message queue-like transports such as MQTT and CoAP |
| 26 | +- Long-term archiving solutions |
| 27 | + |
| 28 | +This storage format should be capable of containing the following information: |
| 29 | + |
| 30 | +- A single sensor value or a time series (measurement) |
| 31 | +- The time at which the measurement was taken, along with relevant time metadata (e.g., clock precision, clock type) |
| 32 | +- Metadata related to the sensor value or time series (e.g., uncertainty, conditions) |
| 33 | +- Sampling strategy details (e.g., arbitrary intervals, equal intervals) |
| 34 | +- Calibration data used during sample processing |
| 35 | +- Optionally, the raw sensor value |
| 36 | +- Identification of the data source |
| 37 | +- Electronic signature and, optionally, encryption |
10 | 38 |
|
11 | | -TBD introduction |
| 39 | +Having a common storage format would simplify data management and facilitate seamless data exchange |
| 40 | +across different media and applications. |
| 41 | + |
| 42 | +Key-word usage |
| 43 | +-------------------- |
| 44 | + |
| 45 | +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", |
| 46 | +"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and |
| 47 | +"OPTIONAL" in this document are to be interpreted as described in |
| 48 | +BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all |
| 49 | +capitals, as shown here. |
| 50 | + |
| 51 | +License |
| 52 | +--------------- |
| 53 | + |
| 54 | +This work is licensed under CC BY-SA 4.0. To view a copy of this license, visit https://creativecommons.org/licenses/by-sa/4.0/ |
| 55 | + |
| 56 | +© 2025 Marek Koza <qyx@krtko.org> |
12 | 57 |
|
13 | 58 |
|
14 | 59 | The data format |
15 | 60 | ===================== |
16 | 61 |
|
17 | | -Top level format structure is a CBOR map with indefinite length with a ``PPKG = 1`` key/value |
18 | | -pair at the beginning. ``PPKG`` is an abbreviation for *plumCore package*, ``1`` is the current |
19 | | -format version. This results in the following encoding: |
| 62 | +Package, the top-level data structure |
| 63 | +----------------------------------------- |
| 64 | + |
| 65 | +Top level data structure is a CBOR map with indefinite length with a ``PPKG = 1`` key/value |
| 66 | +pair at the beginning. It is called a *package*. ``PPKG`` is an abbreviation for *plumCore package*, |
| 67 | +``1`` is the current format version. This results in the following encoding: |
20 | 68 |
|
21 | 69 | .. code-block:: python |
22 | 70 |
|
@@ -48,3 +96,10 @@ In case a ``COSE`` signature is used, the header changes: |
48 | 96 | # COSE signature goes here |
49 | 97 | 0xff # End of map |
50 | 98 |
|
| 99 | +
|
| 100 | +Using an indefinite length CBOR map to encode a package has an interesting property. |
| 101 | +Since it uses the ``0xff`` byte to finish the map, we may freely append more than one |
| 102 | +package one after the other in a common flash memory media which contains |
| 103 | +``0xff`` bytes when erased. However, beginning of a package needs to be aligned to |
| 104 | +a 8 byte boundary in the media region (RAM region, file, flash media partition). |
| 105 | +The padding between the successive packages SHALL be filled with ``0xff`` bytes. |
0 commit comments