Skip to content

Commit add2a60

Browse files
authored
Merge pull request #3 from 107-systems/doc
Minimal documentation how to use the features of this library.
2 parents 2b73c6a + a9a81b6 commit add2a60

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,35 @@
1111

1212
This library provides support functionality for building a complete [Cyphal](https://opencyphal.org/) application in combination with [107-Arduino-Cyphal](https://github.com/107-systems/107-Arduino-Cyphal).
1313

14-
**Features:**
15-
* API for obtaining a unique 64-bit ID.
16-
* API for permanent register storage and retrieval.
17-
1814
<p align="center">
1915
<a href="https://github.com/107-systems/l3xz"><img src="https://raw.githubusercontent.com/107-systems/.github/main/logo/l3xz-logo-memento-mori-github.png" width="30%"></a>
2016
<a href="https://github.com/107-systems/viper"><img src="https://github.com/107-systems/.github/raw/main/logo/viper.jpg" width="30%"></a>
2117
</p>
2218

2319
This library works for
2420
* [arduino-pico](https://github.com/earlephilhower/arduino-pico): [`Raspberry Pi Pico`](https://www.raspberrypi.org/products/raspberry-pi-pico), `Adafruit Feather RP2040`, ... :heavy_check_mark:
21+
22+
**Features:**
23+
* API for obtaining a **unique 64-bit ID**.
24+
```C++
25+
auto /* std::array<uint8_t, 16> */ const UNIQUE_ID = cyphal::support::UniqueId::instance().value();
26+
```
27+
* API for **persistent register storage and retrieval**.
28+
```C++
29+
/* Declaration of key/value storage. */
30+
cyphal::support::platform::storage::littlefs::KeyValueStorage kv_storage(filesystem);
31+
32+
/* Load persistently stored registers from a non-volatile memory (EEPROM, flash, etc.). */
33+
if (auto const opt_err = cyphal::support::load(kv_storage, *node_registry); opt_err.has_value())
34+
{
35+
Serial.print("load failed with error code ");
36+
Serial.println(static_cast<int>(opt_err.value()));
37+
}
38+
39+
/* Store persistent registers to a non-volatile memory (EEPROM, flash, etc.). */
40+
if (auto const opt_err = cyphal::support::save(kv_storage, *node_registry); opt_err.has_value())
41+
{
42+
Serial.print("save failed with error code ");
43+
Serial.println(static_cast<int>(opt_err.value()));
44+
}
45+
```

0 commit comments

Comments
 (0)