Merge pull request #291 from quartiq/feature/miniconf-update

Updating minconf + minimq dependencies
This commit is contained in:
Ryan Summers 2021-03-02 17:33:52 +01:00 committed by GitHub
commit 9bcc76105a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 36 deletions

11
Cargo.lock generated
View File

@ -199,9 +199,9 @@ dependencies = [
]
[[package]]
name = "derive_stringset"
name = "derive_miniconf"
version = "0.1.0"
source = "git+https://github.com/quartiq/miniconf.git?branch=develop#97ace3d8268075235cb67a2a8740d200bea1fe30"
source = "git+https://github.com/quartiq/miniconf.git?branch=develop#394d0634a9622e43a55850afc34eb4695ecababa"
dependencies = [
"proc-macro2",
"quote",
@ -402,9 +402,9 @@ dependencies = [
[[package]]
name = "miniconf"
version = "0.1.0"
source = "git+https://github.com/quartiq/miniconf.git?branch=develop#97ace3d8268075235cb67a2a8740d200bea1fe30"
source = "git+https://github.com/quartiq/miniconf.git?branch=develop#394d0634a9622e43a55850afc34eb4695ecababa"
dependencies = [
"derive_stringset",
"derive_miniconf",
"heapless",
"minimq",
"serde",
@ -414,8 +414,7 @@ dependencies = [
[[package]]
name = "minimq"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c5e626690b6f62e15710cf9815e5ca25ee54084899298c100a14b2504c80a46"
source = "git+https://github.com/quartiq/minimq.git?branch=master#a89a6f11d0d1f63114fb15f676022eb4fe904f56"
dependencies = [
"bit_field",
"embedded-nal",

View File

@ -52,6 +52,10 @@ generic-array = "0.14"
git = "https://github.com/quartiq/miniconf.git"
branch = "develop"
[patch.crates-io.minimq]
git = "https://github.com/quartiq/minimq.git"
branch = "master"
[patch.crates-io.serde-json-core]
git = "https://github.com/rust-embedded-community/serde-json-core.git"
branch = "master"

View File

@ -1,4 +1,4 @@
use miniconf::StringSet;
use miniconf::MiniconfAtomic;
use serde::Deserialize;
use super::{abs, copysign, macc, max, min};
@ -39,7 +39,7 @@ pub type Vec5 = [f32; 5];
/// Therefore it can trivially implement bump-less transfer.
/// * Cascading multiple IIR filters allows stable and robust
/// implementation of transfer functions beyond bequadratic terms.
#[derive(Copy, Clone, Debug, Default, Deserialize, StringSet)]
#[derive(Copy, Clone, Debug, Default, Deserialize, MiniconfAtomic)]
pub struct IIR {
pub ba: Vec5,
pub y_offset: f32,

View File

@ -1,6 +1,6 @@
use super::tools::macc_i32;
use core::f64::consts::PI;
use miniconf::StringSet;
use miniconf::MiniconfAtomic;
use serde::Deserialize;
/// Generic vector for integer IIR filter.
@ -46,7 +46,7 @@ impl Coeff for Vec5 {
/// See `dsp::iir::IIR` for general implementation details.
/// Offset and limiting disabled to suit lowpass applications.
/// Coefficient scaling fixed and optimized.
#[derive(Copy, Clone, Default, Debug, StringSet, Deserialize)]
#[derive(Copy, Clone, Default, Debug, MiniconfAtomic, Deserialize)]
pub struct IIR {
pub ba: Vec5,
// pub y_offset: i32,

View File

@ -8,7 +8,7 @@ use stabilizer::hardware;
use miniconf::{
embedded_nal::{IpAddr, Ipv4Addr},
minimq, MqttInterface, StringSet,
minimq, Miniconf, MqttInterface,
};
use serde::Deserialize;
@ -23,7 +23,7 @@ const SCALE: f32 = i16::MAX as _;
// The number of cascaded IIR biquads per channel. Select 1 or 2!
const IIR_CASCADE_LENGTH: usize = 1;
#[derive(Debug, Deserialize, StringSet)]
#[derive(Debug, Deserialize, Miniconf)]
pub struct Settings {
afe: [AfeGain; 2],
iir_ch: [[iir::IIR; IIR_CASCADE_LENGTH]; 2],
@ -63,12 +63,8 @@ const APP: () = {
let mqtt_interface = {
let mqtt_client = {
let broker = IpAddr::V4(Ipv4Addr::new(10, 34, 16, 1));
minimq::MqttClient::new(
broker,
"stabilizer",
stabilizer.net.stack,
)
.unwrap()
minimq::MqttClient::new(broker, "", stabilizer.net.stack)
.unwrap()
};
MqttInterface::new(mqtt_client, "stabilizer", Settings::default())
@ -147,19 +143,13 @@ const APP: () = {
!interface.network_stack().poll(clock.current_ms())
});
match c
.resources
if c.resources
.mqtt_interface
.lock(|interface| interface.update().unwrap())
{
miniconf::Action::Continue => {
if sleep {
cortex_m::asm::wfi();
}
}
miniconf::Action::CommitSettings => {
c.spawn.settings_update().unwrap()
}
c.spawn.settings_update().unwrap()
} else if sleep {
cortex_m::asm::wfi();
}
}
}

View File

@ -1,11 +1,11 @@
use miniconf::StringSet;
use miniconf::Miniconf;
use serde::{Deserialize, Serialize};
use core::convert::TryFrom;
use enum_iterator::IntoEnumIterator;
#[derive(
Copy, Clone, Debug, Serialize, Deserialize, IntoEnumIterator, StringSet,
Copy, Clone, Debug, Serialize, Deserialize, IntoEnumIterator, Miniconf,
)]
pub enum Gain {
G1 = 0b00,

View File

@ -108,10 +108,6 @@ async def configure_settings(args):
response = await interface.command(f'settings/{args.setting}', json.dumps(request))
logger.info(response)
if args.commit:
response = await interface.command('commit', 'commit')
logger.info(response)
def main():
""" Main program entry point. """
@ -122,8 +118,6 @@ def main():
parser.add_argument('--broker', default='10.34.16.1', type=str, help='The MQTT broker address')
parser.add_argument('values', nargs='+', type=str,
help='The value of settings. key=value list or a single value is accepted.')
parser.add_argument('--commit', action='store_true',
help='Specified true to commit after updating settings.')
parser.add_argument('-v', '--verbose', action='store_true', help='Enable verbose logging')
args = parser.parse_args()