Merge branch 'master' into rj/pounder-fixes

* master:
  adapt to new heapless/serde-json-core after const-generics
  Bump serde-json-core from 0.3.0 to 0.4.0
  build(deps): bump heapless from 0.6.1 to 0.7.1
This commit is contained in:
Robert Jördens 2021-05-28 21:44:07 +02:00
commit 5ee7ef388e
7 changed files with 31 additions and 32 deletions

14
Cargo.lock generated
View File

@ -200,7 +200,7 @@ dependencies = [
[[package]] [[package]]
name = "derive_miniconf" name = "derive_miniconf"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/quartiq/miniconf.git?rev=c6f2b28#c6f2b28f735e27b337eaa986846536e904c6f2bd" source = "git+https://github.com/quartiq/miniconf.git?rev=2750533#275053396f0334e9efefa1ab2aae4c19b95a9a53"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -347,7 +347,6 @@ dependencies = [
"as-slice", "as-slice",
"generic-array 0.14.4", "generic-array 0.14.4",
"hash32 0.1.1", "hash32 0.1.1",
"serde",
"stable_deref_trait", "stable_deref_trait",
] ]
@ -359,6 +358,7 @@ checksum = "c7ee8a997d259962217f40279f34201fdf06e669bafa69d7c1f4c7ff1893b5f6"
dependencies = [ dependencies = [
"atomic-polyfill", "atomic-polyfill",
"hash32 0.2.1", "hash32 0.2.1",
"serde",
"stable_deref_trait", "stable_deref_trait",
] ]
@ -414,7 +414,7 @@ dependencies = [
[[package]] [[package]]
name = "miniconf" name = "miniconf"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/quartiq/miniconf.git?rev=c6f2b28#c6f2b28f735e27b337eaa986846536e904c6f2bd" source = "git+https://github.com/quartiq/miniconf.git?rev=2750533#275053396f0334e9efefa1ab2aae4c19b95a9a53"
dependencies = [ dependencies = [
"derive_miniconf", "derive_miniconf",
"serde", "serde",
@ -709,11 +709,11 @@ dependencies = [
[[package]] [[package]]
name = "serde-json-core" name = "serde-json-core"
version = "0.3.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39af17f40c2a28d2c9a7918663ddc8a10f54cc6f109ead5c3f010869761df186" checksum = "8014aeea272bca0f0779778d43253f2f3375b414185b30e6ecc4d3e4a9994781"
dependencies = [ dependencies = [
"heapless 0.6.1", "heapless 0.7.1",
"ryu", "ryu",
"serde", "serde",
] ]
@ -772,7 +772,7 @@ dependencies = [
"cortex-m-rtic", "cortex-m-rtic",
"dsp", "dsp",
"embedded-hal", "embedded-hal",
"heapless 0.6.1", "heapless 0.7.1",
"log", "log",
"mcp23017", "mcp23017",
"miniconf", "miniconf",

View File

@ -33,7 +33,7 @@ cortex-m-rt = { version = "0.6", features = ["device"] }
log = { version = "0.4", features = ["max_level_trace", "release_max_level_info"] } log = { version = "0.4", features = ["max_level_trace", "release_max_level_info"] }
rtt-target = { version = "0.3", features = ["cortex-m"] } rtt-target = { version = "0.3", features = ["cortex-m"] }
serde = { version = "1.0", features = ["derive"], default-features = false } serde = { version = "1.0", features = ["derive"], default-features = false }
heapless = { version = "0.6", features = ["serde"] } heapless = { version = "0.7", features = ["serde"] }
cortex-m-rtic = "0.5.6" cortex-m-rtic = "0.5.6"
embedded-hal = "0.2.5" embedded-hal = "0.2.5"
nb = "1.0.0" nb = "1.0.0"
@ -44,7 +44,7 @@ dsp = { path = "dsp" }
ad9959 = { path = "ad9959" } ad9959 = { path = "ad9959" }
miniconf = "0.1.0" miniconf = "0.1.0"
shared-bus = {version = "0.2.2", features = ["cortex-m"] } shared-bus = {version = "0.2.2", features = ["cortex-m"] }
serde-json-core = "0.3" serde-json-core = "0.4"
mcp23017 = "1.0" mcp23017 = "1.0"
# rtt-target bump # rtt-target bump
@ -63,7 +63,7 @@ rev = "a2e3ad5"
[patch.crates-io.miniconf] [patch.crates-io.miniconf]
git = "https://github.com/quartiq/miniconf.git" git = "https://github.com/quartiq/miniconf.git"
rev = "c6f2b28" rev = "2750533"
[dependencies.smoltcp-nal] [dependencies.smoltcp-nal]
git = "https://github.com/quartiq/smoltcp-nal.git" git = "https://github.com/quartiq/smoltcp-nal.git"

View File

@ -9,7 +9,7 @@ use stm32h7xx_hal::{
const NUM_SOCKETS: usize = 4; const NUM_SOCKETS: usize = 4;
use heapless::{consts, Vec}; use heapless::Vec;
use smoltcp_nal::smoltcp; use smoltcp_nal::smoltcp;
use embedded_hal::digital::v2::{InputPin, OutputPin}; use embedded_hal::digital::v2::{InputPin, OutputPin};
@ -642,7 +642,7 @@ pub fn setup(
let mut sockets = let mut sockets =
smoltcp::socket::SocketSet::new(&mut store.sockets[..]); smoltcp::socket::SocketSet::new(&mut store.sockets[..]);
let mut handles: Vec<smoltcp::socket::SocketHandle, consts::U64> = let mut handles: Vec<smoltcp::socket::SocketHandle, 64> =
Vec::new(); Vec::new();
for storage in store.socket_storage.iter_mut() { for storage in store.socket_storage.iter_mut() {
let tcp_socket = { let tcp_socket = {

View File

@ -1,4 +1,4 @@
use heapless::{consts, String, Vec}; use heapless::{String, Vec};
use serde::Serialize; use serde::Serialize;
use core::fmt::Write; use core::fmt::Write;
@ -12,15 +12,15 @@ pub enum SettingsResponseCode {
/// Represents a generic MQTT message. /// Represents a generic MQTT message.
pub struct MqttMessage<'a> { pub struct MqttMessage<'a> {
pub topic: &'a str, pub topic: &'a str,
pub message: Vec<u8, consts::U128>, pub message: Vec<u8, 128>,
pub properties: Vec<minimq::Property<'a>, consts::U1>, pub properties: Vec<minimq::Property<'a>, 1>,
} }
/// The payload of the MQTT response message to a settings update request. /// The payload of the MQTT response message to a settings update request.
#[derive(Serialize)] #[derive(Serialize)]
pub struct SettingsResponse { pub struct SettingsResponse {
code: u8, code: u8,
msg: String<heapless::consts::U64>, msg: String<64>,
} }
impl<'a> MqttMessage<'a> { impl<'a> MqttMessage<'a> {
@ -48,8 +48,7 @@ impl<'a> MqttMessage<'a> {
.unwrap_or(&default_response); .unwrap_or(&default_response);
// Associate any provided correlation data with the response. // Associate any provided correlation data with the response.
let mut correlation_data: Vec<minimq::Property<'a>, consts::U1> = let mut correlation_data: Vec<minimq::Property<'a>, 1> = Vec::new();
Vec::new();
if let Some(data) = properties if let Some(data) = properties
.iter() .iter()
.find(|prop| matches!(prop, minimq::Property::CorrelationData(_))) .find(|prop| matches!(prop, minimq::Property::CorrelationData(_)))

View File

@ -10,7 +10,7 @@
///! ///!
///! Respones to settings updates are sent without quality-of-service guarantees, so there's no ///! Respones to settings updates are sent without quality-of-service guarantees, so there's no
///! guarantee that the requestee will be informed that settings have been applied. ///! guarantee that the requestee will be informed that settings have been applied.
use heapless::{consts, String}; use heapless::String;
use super::{MqttMessage, NetworkReference, SettingsResponse, UpdateState}; use super::{MqttMessage, NetworkReference, SettingsResponse, UpdateState};
use crate::hardware::design_parameters::MQTT_BROKER; use crate::hardware::design_parameters::MQTT_BROKER;
@ -20,11 +20,11 @@ pub struct MiniconfClient<S>
where where
S: miniconf::Miniconf + Default + Clone, S: miniconf::Miniconf + Default + Clone,
{ {
default_response_topic: String<consts::U128>, default_response_topic: String<128>,
mqtt: minimq::Minimq<NetworkReference, 256>, mqtt: minimq::Minimq<NetworkReference, 256>,
settings: S, settings: S,
subscribed: bool, subscribed: bool,
settings_prefix: String<consts::U64>, settings_prefix: String<64>,
} }
impl<S> MiniconfClient<S> impl<S> MiniconfClient<S>
@ -41,10 +41,10 @@ where
let mqtt = let mqtt =
minimq::Minimq::new(MQTT_BROKER.into(), client_id, stack).unwrap(); minimq::Minimq::new(MQTT_BROKER.into(), client_id, stack).unwrap();
let mut response_topic: String<consts::U128> = String::from(prefix); let mut response_topic: String<128> = String::from(prefix);
response_topic.push_str("/log").unwrap(); response_topic.push_str("/log").unwrap();
let mut settings_prefix: String<consts::U64> = String::from(prefix); let mut settings_prefix: String<64> = String::from(prefix);
settings_prefix.push_str("/settings").unwrap(); settings_prefix.push_str("/settings").unwrap();
Self { Self {
@ -81,7 +81,7 @@ where
if !self.subscribed && mqtt_connected { if !self.subscribed && mqtt_connected {
// Note(unwrap): We construct a string with two more characters than the prefix // Note(unwrap): We construct a string with two more characters than the prefix
// strucutre, so we are guaranteed to have space for storage. // strucutre, so we are guaranteed to have space for storage.
let mut settings_topic: String<consts::U66> = let mut settings_topic: String<66> =
String::from(self.settings_prefix.as_str()); String::from(self.settings_prefix.as_str());
settings_topic.push_str("/#").unwrap(); settings_topic.push_str("/#").unwrap();

View File

@ -5,7 +5,7 @@
///! telemetry (via MQTT), configuration of run-time settings (via MQTT + Miniconf), and live data ///! telemetry (via MQTT), configuration of run-time settings (via MQTT + Miniconf), and live data
///! streaming over raw UDP/TCP sockets. This module encompasses the main processing routines ///! streaming over raw UDP/TCP sockets. This module encompasses the main processing routines
///! related to Stabilizer networking operations. ///! related to Stabilizer networking operations.
use heapless::{consts, String}; use heapless::String;
use miniconf::Miniconf; use miniconf::Miniconf;
use serde::Serialize; use serde::Serialize;
@ -134,7 +134,7 @@ fn get_client_id(
app: &str, app: &str,
client: &str, client: &str,
mac: smoltcp_nal::smoltcp::wire::EthernetAddress, mac: smoltcp_nal::smoltcp::wire::EthernetAddress,
) -> String<consts::U64> { ) -> String<64> {
let mut identifier = String::new(); let mut identifier = String::new();
write!(&mut identifier, "{}-{}-{}", app, mac, client).unwrap(); write!(&mut identifier, "{}-{}-{}", app, mac, client).unwrap();
identifier identifier
@ -151,10 +151,10 @@ fn get_client_id(
pub fn get_device_prefix( pub fn get_device_prefix(
app: &str, app: &str,
mac: smoltcp_nal::smoltcp::wire::EthernetAddress, mac: smoltcp_nal::smoltcp::wire::EthernetAddress,
) -> String<consts::U128> { ) -> String<128> {
// Note(unwrap): The mac address + binary name must be short enough to fit into this string. If // Note(unwrap): The mac address + binary name must be short enough to fit into this string. If
// they are defined too long, this will panic and the device will fail to boot. // they are defined too long, this will panic and the device will fail to boot.
let mut prefix: String<consts::U128> = String::new(); let mut prefix: String<128> = String::new();
write!(&mut prefix, "dt/sinara/{}/{}", app, mac).unwrap(); write!(&mut prefix, "dt/sinara/{}/{}", app, mac).unwrap();
prefix prefix

View File

@ -10,7 +10,7 @@
///! sampling frequency. Instead, the raw codes are stored and the telemetry is generated as ///! sampling frequency. Instead, the raw codes are stored and the telemetry is generated as
///! required immediately before transmission. This ensures that any slower computation required ///! required immediately before transmission. This ensures that any slower computation required
///! for unit conversion can be off-loaded to lower priority tasks. ///! for unit conversion can be off-loaded to lower priority tasks.
use heapless::{consts, String, Vec}; use heapless::{String, Vec};
use minimq::QoS; use minimq::QoS;
use serde::Serialize; use serde::Serialize;
@ -22,7 +22,7 @@ use crate::hardware::{
/// The telemetry client for reporting telemetry data over MQTT. /// The telemetry client for reporting telemetry data over MQTT.
pub struct TelemetryClient<T: Serialize> { pub struct TelemetryClient<T: Serialize> {
mqtt: minimq::Minimq<NetworkReference, 256>, mqtt: minimq::Minimq<NetworkReference, 256>,
telemetry_topic: String<consts::U128>, telemetry_topic: String<128>,
_telemetry: core::marker::PhantomData<T>, _telemetry: core::marker::PhantomData<T>,
} }
@ -99,7 +99,7 @@ impl<T: Serialize> TelemetryClient<T> {
let mqtt = let mqtt =
minimq::Minimq::new(MQTT_BROKER.into(), client_id, stack).unwrap(); minimq::Minimq::new(MQTT_BROKER.into(), client_id, stack).unwrap();
let mut telemetry_topic: String<consts::U128> = String::from(prefix); let mut telemetry_topic: String<128> = String::from(prefix);
telemetry_topic.push_str("/telemetry").unwrap(); telemetry_topic.push_str("/telemetry").unwrap();
Self { Self {
@ -118,7 +118,7 @@ impl<T: Serialize> TelemetryClient<T> {
/// # Args /// # Args
/// * `telemetry` - The telemetry to report /// * `telemetry` - The telemetry to report
pub fn publish(&mut self, telemetry: &T) { pub fn publish(&mut self, telemetry: &T) {
let telemetry: Vec<u8, consts::U256> = let telemetry: Vec<u8, 256> =
serde_json_core::to_vec(telemetry).unwrap(); serde_json_core::to_vec(telemetry).unwrap();
self.mqtt self.mqtt
.client .client