command_parser: parse load/save

pull/20/head
Astro 2020-09-24 01:17:50 +02:00
parent 201701ee8b
commit 93f14523d7
3 changed files with 20 additions and 0 deletions

View File

@ -71,3 +71,5 @@ The scope of this setting is per TCP session.
| `s-h` | Show Steinhart-Hart equation parameters |
| `s-h <0/1> <t/b/r0> <value>` | Set Steinhart-Hart parameter for a channel |
| `postfilter <0/1> rate <rate>` | Set postfilter output data rate |
| `load` | Restore configuration from EEPROM |
| `save` | Save configuration to EEPROM |

View File

@ -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<Command, Error>> {
fn command(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
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");

View File

@ -427,6 +427,8 @@ fn main() -> ! {
}
}
}
Command::Load => {}
Command::Save => {}
}
Ok(SessionOutput::Error(e)) => {
let _ = writeln!(socket, "Command error: {:?}", e);