Skip to content

Commit

Permalink
Merge pull request #619 from WildernessLabs/dfu_usb_error
Browse files Browse the repository at this point in the history
Improve output when flashing with a missing USB driver or bad connection/cable
  • Loading branch information
ctacke authored Feb 3, 2025
2 parents ad30ffe + 4371644 commit 337268a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class FirmwareWriteCommand : BaseDeviceCommand<FirmwareWriteCommand>
private FileManager FileManager { get; }
private ISettingsManager Settings { get; }

private string DFU_USB_ERROR_MESSAGE = "Operation not supported or unimplemented on this platform";

public FirmwareWriteCommand(ISettingsManager settingsManager, FileManager fileManager, MeadowConnectionManager connectionManager, ILoggerFactory loggerFactory)
: base(connectionManager, loggerFactory)
{
Expand Down Expand Up @@ -181,7 +183,22 @@ protected override async ValueTask ExecuteCommand()

// do we have a dfu device attached, or is DFU specified?
var provider = new LibUsbProvider();
var dfuDevice = GetLibUsbDeviceForCurrentEnvironment(provider);

ILibUsbDevice? dfuDevice = null;

try
{
dfuDevice = GetLibUsbDeviceForCurrentEnvironment(provider);
}
catch (Exception ex)
{
if (ex.Message.Contains(DFU_USB_ERROR_MESSAGE))
{
var msg = "Exception: " + ex.Message + Environment.NewLine + Environment.NewLine + Strings.DfuUsbErrorMessage;
throw new CommandException(msg, ex);
}
}

bool ignoreSerial = IgnoreSerialNumberForDfu(provider);

if (dfuDevice != null)
Expand Down
2 changes: 1 addition & 1 deletion Source/Meadow.CLI/Meadow.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Authors>Wilderness Labs, Inc</Authors>
<Company>Wilderness Labs, Inc</Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>2.0.66.0</PackageVersion>
<PackageVersion>2.0.67.0</PackageVersion>
<Platforms>AnyCPU</Platforms>
<PackageProjectUrl>http://developer.wildernesslabs.co/Meadow/Meadow.CLI/</PackageProjectUrl>
<RepositoryUrl>https://github.com/WildernessLabs/Meadow.CLI</RepositoryUrl>
Expand Down
2 changes: 1 addition & 1 deletion Source/Meadow.CLI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ namespace Meadow.CLI;

public static class Constants
{
public const string CLI_VERSION = "2.0.66.0";
public const string CLI_VERSION = "2.0.67.0";
}
10 changes: 4 additions & 6 deletions Source/Meadow.CLI/Strings.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Meadow.Telemetry;
using Spectre.Console;

namespace Meadow.CLI;
namespace Meadow.CLI;

public static class Strings
{
Expand Down Expand Up @@ -71,8 +68,9 @@ public static class Strings
public const string AppDeployFailed = "Application deploy failed";
public const string AppDeployedSuccessfully = "Application deployed successfully";
public const string AppTrimFailed = "Application trimming failed";
public const string WithConfiguration = "with configuration";
public const string At = "at";
public const string WithConfiguration = "with configuration";
public const string At = "at";
public const string DfuUsbErrorMessage = "Found a DFU device but couldn't identify it as Meadow hardware. \r\nEnsure your device is in DFU mode and is correctly recognized by the host development machine.";

public static class Telemetry
{
Expand Down

0 comments on commit 337268a

Please sign in to comment.