command_parser: shorten to parallel_r, add tests

This commit is contained in:
Astro 2019-10-02 21:25:06 +02:00
parent 8611cc1c79
commit 12c2be0a03
2 changed files with 40 additions and 24 deletions

View File

@ -71,5 +71,5 @@ The scope of this setting is per TCP session.
| `pid <0/1> integral_max <value>` | Set integral upper bound | | `pid <0/1> integral_max <value>` | Set integral upper bound |
| `s-h` | Show Steinhart-Hart equation parameters | | `s-h` | Show Steinhart-Hart equation parameters |
| `s-h <0/1> <a/b/c> <value>` | Set Steinhart-Hart parameter for a channel | | `s-h <0/1> <a/b/c> <value>` | Set Steinhart-Hart parameter for a channel |
| `s-h <0/1> <parallel_resistance> <value>` | Set parallel resistance of the ADC | | `s-h <0/1> parallel_r <value>` | Set parallel resistance of the ADC |
| `postfilter <0/1> rate <rate>` | Set postfilter output data rate | | `postfilter <0/1> rate <rate>` | Set postfilter output data rate |

View File

@ -323,7 +323,7 @@ fn steinhart_hart_parameter(input: &[u8]) -> IResult<&[u8], Result<Command, Erro
alt((value(ShParameter::A, tag("a")), alt((value(ShParameter::A, tag("a")),
value(ShParameter::B, tag("b")), value(ShParameter::B, tag("b")),
value(ShParameter::C, tag("c")), value(ShParameter::C, tag("c")),
value(ShParameter::ParallelR, tag("parallel_resistance")) value(ShParameter::ParallelR, tag("parallel_r"))
))(input)?; ))(input)?;
let (input, _) = whitespace(input)?; let (input, _) = whitespace(input)?;
let (input, value) = float(input)?; let (input, value) = float(input)?;
@ -506,6 +506,22 @@ mod test {
})); }));
} }
#[test]
fn parse_steinhart_hart() {
let command = Command::parse(b"s-h");
assert_eq!(command, Ok(Command::Show(ShowCommand::SteinhartHart)));
}
#[test]
fn parse_steinhart_hart_parallel_r() {
let command = Command::parse(b"s-h 1 parallel_r 23.05");
assert_eq!(command, Ok(Command::SteinhartHart {
channel: 1,
parameter: ShParameter::ParallelR,
value: 23.05,
}));
}
#[test] #[test]
fn parse_postfilter_rate() { fn parse_postfilter_rate() {
let command = Command::parse(b"postfilter 0 rate 21"); let command = Command::parse(b"postfilter 0 rate 21");