Skip to content

Commit

Permalink
Merge pull request #889 from quartiq/bump
Browse files Browse the repository at this point in the history
bump
  • Loading branch information
jordens authored May 6, 2024
2 parents c621f69 + c04a4bc commit 71fb265
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 85 deletions.
File renamed without changes.
102 changes: 41 additions & 61 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ num_enum = { version = "0.7.2", default-features = false }
paste = "1"
idsp = "0.15.1"
ad9959 = { path = "ad9959", version = "0.2.1" }
serial-settings = {path = "serial-settings"}
serial-settings = { version = "0.1", path = "serial-settings" }
mcp230xx = "1.0"
mutex-trait = "0.2"
fugit = "0.3"
Expand All @@ -62,17 +62,17 @@ mono-clock = "0.1"
spin = { version = "0.9", default-features = false, features = ["spin_mutex"]}
shared-bus = { version = "0.3", features = ["cortex-m"] }
lm75 = "0.2"
enum-iterator = "2.0.1"
enum-iterator = "2.1.0"
rand_xorshift = "0.3.0"
rand_core = "0.6.4"
minimq = "0.8.0"
minimq = "0.9.0"
usb-device = "0.3.2"
usbd-serial = "0.2"
# Keep this synced with the miniconf version in py/setup.py
miniconf = { version = "0.10", features = ["json-core"] }
miniconf_mqtt = "0.10"
miniconf = { version = "0.11", features = ["json-core", "derive", "postcard"] }
miniconf_mqtt = "0.11"
tca9539 = "0.2"
smoltcp-nal = { version = "0.4", features = ["shared-stack"], git = "https://github.com/quartiq/smoltcp-nal.git", rev = "3e3373e" }
smoltcp-nal = { version = "0.5", features = ["shared-stack"] }
bbqueue = "0.5"
postcard = "1"
bit_field = "0.10.2"
Expand Down
2 changes: 1 addition & 1 deletion serial-settings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
miniconf = "0.10"
miniconf = {version = "0.11", features = ["json-core"]}

menu = {git = "https://github.com/rust-embedded-community/menu", rev = "7ba884993fea57c3661d0f9d7c3cdca639a48701", features = ["echo"]}
heapless = "0.8"
Expand Down
33 changes: 16 additions & 17 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
//! storage sharing.
use crate::hardware::{flash::Flash, metadata::ApplicationMetadata, platform};
use core::fmt::Write;
use miniconf::Tree;
use postcard::ser_flavors::Flavor;
use miniconf::{Postcard, Tree};
use stm32h7xx_hal::flash::LockedFlashBank;

/// Settings that are used for configuring the network interface to Stabilizer.
Expand Down Expand Up @@ -96,11 +95,9 @@ pub fn load_from_flash<

log::info!("Loading initial `{path}` from flash");

let mut deserializer = postcard::Deserializer::from_flavor(
postcard::de_flavors::Slice::new(&item.data),
);
if let Err(e) = structure
.deserialize_by_key(path.split('/').skip(1), &mut deserializer)
let flavor = postcard::de_flavors::Slice::new(&item.data);
if let Err(e) =
structure.set_postcard_by_key(path.split('/').skip(1), flavor)
{
log::warn!("Failed to deserialize `{path}` from flash: {e:?}");
}
Expand Down Expand Up @@ -182,18 +179,20 @@ where

item.data.resize(item.data.capacity(), 0).unwrap();

let mut serializer = postcard::Serializer {
output: postcard::ser_flavors::Slice::new(&mut item.data),
};
let flavor = postcard::ser_flavors::Slice::new(&mut item.data);

if let Err(e) = settings
.serialize_by_key(item.path.split('/').skip(1), &mut serializer)
let len = match settings
.get_postcard_by_key(item.path.split('/').skip(1), flavor)
{
log::warn!("Failed to save `{}` to flash: {e:?}", item.path);
continue;
}

let len = serializer.output.finalize()?.len();
Err(e) => {
log::warn!(
"Failed to save `{}` to flash: {e:?}",
item.path
);
continue;
}
Ok(slice) => slice.len(),
};
item.data.truncate(len);

let range = self.storage.range();
Expand Down

0 comments on commit 71fb265

Please sign in to comment.