Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Tool for inspecting, updating and interfacing with Harp devices, with automatic
6. To update the device firmware from a local HEX file:

```cmd
dotnet harp.toolkit update --port COM4 --path Behavior-fw3.2-harp1.13-hw2.0-ass0.hex
dotnet harp.toolkit update --port COM4 Behavior-fw3.2-harp1.13-hw2.0-ass0.hex
```

7. To restore the tool at any point, run:
Expand Down
6 changes: 3 additions & 3 deletions docs/articles/verify.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Verification stops at the first request left unanswered for 2000 ms, since a lat
--port <port>
```

Specifies the name of the serial port used to communicate with the device. This option is required.
Name of the serial port used to communicate with the device. This option is required.

#### Detailed results
```ps1
Expand Down Expand Up @@ -74,7 +74,7 @@ The report is titled with the device name and opens with a header describing the
--report <report>
```

Path of the HTML report written after the run. Without it the results are printed and not saved.
Path to the HTML report written after the run. Without it the results are printed and not saved.

### Acting on a reported failure

Expand Down Expand Up @@ -126,6 +126,6 @@ dotnet harp.toolkit verify --port COM3 --metadata device.yml
--metadata <metadata>
```

Path of the file describing the device registers. The file must exist.
Path to the file describing the device registers. The file must exist.

Unlike code generation, this option has no default, so a `device.yml` located in the current directory does not automatically enable these checks.
2 changes: 1 addition & 1 deletion src/Harp.Toolkit/DevicePortNameOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class DevicePortNameOption : PortNameOption
public DevicePortNameOption()
: base("--port")
{
Description = "Specifies the name of the serial port used to communicate with the device.";
Description = "Name of the serial port used to communicate with the device.";
Required = true;
}
}
2 changes: 1 addition & 1 deletion src/Harp.Toolkit/Generate/GenerateFirmwareCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public GenerateFirmwareCommand()

Option<bool> generateImplementationOption = new("--implementation")
{
Description = "Indicates whether to generate implementation (.c) files. The default is false."
Description = "Generate implementation (.c) files. The default is false."
};

Arguments.Add(metadataPathArgument);
Expand Down
4 changes: 2 additions & 2 deletions src/Harp.Toolkit/Generate/OutputPathOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class OutputPathOption : Option<DirectoryInfo>
public OutputPathOption()
: base("-o", "--output")
{
Description = "Location to place the generated output. The default is the current directory.";
DefaultValueFactory = _ => new DirectoryInfo(Environment.CurrentDirectory);
Description = "Location to place the generated output.";
DefaultValueFactory = _ => new DirectoryInfo(".");
}
}
2 changes: 1 addition & 1 deletion src/Harp.Toolkit/PortTimeoutOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class PortTimeoutOption : Option<int>
public PortTimeoutOption()
: base("--timeout")
{
Description = "Specifies the timeout, in milliseconds, to receive a response from the device. Use -1 to wait indefinitely.";
Description = "Timeout in milliseconds to receive a response from the device. Use -1 to wait indefinitely.";
DefaultValueFactory = _ => 2000;
Validators.Add(result =>
{
Expand Down
33 changes: 26 additions & 7 deletions src/Harp.Toolkit/UpdateFirmwareCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,42 @@ public UpdateFirmwareCommand()
: base("update", "Update the device firmware from a local HEX file.")
{
DevicePortNameOption portNameOption = new();
Option<FileInfo> firmwarePathOption = new("--path")
{
Description = "Specifies the path of the firmware file to write to the device.",
Required = true
};
Argument<FileInfo> firmwareArgument = ArgumentValidation.AcceptExistingOnly(
new Argument<FileInfo>("firmware")
{
Description = "Path to the firmware file.",
Arity = ArgumentArity.ZeroOrOne
});

Option<FileInfo> firmwarePathOption = OptionValidation.AcceptExistingOnly(
new Option<FileInfo>("--path")
{
Description = "Path to the firmware file.",
Hidden = true
});

Option<bool> forceUpdateOption = new("--force")
{
Description = "Indicates whether to force a firmware update on the device regardless of compatibility."
Description = "Force a firmware update regardless of compatibility."
};

Arguments.Add(firmwareArgument);
Options.Add(portNameOption);
Options.Add(firmwarePathOption);
Options.Add(forceUpdateOption);
Validators.Add(result =>
{
var hasArgument = result.GetResult(firmwareArgument) is not null;
var hasOption = result.GetResult(firmwarePathOption) is not null;
if (!hasArgument && !hasOption)
result.AddError("Required argument missing for command: 'update'.");
else if (hasArgument && hasOption)
result.AddError("The firmware file must be given either as an argument or with --path, not both.");
});

SetAction(parseResult =>
{
var firmwarePath = parseResult.GetRequiredValue(firmwarePathOption);
var firmwarePath = parseResult.GetValue(firmwareArgument) ?? parseResult.GetValue(firmwarePathOption)!;
var portName = parseResult.GetRequiredValue(portNameOption);
var forceUpdate = parseResult.GetValue(forceUpdateOption);

Expand Down
Loading