command_parser: shorten to parallel_r, add tests
This commit is contained in:
parent
8611cc1c79
commit
12c2be0a03
@ -50,26 +50,26 @@ The scope of this setting is per TCP session.
|
|||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
|
|
||||||
| Syntax | Function |
|
| Syntax | Function |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `report` | Show current input |
|
| `report` | Show current input |
|
||||||
| `report mode` | Show current report mode |
|
| `report mode` | Show current report mode |
|
||||||
| `report mode <off/on>` | Set report mode |
|
| `report mode <off/on>` | Set report mode |
|
||||||
| `pwm <0/1> max_i_pos <width> <total>` | Set PWM duty cycle for **max_i_pos** to *width / total* |
|
| `pwm <0/1> max_i_pos <width> <total>` | Set PWM duty cycle for **max_i_pos** to *width / total* |
|
||||||
| `pwm <0/1> max_i_neg <width> <total>` | Set PWM duty cycle for **max_i_neg** to *width / total* |
|
| `pwm <0/1> max_i_neg <width> <total>` | Set PWM duty cycle for **max_i_neg** to *width / total* |
|
||||||
| `pwm <0/1> max_v <width> <total>` | Set PWM duty cycle for **max_v** to *width / total* |
|
| `pwm <0/1> max_v <width> <total>` | Set PWM duty cycle for **max_v** to *width / total* |
|
||||||
| `pwm <0/1> <width> <total>` | Set PWM duty cycle for **i_set** to manual *width / total* |
|
| `pwm <0/1> <width> <total>` | Set PWM duty cycle for **i_set** to manual *width / total* |
|
||||||
| `pwm <0/1> pid` | Set PWM to be controlled by PID |
|
| `pwm <0/1> pid` | Set PWM to be controlled by PID |
|
||||||
| `pid` | Show PID configuration |
|
| `pid` | Show PID configuration |
|
||||||
| `pid <0/1> target <value>` | Set the PID controller target |
|
| `pid <0/1> target <value>` | Set the PID controller target |
|
||||||
| `pid <0/1> kp <value>` | Set proportional gain |
|
| `pid <0/1> kp <value>` | Set proportional gain |
|
||||||
| `pid <0/1> ki <value>` | Set integral gain |
|
| `pid <0/1> ki <value>` | Set integral gain |
|
||||||
| `pid <0/1> kd <value>` | Set differential gain |
|
| `pid <0/1> kd <value>` | Set differential gain |
|
||||||
| `pid <0/1> output_min <value>` | Set mininum output |
|
| `pid <0/1> output_min <value>` | Set mininum output |
|
||||||
| `pid <0/1> output_max <value>` | Set maximum output |
|
| `pid <0/1> output_max <value>` | Set maximum output |
|
||||||
| `pid <0/1> integral_min <value>` | Set integral lower bound |
|
| `pid <0/1> integral_min <value>` | Set integral lower bound |
|
||||||
| `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 |
|
||||||
|
@ -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");
|
||||||
|
Loading…
Reference in New Issue
Block a user