diff --git a/Source/v2/Meadow.CLI.Core/PackageManager/PackageManager.cs b/Source/v2/Meadow.CLI.Core/PackageManager/PackageManager.cs index c4881a52..4ff24eee 100644 --- a/Source/v2/Meadow.CLI.Core/PackageManager/PackageManager.cs +++ b/Source/v2/Meadow.CLI.Core/PackageManager/PackageManager.cs @@ -230,7 +230,7 @@ public static FileInfo[] GetAvailableBuiltConfigurations(string rootFolder, stri // look for a 'bin' folder var path = Path.Combine(rootFolder, "bin"); - if (!Directory.Exists(path)) throw new FileNotFoundException($"No 'bin' directory found under {rootFolder}. Have you compiled?"); + if (!Directory.Exists(path)) throw new FileNotFoundException($"No 'bin' directory found under {rootFolder}. Have you compiled?"); var files = new List(); FindApp(path, files); diff --git a/Source/v2/Meadow.Cli/Commands/Current/App/AppBuildCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/App/AppBuildCommand.cs index a29a90ce..9831daf0 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/App/AppBuildCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/App/AppBuildCommand.cs @@ -20,7 +20,7 @@ public AppBuildCommand(IPackageManager packageManager, ILoggerFactory loggerFact _packageManager = packageManager; } - protected override async ValueTask ExecuteCommand() + protected override ValueTask ExecuteCommand() { string path = Path == null ? AppDomain.CurrentDomain.BaseDirectory @@ -33,11 +33,14 @@ protected override async ValueTask ExecuteCommand() if (!Directory.Exists(path)) { Logger?.LogError($"Invalid application path '{path}'"); - return; + return ValueTask.CompletedTask; } } - if (Configuration == null) Configuration = "Release"; + if (Configuration == null) + { + Configuration = "Release"; + } Logger?.LogInformation($"Building {Configuration} configuration of {path}..."); @@ -52,5 +55,6 @@ protected override async ValueTask ExecuteCommand() { Logger?.LogError($"Build successful"); } + return ValueTask.CompletedTask; } } \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Current/App/AppRunCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/App/AppRunCommand.cs index d5a3ba85..f11cc484 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/App/AppRunCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/App/AppRunCommand.cs @@ -1,5 +1,4 @@ using CliFx.Attributes; -using Meadow.CLI; using Meadow.Hcom; using Microsoft.Extensions.Logging; @@ -69,7 +68,7 @@ protected override async ValueTask ExecuteCommand() return; } - // illink returns before all files are actually written. That's not fun, but we must just wait a little while. + // illink returns before all files are written - attempt a delay of 1s await Task.Delay(1000); if (!await DeployApplication(connection, path, CancellationToken)) diff --git a/Source/v2/Meadow.Cli/Commands/Current/BaseCloudCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/BaseCloudCommand.cs index daccc131..618585b0 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/BaseCloudCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/BaseCloudCommand.cs @@ -65,4 +65,4 @@ public BaseCloudCommand( return org; } -} +} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Current/BaseCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/BaseCommand.cs index be3063e7..aa083008 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/BaseCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/BaseCommand.cs @@ -43,5 +43,4 @@ public async ValueTask ExecuteAsync(IConsole console) Logger?.LogInformation($"Done"); } } - } \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Current/BaseFileCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/BaseFileCommand.cs index 09e0d728..6edc65ef 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/BaseFileCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/BaseFileCommand.cs @@ -1,5 +1,4 @@ -using Meadow.CLI; -using Meadow.Software; +using Meadow.Software; using Microsoft.Extensions.Logging; namespace Meadow.CLI.Commands.DeviceManagement; @@ -13,4 +12,4 @@ public BaseFileCommand(FileManager fileManager, ISettingsManager settingsManager { FileManager = fileManager; } -} +} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Current/DeveloperCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/DeveloperCommand.cs index af1263f8..5fcd5185 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/DeveloperCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/DeveloperCommand.cs @@ -14,33 +14,29 @@ public class DeveloperCommand : BaseDeviceCommand public DeveloperCommand(MeadowConnectionManager connectionManager, ILoggerFactory loggerFactory) : base(connectionManager, loggerFactory) - { - } + { } protected override async ValueTask ExecuteCommand() { var connection = await GetCurrentConnection(); - if (connection == null) + if (connection == null || connection.Device == null) { + Logger?.LogError($"Developer parameter set failed - device or connection not found"); return; } Logger?.LogInformation($"Setting developer parameter {Parameter} to {Value}"); - if (connection != null) + connection.DeviceMessageReceived += (s, e) => { - connection.DeviceMessageReceived += (s, e) => - { - Logger?.LogInformation(e.message); - }; - connection.ConnectionError += (s, e) => - { - Logger?.LogError(e.Message); - }; - - await connection.Device.SetDeveloperParameter(Parameter, Value, CancellationToken); - } - } -} + Logger?.LogInformation(e.message); + }; + connection.ConnectionError += (s, e) => + { + Logger?.LogError(e.Message); + }; + await connection.Device.SetDeveloperParameter(Parameter, Value, CancellationToken); + } +} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Current/Device/DeviceProvisionCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/Device/DeviceProvisionCommand.cs index 23d16c6f..85d51793 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/Device/DeviceProvisionCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/Device/DeviceProvisionCommand.cs @@ -8,7 +8,7 @@ namespace Meadow.CLI.Commands.DeviceManagement; [Command("device provision", Description = "Registers and prepares connected device for use with Meadow Cloud")] public class DeviceProvisionCommand : BaseDeviceCommand { - private DeviceService _deviceService; + private readonly DeviceService _deviceService; public const string DefaultHost = "https://www.meadowcloud.co"; @@ -75,9 +75,9 @@ protected override async ValueTask ExecuteCommand() var connection = await GetCurrentConnection(); - if (connection == null) + if (connection == null || connection.Device == null) { - Logger?.LogError($"No connection path is defined"); + Logger?.LogError($"Device provision failed - device or connection not found"); return; } diff --git a/Source/v2/Meadow.Cli/Commands/Current/Firmware/FirmwareWriteCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/Firmware/FirmwareWriteCommand.cs index 942f1577..ae9b0fc1 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/Firmware/FirmwareWriteCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/Firmware/FirmwareWriteCommand.cs @@ -1,5 +1,4 @@ using CliFx.Attributes; -using Meadow.CLI; using Meadow.CLI.Core.Internals.Dfu; using Meadow.Hcom; using Meadow.LibUsb; @@ -58,7 +57,7 @@ protected override async ValueTask ExecuteCommand() if (!Files.Contains(FirmwareType.OS) && UseDfu) { - Logger?.LogError($"DFU is only used for OS files. Select an OS file or remove the DFU option"); + Logger?.LogError($"DFU is only used for OS files - select an OS file or remove the DFU option"); return; } @@ -199,7 +198,7 @@ private ILibUsbDevice GetLibUsbDeviceForCurrentEnvironment() _libUsbDevice = devices[0]; break; default: - throw new Exception("Multiple devices found in bootloader mode. Disconnect all but one"); + throw new Exception("Multiple devices found in bootloader mode - only connect one device"); } } @@ -298,7 +297,7 @@ private async ValueTask WriteFiles(IMeadowConnection connection) write_runtime: if (!await connection.Device.WriteRuntime(rtpath, CancellationToken)) { - Logger?.LogInformation($"Error writing runtime. Retrying."); + Logger?.LogInformation($"Error writing runtime - retrying"); goto write_runtime; } } diff --git a/Source/v2/Meadow.Cli/Commands/Current/ListenCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/ListenCommand.cs index 5834937e..e2f703c6 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/ListenCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/ListenCommand.cs @@ -11,11 +11,11 @@ public class ListenCommand : BaseDeviceCommand public ListenCommand(MeadowConnectionManager connectionManager, ILoggerFactory loggerFactory) : base(connectionManager, loggerFactory) - { - } + { } private void Connection_ConnectionMessage(object? sender, string e) { + //ToDo } private void OnDeviceMessageReceived(object? sender, (string message, string? source) e) @@ -49,4 +49,4 @@ protected override async ValueTask ExecuteCommand() await Task.Delay(1000); } } -} +} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/DownloadOsCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/DownloadOsCommand.cs index dd27dbc4..a3ea05cd 100644 --- a/Source/v2/Meadow.Cli/Commands/Legacy/DownloadOsCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Legacy/DownloadOsCommand.cs @@ -1,5 +1,4 @@ using CliFx.Attributes; -using Meadow.CLI; using Meadow.Software; using Microsoft.Extensions.Logging; @@ -11,6 +10,6 @@ public class DownloadOsCommand : FirmwareDownloadCommand public DownloadOsCommand(FileManager fileManager, ISettingsManager settingsManager, ILoggerFactory loggerFactory) : base(fileManager, settingsManager, loggerFactory) { - Logger?.LogWarning($"Deprecated command. Use `firmware download` instead"); + Logger?.LogWarning($"Deprecated command - use `firmware download` instead"); } } \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/FlashOsCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/FlashOsCommand.cs index b81f43aa..3fd95004 100644 --- a/Source/v2/Meadow.Cli/Commands/Legacy/FlashOsCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Legacy/FlashOsCommand.cs @@ -1,5 +1,4 @@ using CliFx.Attributes; -using Meadow.CLI; using Meadow.CLI.Core.Internals.Dfu; using Meadow.LibUsb; using Meadow.Software; @@ -11,7 +10,7 @@ namespace Meadow.CLI.Commands.DeviceManagement; public class FlashOsCommand : BaseDeviceCommand { [CommandOption("osFile", 'o', Description = "Path to the Meadow OS binary")] - public string OSFile { get; init; } + public string OSFile { get; init; } = default!; [CommandOption("runtimeFile", 'r', Description = "Path to the Meadow Runtime binary")] public string RuntimeFile { get; init; } @@ -39,10 +38,13 @@ public class FlashOsCommand : BaseDeviceCommand private ILibUsbDevice? _libUsbDevice; - public FlashOsCommand(ISettingsManager settingsManager, FileManager fileManager, MeadowConnectionManager connectionManager, ILoggerFactory loggerFactory) + public FlashOsCommand(ISettingsManager settingsManager, + FileManager fileManager, + MeadowConnectionManager connectionManager, + ILoggerFactory loggerFactory) : base(connectionManager, loggerFactory) { - Logger?.LogWarning($"Deprecated command. Use `firmware write` instead"); + Logger?.LogWarning($"Deprecated command. Use `firmware write` instead"); FileManager = fileManager; Settings = settingsManager; @@ -72,7 +74,7 @@ protected override async ValueTask ExecuteCommand() if (!Files.Contains(FirmwareType.OS) && UseDfu) { - Logger.LogError($"DFU is only used for OS files. Select an OS file or remove the DFU option"); + Logger.LogError($"DFU is only used for OS files - select an OS file or remove the DFU option"); return; } @@ -196,7 +198,7 @@ private ILibUsbDevice GetLibUsbDeviceForCurrentEnvironment() case 1: return devices[0]; default: - throw new Exception("Multiple devices found in bootloader mode. Disconnect all but one"); + throw new Exception("Multiple devices found in bootloader mode - only connect one device"); } } @@ -328,4 +330,4 @@ await DfuUtils.FlashFile( logger: Logger, format: DfuUtils.DfuFlashFormat.ConsoleOut); } -} +} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/InstallDfuCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/InstallDfuCommand.cs index 97613771..a28bb0c3 100644 --- a/Source/v2/Meadow.Cli/Commands/Legacy/InstallDfuCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Legacy/InstallDfuCommand.cs @@ -1,5 +1,4 @@ using CliFx.Attributes; -using Meadow.CLI; using Microsoft.Extensions.Logging; namespace Meadow.CLI.Commands.DeviceManagement; @@ -10,7 +9,6 @@ public class InstallDfuCommand : DfuInstallCommand public InstallDfuCommand(ISettingsManager settingsManager, ILoggerFactory loggerFactory) : base(settingsManager, loggerFactory, "0.11") { - Logger?.LogWarning($"Deprecated command. Use `dfu install` instead"); + Logger?.LogWarning($"Deprecated command - use `dfu install` instead"); } -} - +} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/ListPortsCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/ListPortsCommand.cs index 696c0b44..d99402d2 100644 --- a/Source/v2/Meadow.Cli/Commands/Legacy/ListPortsCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Legacy/ListPortsCommand.cs @@ -1,5 +1,4 @@ using CliFx.Attributes; -using Meadow.CLI; using Microsoft.Extensions.Logging; namespace Meadow.CLI.Commands.DeviceManagement; @@ -10,12 +9,11 @@ public class ListPortsCommand : PortListCommand public ListPortsCommand(ISettingsManager settingsManager, ILoggerFactory loggerFactory) : base(loggerFactory) { - Logger?.LogWarning($"Deprecated command. Use `port list` instead"); + Logger?.LogWarning($"Deprecated command - use `port list` instead"); } protected override ValueTask ExecuteCommand() { return base.ExecuteCommand(); } -} - +} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/MonoDisableCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/MonoDisableCommand.cs index 0a0807fe..8d9e63bf 100644 --- a/Source/v2/Meadow.Cli/Commands/Legacy/MonoDisableCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Legacy/MonoDisableCommand.cs @@ -9,6 +9,6 @@ public class MonoDisableCommand : RuntimeDisableCommand public MonoDisableCommand(MeadowConnectionManager connectionManager, ILoggerFactory loggerFactory) : base(connectionManager, loggerFactory) { - Logger?.LogWarning($"Deprecated command. Use `runtime disable` instead"); + Logger?.LogWarning($"Deprecated command - use `runtime disable` instead"); } -} +} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/MonoEnableCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/MonoEnableCommand.cs index f5bdb9f0..d19bafe9 100644 --- a/Source/v2/Meadow.Cli/Commands/Legacy/MonoEnableCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Legacy/MonoEnableCommand.cs @@ -9,6 +9,6 @@ public class MonoEnableCommand : RuntimeEnableCommand public MonoEnableCommand(MeadowConnectionManager connectionManager, ILoggerFactory loggerFactory) : base(connectionManager, loggerFactory) { - Logger.LogWarning($"Deprecated command. Use `runtime enable` instead"); + Logger?.LogWarning($"Deprecated command - use `runtime enable` instead"); } } \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/MonoStateCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/MonoStateCommand.cs index 02b08da3..4fd2a7d3 100644 --- a/Source/v2/Meadow.Cli/Commands/Legacy/MonoStateCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Legacy/MonoStateCommand.cs @@ -9,6 +9,6 @@ public class MonoStateCommand : RuntimeStateCommand public MonoStateCommand(MeadowConnectionManager connectionManager, ILoggerFactory loggerFactory) : base(connectionManager, loggerFactory) { - Logger.LogWarning($"Deprecated command. Use `runtime state` instead"); + Logger?.LogWarning($"Deprecated command - use `runtime state` instead"); } -} +} \ No newline at end of file diff --git a/Source/v2/Meadow.Cli/Commands/Legacy/UsePortCommand.cs b/Source/v2/Meadow.Cli/Commands/Legacy/UsePortCommand.cs index 87e4d06e..9413c036 100644 --- a/Source/v2/Meadow.Cli/Commands/Legacy/UsePortCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Legacy/UsePortCommand.cs @@ -1,5 +1,4 @@ using CliFx.Attributes; -using Meadow.CLI; using Microsoft.Extensions.Logging; namespace Meadow.CLI.Commands.DeviceManagement; @@ -7,7 +6,7 @@ namespace Meadow.CLI.Commands.DeviceManagement; [Command("use port", Description = "** Deprecated ** Use `config route` instead")] public class UsePortCommand : BaseCommand { - private ISettingsManager _settingsManager; + private readonly ISettingsManager _settingsManager; [CommandParameter(0, Name = "Port", IsRequired = true)] public string Port { get; set; } = default!; @@ -15,7 +14,7 @@ public class UsePortCommand : BaseCommand public UsePortCommand(ILoggerFactory loggerFactory, ISettingsManager settingsManager) : base(loggerFactory) { - Logger?.LogWarning($"Deprecated command. Use `config route` instead"); + Logger?.LogWarning($"Deprecated command -use `config route` instead"); _settingsManager = settingsManager; } @@ -26,5 +25,4 @@ protected override ValueTask ExecuteCommand() return ValueTask.CompletedTask; } -} - +} \ No newline at end of file diff --git a/Source/v2/Meadow.Hcom/Connections/SerialConnection.cs b/Source/v2/Meadow.Hcom/Connections/SerialConnection.cs index 2f4e5f81..26663cbb 100644 --- a/Source/v2/Meadow.Hcom/Connections/SerialConnection.cs +++ b/Source/v2/Meadow.Hcom/Connections/SerialConnection.cs @@ -193,7 +193,7 @@ public void Detach() // search for the device via HCOM - we'll use a simple command since we don't have a "ping" var command = RequestBuilder.Build(); - // sequence numbers are only for file retrieval. Setting it to non-zero will cause it to hang + // sequence numbers are only for file retrieval - Setting it to non-zero will cause it to hang _port.DiscardInBuffer();