From 93f14523d73d8ce2a32cc95f66160544d1471b1e Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 24 Sep 2020 01:17:50 +0200 Subject: [PATCH] command_parser: parse load/save --- README.md | 2 ++ src/command_parser.rs | 16 ++++++++++++++++ src/main.rs | 2 ++ 3 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 0d67e2e..1bc7d54 100644 --- a/README.md +++ b/README.md @@ -71,3 +71,5 @@ The scope of this setting is per TCP session. | `s-h` | Show Steinhart-Hart equation parameters | | `s-h <0/1> ` | Set Steinhart-Hart parameter for a channel | | `postfilter <0/1> rate ` | Set postfilter output data rate | +| `load` | Restore configuration from EEPROM | +| `save` | Save configuration to EEPROM | diff --git a/src/command_parser.rs b/src/command_parser.rs index db9d3a9..fd78315 100644 --- a/src/command_parser.rs +++ b/src/command_parser.rs @@ -131,6 +131,8 @@ pub enum CenterPoint { #[derive(Debug, Clone, PartialEq)] pub enum Command { Quit, + Load, + Save, Show(ShowCommand), Reporting(bool), /// PWM parameter setting @@ -405,6 +407,8 @@ fn postfilter(input: &[u8]) -> IResult<&[u8], Result> { fn command(input: &[u8]) -> IResult<&[u8], Result> { alt((value(Ok(Command::Quit), tag("quit")), + value(Ok(Command::Load), tag("load")), + value(Ok(Command::Save), tag("save")), map(report, Ok), pwm, center_point, @@ -437,6 +441,18 @@ mod test { assert_eq!(command, Ok(Command::Quit)); } + #[test] + fn parse_load() { + let command = Command::parse(b"load"); + assert_eq!(command, Ok(Command::Load)); + } + + #[test] + fn parse_save() { + let command = Command::parse(b"save"); + assert_eq!(command, Ok(Command::Save)); + } + #[test] fn parse_report() { let command = Command::parse(b"report"); diff --git a/src/main.rs b/src/main.rs index 916b228..afb1981 100644 --- a/src/main.rs +++ b/src/main.rs @@ -427,6 +427,8 @@ fn main() -> ! { } } } + Command::Load => {} + Command::Save => {} } Ok(SessionOutput::Error(e)) => { let _ = writeln!(socket, "Command error: {:?}", e);