mqtt_client: take out scpi

This commit is contained in:
occheung 2020-09-17 17:05:09 +08:00
parent 74f7b7ce61
commit 72770d9276
1 changed files with 7 additions and 53 deletions

View File

@ -1,8 +1,7 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
#[macro_use] use log::{info, warn};
extern crate log;
use smoltcp as net; use smoltcp as net;
use stm32h7xx_hal::ethernet; use stm32h7xx_hal::ethernet;
@ -31,44 +30,9 @@ use firmware::{
cpld::{ cpld::{
CPLD, CPLD,
}, },
scpi::{
HelloWorldCommand,
Channel0SwitchCommand,
Channel1SwitchCommand,
Channel2SwitchCommand,
Channel3SwitchCommand,
Channel0AttenuationCommand,
Channel1AttenuationCommand,
Channel2AttenuationCommand,
Channel3AttenuationCommand,
ClockSourceCommand,
ClockDivisionCommand,
ProfileCommand,
Channel0Profile0Singletone
},
Urukul, scpi_root, recursive_scpi_tree, scpi_tree
}; };
use firmware::translation::MqttScpiTranslator; use firmware::Urukul;
use firmware::mqtt_mux::{MqttCommandType, MqttMux};
use scpi::prelude::*;
use scpi::ieee488::commands::*;
use scpi::scpi::commands::*;
use scpi::{
ieee488_cls,
ieee488_ese,
ieee488_esr,
ieee488_idn,
ieee488_opc,
ieee488_rst,
ieee488_sre,
ieee488_stb,
ieee488_tst,
ieee488_wai,
scpi_crate_version,
scpi_status,
scpi_system,
};
use scpi::Context;
#[path = "util/logger.rs"] #[path = "util/logger.rs"]
mod logger; mod logger;
@ -216,16 +180,9 @@ fn main() -> ! {
cp.SCB.invalidate_icache(); cp.SCB.invalidate_icache();
cp.SCB.enable_icache(); cp.SCB.enable_icache();
// Define SCPI tree // TODO: Remove this simple test
let tree = scpi_tree!(); let mut mqtt_mux = MqttMux::new(urukul);
info!("{:?}", mqtt_mux.handle_command("Urukul/Control/Channel0/Switch", "on".as_bytes()));
// Device was declared in prior
let mut errors = ArrayErrorQueue::<[Error; 10]>::new();
let mut context = Context::new(&mut urukul, &mut errors, tree);
//Response bytebuffer
let mut buf = ArrayVecFormatter::<[u8; 256]>::new();
// SCPI configs END
// Time unit in ms // Time unit in ms
let mut time: u32 = 0; let mut time: u32 = 0;
@ -274,10 +231,7 @@ fn main() -> ! {
topic => { topic => {
info!("On '{:?}', received: {:?}", topic, message); info!("On '{:?}', received: {:?}", topic, message);
// Why is topic a string while message is a slice? // Why is topic a string while message is a slice?
context.run_with_mqtt(topic, mqtt_mux.handle_command(topic, message).unwrap();
core::str::from_utf8(message).unwrap(),
&mut buf)
.unwrap();
}, },
}).is_ok(); }).is_ok();