command_parser: require the explicit i_set symbol

This commit is contained in:
Astro 2020-12-09 01:07:08 +01:00
parent b92a5f18cd
commit 5c8bb47e11
2 changed files with 20 additions and 12 deletions

View File

@ -75,7 +75,7 @@ The scope of this setting is per TCP session.
| `pwm <0/1> max_i_pos <amp>` | Set PWM duty cycle for **max_i_pos** to *ampere* |
| `pwm <0/1> max_i_neg <amp>` | Set PWM duty cycle for **max_i_neg** to *ampere* |
| `pwm <0/1> max_v <volts>` | Set PWM duty cycle for **max_v** to *volt* |
| `pwm <0/1> <amp>` | Disengage PID, set **i_set** DAC to *ampere* |
| `pwm <0/1> i_set <amp>` | Disengage PID, set **i_set** DAC to *ampere* |
| `pwm <0/1> pid` | Set PWM to be controlled by PID |
| `center <0/1> <volts>` | Set the MAX1968 0A-centerpoint to *volts* |
| `center <0/1> vref` | Set the MAX1968 0A-centerpoint to measure from VREF |
@ -151,7 +151,7 @@ Use the `pwm` command to see current settings and maximum values.
| `max_v` | Volts | Maximum voltage |
| `max_i_pos` | Amperes | Maximum positive current |
| `max_i_neg` | Amperes | Maximum negative current |
| | Amperes | Output current control (Open-loop mode) |
| `i_set` | Amperes | (Not a limit; Open-loop mode) |
Example: set the maximum voltage of channel 0 to 1.5 V.
```
@ -166,7 +166,7 @@ channel.
Example: set output current of channel 0 to 0 A.
```
pwm 0 0
pwm 0 i_set 0
```
## PID-stabilized temperature control

View File

@ -249,6 +249,16 @@ fn pwm_setup(input: &[u8]) -> IResult<&[u8], Result<(PwmPin, f64), Error>> {
result.map(|value| (pin, value));
alt((
map(
preceded(
tag("i_set"),
preceded(
whitespace,
float
)
),
result_with_pin(PwmPin::ISet)
),
map(
preceded(
tag("max_i_pos"),
@ -278,8 +288,6 @@ fn pwm_setup(input: &[u8]) -> IResult<&[u8], Result<(PwmPin, f64), Error>> {
)
),
result_with_pin(PwmPin::MaxV)
),
map(float, result_with_pin(PwmPin::ISet)
))
)(input)
}
@ -528,8 +536,8 @@ mod test {
}
#[test]
fn parse_pwm_manual() {
let command = Command::parse(b"pwm 1 16383");
fn parse_pwm_i_set() {
let command = Command::parse(b"pwm 1 i_set 16383");
assert_eq!(command, Ok(Command::Pwm {
channel: 1,
pin: PwmPin::ISet,