diff --git a/firmware/src/command_parser.rs b/firmware/src/command_parser.rs index 9e97b25..24419a8 100644 --- a/firmware/src/command_parser.rs +++ b/firmware/src/command_parser.rs @@ -52,31 +52,11 @@ pub enum Error { Parser, UnexpectedEnd, UnexpectedToken(Token), - NoSuchChannel, - NoSuchSetup, } #[derive(Debug)] pub enum ShowCommand { ReportMode, - Channel(u8), -} - -#[derive(Debug)] -pub enum ChannelCommand { - Enable, - Disable, - Setup(u8), - EnableInput(InputBuffer), - DisableInput(InputBuffer), -} - -#[derive(Clone, Copy, Debug)] -pub enum InputBuffer { - RefPos, - RefNeg, - AinPos, - AinNeg, } #[derive(Debug)] @@ -84,14 +64,8 @@ pub enum Command { Quit, Show(ShowCommand), Report(ReportMode), - Channel(u8, ChannelCommand), } -const CHANNEL_IDS: &'static [&'static str] = &[ - "0", "1", "2", "3", -]; -const SETUP_IDS: &'static [&'static str] = CHANNEL_IDS; - impl Command { pub fn parse(input: &str) -> Result { let mut lexer = Token::lexer(input); @@ -121,19 +95,6 @@ impl Command { }; } - macro_rules! channel_input { - ($channel: expr, $input: tt) => { - choice![ - End => - Ok(Command::Show(ShowCommand::Channel($channel))), - Enable => - end![Command::Channel($channel, ChannelCommand::EnableInput(InputBuffer::$input))], - Disable => - end![Command::Channel($channel, ChannelCommand::DisableInput(InputBuffer::$input))], - ] - }; - } - // Command grammar choice![ Quit => Ok(Command::Quit), @@ -146,37 +107,6 @@ impl Command { ], End => Ok(Command::Report(ReportMode::Once)), ], - Channel => { - let channel = choice![ - Number => { - CHANNEL_IDS.iter() - .position(|id| *id == lexer.slice()) - .ok_or(Error::NoSuchChannel) - }, - ]? as u8; - choice![ - End => - Ok(Command::Show(ShowCommand::Channel(channel))), - Enable => - Ok(Command::Channel(channel, ChannelCommand::Enable)), - Disable => - Ok(Command::Channel(channel, ChannelCommand::Enable)), - Setup => { - let setup = choice![ - Number => { - SETUP_IDS.iter() - .position(|id| *id == lexer.slice()) - .ok_or(Error::NoSuchSetup) - }, - ]? as u8; - end!(Command::Channel(channel, ChannelCommand::Setup(setup))) - }, - RefPos => channel_input!(channel, RefPos), - RefNeg => channel_input!(channel, RefNeg), - AinPos => channel_input!(channel, AinPos), - AinNeg => channel_input!(channel, AinNeg), - ] - }, ] } } diff --git a/firmware/src/main.rs b/firmware/src/main.rs index 5354b00..f75ba5d 100644 --- a/firmware/src/main.rs +++ b/firmware/src/main.rs @@ -244,27 +244,6 @@ fn main() -> ! { Command::Show(ShowCommand::ReportMode) => { let _ = writeln!(socket, "Report mode: {:?}", session.report_mode()); } - Command::Show(ShowCommand::Channel(index)) => { - let _ = writeln!(socket, "Channel {:?} configuration", index); - adc.read_reg(&ad7172::regs::Channel { index }) - .map(|data| { - let _ = writeln!(socket, "{} setup={}", - if data.enabled() { "enabled" } else { "disabled" }, - data.setup() - ); - let _ = writeln!(socket, "ain+={} ain-={}", - data.a_in_pos(), data.a_in_neg() - ); - }); - adc.read_reg(&ad7172::regs::SetupCon { index }) - .map(|data| { - let _ = writeln!(socket, "{} burnout={}, ref={}", - if data.bi_unipolar() { "bipolar" } else { "unipolar" }, - if data.burnout_en() { "enabled" } else { "disabled" }, - data.ref_sel() - ); - }); - } command => { // TODO: remove for exhaustion check let _ = writeln!(socket, "Not implemented: {:?}", command);