make config demo errors non-fatal

This commit is contained in:
Sebastien Bourdeauducq 2020-06-25 11:27:50 +08:00
parent 654d65a6d5
commit 507edb5a78

View File

@ -6,7 +6,7 @@
extern crate alloc; extern crate alloc;
use core::{cmp, str}; use core::{cmp, str};
use log::info; use log::{info, error};
use libboard_zynq::{timer::GlobalTimer, logger, devc}; use libboard_zynq::{timer::GlobalTimer, logger, devc};
use libsupport_zynq::ram; use libsupport_zynq::ram;
@ -46,18 +46,22 @@ pub fn main_core0() {
ram::init_alloc_linker(); ram::init_alloc_linker();
let mut cfg = config::Config::new().unwrap(); match config::Config::new() {
match cfg.read_str("FOO") { Ok(mut cfg) => {
Ok(val) => info!("FOO = {}", val), match cfg.read_str("FOO") {
Err(error) => info!("failed to read config FOO: {}", error), Ok(val) => info!("FOO = {}", val),
} Err(error) => info!("failed to read config FOO: {}", error),
match cfg.read_str("BAR") { }
Ok(val) => info!("BAR = {}", val), match cfg.read_str("BAR") {
Err(error) => info!("failed to read config BAR: {}", error), Ok(val) => info!("BAR = {}", val),
} Err(error) => info!("failed to read config BAR: {}", error),
match cfg.read_str("FOOBAR") { }
Ok(val) => info!("read FOOBAR = {}", val), match cfg.read_str("FOOBAR") {
Err(error) => info!("failed to read config FOOBAR: {}", error), Ok(val) => info!("read FOOBAR = {}", val),
Err(error) => info!("failed to read config FOOBAR: {}", error),
}
},
Err(error) => error!("config failed: {}", error)
} }
if devc::DevC::new().is_done() { if devc::DevC::new().is_done() {