diff --git a/BaseStationEX b/BaseStationEX new file mode 160000 index 0000000..06aa5d0 --- /dev/null +++ b/BaseStationEX @@ -0,0 +1 @@ +Subproject commit 06aa5d0b73c8cbaed5ddbba3c8ee5476b143c86e diff --git a/BaseStationInstaller/App.xaml b/BaseStationInstaller/App.xaml index 1f78778..41f6629 100644 --- a/BaseStationInstaller/App.xaml +++ b/BaseStationInstaller/App.xaml @@ -6,6 +6,20 @@ + + #FF00A3B9 + #FF00353D + #FF373737 + #FFFFFFFF + #FF6C6C6C + + + + + + + + diff --git a/BaseStationInstaller/App.xaml.cs b/BaseStationInstaller/App.xaml.cs index 00c910a..f372414 100644 --- a/BaseStationInstaller/App.xaml.cs +++ b/BaseStationInstaller/App.xaml.cs @@ -3,6 +3,7 @@ using Avalonia.Markup.Xaml; using BaseStationInstaller.ViewModels; using BaseStationInstaller.Views; +using Avalonia.ReactiveUI; namespace BaseStationInstaller diff --git a/BaseStationInstaller/Assets/Audiowide-Regular.ttf b/BaseStationInstaller/Assets/Audiowide-Regular.ttf new file mode 100644 index 0000000..e5d242b Binary files /dev/null and b/BaseStationInstaller/Assets/Audiowide-Regular.ttf differ diff --git a/BaseStationInstaller/Assets/Flamenco-Regular.ttf b/BaseStationInstaller/Assets/Flamenco-Regular.ttf new file mode 100644 index 0000000..fb3e8c9 Binary files /dev/null and b/BaseStationInstaller/Assets/Flamenco-Regular.ttf differ diff --git a/BaseStationInstaller/Assets/avalonia-logo.ico b/BaseStationInstaller/Assets/avalonia-logo.ico deleted file mode 100644 index da8d49f..0000000 Binary files a/BaseStationInstaller/Assets/avalonia-logo.ico and /dev/null differ diff --git a/BaseStationInstaller/Assets/dcc-ex-logo.png b/BaseStationInstaller/Assets/dcc-ex-logo.png new file mode 100644 index 0000000..929706d Binary files /dev/null and b/BaseStationInstaller/Assets/dcc-ex-logo.png differ diff --git a/BaseStationInstaller/Assets/dccex-logo.ico b/BaseStationInstaller/Assets/dccex-logo.ico new file mode 100644 index 0000000..aeea5b2 Binary files /dev/null and b/BaseStationInstaller/Assets/dccex-logo.ico differ diff --git a/BaseStationInstaller/BaseStationInstaller.csproj b/BaseStationInstaller/BaseStationInstaller.csproj index 8d20267..cdf7802 100644 --- a/BaseStationInstaller/BaseStationInstaller.csproj +++ b/BaseStationInstaller/BaseStationInstaller.csproj @@ -5,11 +5,13 @@ win-x86;win-x64;osx-x64;linux-x64;linux-arm;linux-arm64 BaseStationInstaller.Program BaseStationInstaller - 2.0.0 + 2.1.0 Dex's Lab DCC++ Extended https://dcc-ex.github.io/ https://github.com/DCC-EX/BaseStation-Installer + dcc-ex-logo.png + Assets\dccex-logo.ico @@ -21,14 +23,32 @@ - - - + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - + + + + + + + + + Always @@ -57,5 +77,9 @@ Always + + True + + diff --git a/BaseStationInstaller/Models/BaseStationSettings.cs b/BaseStationInstaller/Models/BaseStationSettings.cs index aa72b16..637d0d2 100644 --- a/BaseStationInstaller/Models/BaseStationSettings.cs +++ b/BaseStationInstaller/Models/BaseStationSettings.cs @@ -45,7 +45,7 @@ public static class BaseStationSettings Name = "BaseStationEX", Git = "https://github.com/DCC-EX/BaseStation-EX.git", ConfigFile = $@"DCCpp_EX/DCCppEX/Config.h", - InputFileLocation = "DCCpp_EX/DCCppEX/DCCppEX.ino", + InputFileLocation = "DCCpp_EX/DCCppEX", Libraries = new List(), AllowAdvanced = true, SupportedBoards = new List() @@ -67,7 +67,7 @@ public static class BaseStationSettings Name = "BaseStationClassic", DisplayName = "Base Station Classic", ConfigFile = @"DCCpp/Config.h", - InputFileLocation = "DCCpp/DCCpp.ino", + InputFileLocation = "DCCpp", Git = "https://github.com/DCC-EX/BaseStation-Classic.git", Libraries = new List(), AllowAdvanced = false, @@ -85,11 +85,11 @@ public static class BaseStationSettings },{ new Config { - DisplayName = "CommandStation Test", - Name = "CommandStation", + DisplayName = "CommandStation EX", + Name = "CommandStation-DCC", Git = "https://github.com/DCC-EX/CommandStation-DCC.git", - ConfigFile = @"src/main.cpp", - InputFileLocation = @"src/main.cpp", + ConfigFile = @"Config.h", + InputFileLocation = @"", AllowAdvanced = true, Libraries = new List() { @@ -109,6 +109,8 @@ public static class BaseStationSettings { new MotorShield("Arduino Motor Shield", MotorShieldType.Arduino), new MotorShield("Pololu MC33926 Motor Shield", MotorShieldType.Pololu), + new MotorShield("FireBox MK1", MotorShieldType.FireBox_MK1), + new MotorShield("FireBox MK1S", MotorShieldType.FireBox_MK1S), //new MotorShield("BTS7960B Motor Shield", MotorShieldType.BTS7960B), } } diff --git a/BaseStationInstaller/Models/MotorShield.cs b/BaseStationInstaller/Models/MotorShield.cs index b52ad41..19999d7 100644 --- a/BaseStationInstaller/Models/MotorShield.cs +++ b/BaseStationInstaller/Models/MotorShield.cs @@ -10,7 +10,9 @@ public enum MotorShieldType { Arduino, Pololu, - BTS7960B + BTS7960B, + FireBox_MK1, + FireBox_MK1S } public class MotorShield { diff --git a/BaseStationInstaller/Utils/ArudinoCliHelper.cs b/BaseStationInstaller/Utils/ArudinoCliHelper.cs index da6267e..3f02692 100644 --- a/BaseStationInstaller/Utils/ArudinoCliHelper.cs +++ b/BaseStationInstaller/Utils/ArudinoCliHelper.cs @@ -1,9 +1,19 @@ -using BaseStationInstaller.ViewModels; +using Avalonia.Threading; +using BaseStationInstaller.ViewModels; +using Cc.Arduino.Cli.Commands; +using DynamicData; +using Grpc.Core; +using Grpc.Net.Client; using ReactiveUI; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; +using System.IO; +using System.Runtime.CompilerServices; using System.Text; +using System.Threading; +using System.Threading.Tasks; using System.Windows.Input; namespace BaseStationInstaller.Utils @@ -11,144 +21,261 @@ namespace BaseStationInstaller.Utils public class ArudinoCliHelper { IMainWindowViewModel mainWindowView; + GrpcChannel channel; + ArduinoCore.ArduinoCoreClient client; + Instance instance; public ArudinoCliHelper(IMainWindowViewModel mWindow) { mainWindowView = mWindow; mainWindowView.Busy = true; ProcessStartInfo start = new ProcessStartInfo(); + AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); start.FileName = $@"arduino-cli"; - start.Arguments = "core update-index"; start.UseShellExecute = false; start.WindowStyle = ProcessWindowStyle.Hidden; start.CreateNoWindow = true; start.RedirectStandardOutput = true; + start.RedirectStandardError = true; Process process = new Process(); - process.OutputDataReceived += Process_OutputDataReceived; + start.Arguments = "daemon"; + start.RedirectStandardOutput = false; + start.RedirectStandardError = false; process.StartInfo = start; process.Start(); - mainWindowView.Status += process.StandardOutput.ReadToEnd(); - process.WaitForExit(); - process = new Process(); - start.Arguments = "core install arduino:avr"; - process.OutputDataReceived += Process_OutputDataReceived; - process.StartInfo = start; - process.Start(); - mainWindowView.Status += process.StandardOutput.ReadToEnd(); - process.WaitForExit(); - process = new Process(); - start.Arguments = "core install arduino:mega"; - process.OutputDataReceived += Process_OutputDataReceived; - process.StartInfo = start; - process.Start(); - mainWindowView.Status += process.StandardOutput.ReadToEnd(); - process.WaitForExit(); - process = new Process(); - start.Arguments = "core install arduino:samd"; - process.OutputDataReceived += Process_OutputDataReceived; - process.StartInfo = start; - process.Start(); - mainWindowView.Status += process.StandardOutput.ReadToEnd(); - process.WaitForExit(); - process = new Process(); - start.Arguments = "core install arduino:uno"; - process.OutputDataReceived += Process_OutputDataReceived; - process.StartInfo = start; - process.Start(); - mainWindowView.Status += process.StandardOutput.ReadToEnd(); - process.WaitForExit(); - process = new Process(); - start.Arguments = "core install SparkFun:samd"; - process.OutputDataReceived += Process_OutputDataReceived; - process.StartInfo = start; - process.Start(); - mainWindowView.Status += process.StandardOutput.ReadToEnd(); - process.WaitForExit(); + Task task = new Task(Init); + task.Start(); + + } + + + string currentFile = ""; + long totalSize = 0; + public async void Init() + { + mainWindowView.Busy = true; + channel = GrpcChannel.ForAddress("http://127.0.0.1:27160", new GrpcChannelOptions { Credentials = ChannelCredentials.Insecure }); + client = new ArduinoCore.ArduinoCoreClient(channel); + AsyncServerStreamingCall init = client.Init(new InitReq()); + + while (await init.ResponseStream.MoveNext()) + { + InitResp resp = init.ResponseStream.Current; + instance = resp.Instance; + } + + AsyncServerStreamingCall update = client.UpdateIndex(new UpdateIndexReq { Instance = instance }); + while (await update.ResponseStream.MoveNext()) + { + UpdateIndexResp resp = update.ResponseStream.Current; + if (resp.DownloadProgress != null) + { + if (!String.IsNullOrEmpty(resp.DownloadProgress.File)) + { + currentFile = resp.DownloadProgress.File; + totalSize = resp.DownloadProgress.TotalSize; + } + if (!resp.DownloadProgress.Completed) + { + mainWindowView.Status += $"Downloading {currentFile}: {resp.DownloadProgress.Downloaded}/{totalSize}"; + } + else + { + mainWindowView.Status += $"{currentFile} download complete"; + } + } + + } + + AsyncServerStreamingCall avr = client.PlatformInstall(new PlatformInstallReq { Instance = instance, Architecture = "avr", PlatformPackage = "arduino" }); + while (await avr.ResponseStream.MoveNext()) + { + SendProgress(avr.ResponseStream.Current); + } + + AsyncServerStreamingCall mega = client.PlatformInstall(new PlatformInstallReq { Instance = instance, Architecture = "megaavr", PlatformPackage = "arduino" }); + while (await mega.ResponseStream.MoveNext()) + { + SendProgress(mega.ResponseStream.Current); + } + + AsyncServerStreamingCall samd = client.PlatformInstall(new PlatformInstallReq { Instance = instance, Architecture = "samd", PlatformPackage = "arduino" }); + while (await samd.ResponseStream.MoveNext()) + { + SendProgress(samd.ResponseStream.Current); + } + + AsyncServerStreamingCall sparkfun = client.PlatformInstall(new PlatformInstallReq { Instance = instance, Architecture = "samd", PlatformPackage = "SparkFun" }); + while (await sparkfun.ResponseStream.MoveNext()) + { + SendProgress(sparkfun.ResponseStream.Current); + } + + mainWindowView.Status += "Boards Installed and Arduino CLI initialized"; + mainWindowView.Progress = 0; mainWindowView.Busy = false; } + + + private void SendProgress(PlatformInstallResp resp) + { + if (resp.Progress != null) + { + if (!String.IsNullOrEmpty(resp.Progress.File)) + { + currentFile = resp.Progress.File; + totalSize = resp.Progress.TotalSize; + } + if (!resp.Progress.Completed) + { + mainWindowView.Status += $"Downloading {currentFile}: {resp.Progress.Downloaded}/{totalSize}"; + mainWindowView.Progress = (int)(resp.Progress.Downloaded / totalSize); + } + else + { + mainWindowView.Status += $"{currentFile} download complete"; + } + } + } + /// /// Attempt to copile Arudino Sketch /// /// Fully qualified board name for Arduino Board /// Location of ino/cpp file - public void ArduinoComplieSketch(string fqbn, string location,string port) + public async void ArduinoComplieSketch(string fqbn, string location) { - mainWindowView.Busy = true; - ProcessStartInfo start = new ProcessStartInfo(); - start.FileName = $@"arduino-cli"; - start.Arguments = $"compile -v -p {port} -u --fqbn {fqbn} --output-dir . ./{location}"; - start.UseShellExecute = false; - start.WindowStyle = ProcessWindowStyle.Hidden; - start.RedirectStandardOutput = true; - start.CreateNoWindow = true; - Process process = new Process(); - process.OutputDataReceived += Process_OutputDataReceived; - process.StartInfo = start; - process.Start(); - mainWindowView.Status += process.StandardOutput.ReadToEnd(); - process.WaitForExit(); - mainWindowView.Busy = false; + AsyncServerStreamingCall compile = client.Compile(new CompileReq { Instance = instance, Fqbn = fqbn, Verbose = true, SketchPath = $"./{location}" }); + try + { + int count = 0; + while (await compile.ResponseStream.MoveNext()) + { + mainWindowView.Status += compile.ResponseStream.Current.OutStream.ToStringUtf8(); + count++; + if (count % 3 == 0) + { + mainWindowView.Progress++; + } + if (compile.ResponseStream.Current.ErrStream.Length >= 1) + { + mainWindowView.Status += $"ERROR: {compile.ResponseStream.Current.ErrStream.ToStringUtf8()}"; + } + } + } + catch (RpcException e) + { + mainWindowView.Status += $"Failed to compile sketch in {location} got error {e.Status.Detail}"; + } } /// /// Attempt to compile and upload Arudino Sketch /// /// Fully qualified board name for Arduino Board /// Location of ino/cpp file - public void UploadSketch(string fqbn, string port, string file) + public async void UploadSketch(string fqbn, string port, string location) { - mainWindowView.Busy = true; - ProcessStartInfo start = new ProcessStartInfo(); - start.FileName = $@"arduino-cli"; - start.Arguments = $@"upload --fqbn {fqbn} -p {port} -i .\{file}.hex -v -t"; - start.UseShellExecute = false; - start.WindowStyle = ProcessWindowStyle.Hidden; - start.RedirectStandardOutput = true; - start.CreateNoWindow = true; - Process process = new Process(); - process.OutputDataReceived += Process_OutputDataReceived; - process.StartInfo = start; - process.Start(); - mainWindowView.Status += process.StandardOutput.ReadToEnd(); - process.WaitForExit(); - mainWindowView.Busy = false; + mainWindowView.RefreshingPorts = true; + AsyncServerStreamingCall upload = client.Upload(new UploadReq { Instance = instance, Fqbn = fqbn, Port = port, SketchPath = location, Verbose = true, Verify = true }); + try + { + StringBuilder sb = new StringBuilder(); + Stopwatch time = new Stopwatch(); + time.Start(); + int count = 0; + while (await upload.ResponseStream.MoveNext()) + { + mainWindowView.Status += $"Uploading elasped time {Math.Round(time.ElapsedMilliseconds * 0.001, 3).ToString("00.000")} seconds"; + count++; + if (count % 10 == 0) + { + mainWindowView.Progress++; + } + sb.Append($"{upload.ResponseStream.Current.OutStream.ToStringUtf8()}"); + sb.Append($"{upload.ResponseStream.Current.ErrStream.ToStringUtf8()}"); + } + time.Stop(); + mainWindowView.Status += sb.ToString(); + mainWindowView.Status += $"Uploaded and Verified to {port} in {Math.Round(time.ElapsedMilliseconds * 0.001,3).ToString("00.000")} seconds"; + mainWindowView.Progress = 100; + Thread.Sleep(2500); + mainWindowView.Progress = 0; + mainWindowView.Busy = false; + mainWindowView.RefreshingPorts = false; + } + catch (RpcException e) + { + mainWindowView.Status += $"Failed to upload because {e.Status.Detail}"; + mainWindowView.Progress = 0; + mainWindowView.Busy = false; + mainWindowView.RefreshingPorts = false; + } + } - public void DetectBoard() + /// + /// Detect attached boards and select it. + /// + public async void DetectBoard() { + mainWindowView.Busy = true; - //arduino-cli board list - ProcessStartInfo start = new ProcessStartInfo(); - start.FileName = $@"arduino-cli"; - start.Arguments = "board list"; - start.UseShellExecute = false; - start.WindowStyle = ProcessWindowStyle.Hidden; - start.RedirectStandardOutput = true; - start.CreateNoWindow = true; - Process process = new Process(); - process.OutputDataReceived += Process_OutputDataReceived; - process.StartInfo = start; - process.Start(); - mainWindowView.Status += process.StandardOutput.ReadToEnd(); - process.WaitForExit(); + mainWindowView.RefreshingPorts = true; + mainWindowView.AvailableComPorts = new ObservableCollection(); + BoardListResp boards = client.BoardList(new BoardListReq { Instance = instance }); + foreach (DetectedPort port in boards.Ports) + { + if (port.Boards.Count > 0) + { + + mainWindowView.Status += $"Detected a {port.Boards[0].Name} on port {port.Address}"; + Dispatcher.UIThread.InvokeAsync(() => + { + mainWindowView.AvailableComPorts.Add(port.Address); + }); + Thread.Sleep(1000); + + if (String.IsNullOrEmpty(mainWindowView.SelectedComPort)) + { + mainWindowView.SelectedBoard = mainWindowView.SelectedConfig.SupportedBoards.Find((b) => b.FQBN == port.Boards[0].FQBN); + mainWindowView.SelectedComPort = port.Address; + } + + } + } mainWindowView.Busy = false; + mainWindowView.RefreshingPorts = false; } - public void GetLibrary(string name) + + /// + /// Install required libraries that do not have to be obtained via GIT + /// + /// Name of library to install + public async void GetLibrary(string name) { mainWindowView.Busy = true; - ProcessStartInfo start = new ProcessStartInfo(); - start.FileName = $@"arduino-cli"; - start.Arguments = $"lib install \"{name}\""; - start.UseShellExecute = false; - start.WindowStyle = ProcessWindowStyle.Hidden; - start.RedirectStandardOutput = true; - start.CreateNoWindow = true; - Process process = new Process(); - process.OutputDataReceived += Process_OutputDataReceived; - process.StartInfo = start; - process.Start(); - mainWindowView.Status += process.StandardOutput.ReadToEnd(); - process.WaitForExit(); + AsyncServerStreamingCall libInstall = client.LibraryInstall(new LibraryInstallReq { Instance = instance, Name = name }); + while (await libInstall.ResponseStream.MoveNext()) + { + LibraryInstallResp resp = libInstall.ResponseStream.Current; + if (resp.Progress != null) + { + if (!String.IsNullOrEmpty(resp.Progress.File)) + { + currentFile = resp.Progress.File; + totalSize = resp.Progress.TotalSize; + } + if (!resp.Progress.Completed) + { + mainWindowView.Status += $"Downloading {currentFile}: {resp.Progress.Downloaded}/{totalSize}"; + } + else + { + mainWindowView.Status += $"{currentFile} download complete"; + } + } + } mainWindowView.Busy = false; } diff --git a/BaseStationInstaller/ViewModels/IMainWindowViewModel.cs b/BaseStationInstaller/ViewModels/IMainWindowViewModel.cs index 52e1301..6269ead 100644 --- a/BaseStationInstaller/ViewModels/IMainWindowViewModel.cs +++ b/BaseStationInstaller/ViewModels/IMainWindowViewModel.cs @@ -1,6 +1,7 @@ using BaseStationInstaller.Models; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Text; namespace BaseStationInstaller.ViewModels @@ -8,11 +9,16 @@ namespace BaseStationInstaller.ViewModels public interface IMainWindowViewModel { public string Status { get; set; } - public string SelectedComPort { get; } + public string SelectedComPort { get; set; } public int Progress { get; set; } - public Board SelectedBoard { get; } + public Board SelectedBoard { get; set; } + + public ObservableCollection AvailableComPorts { get; set; } + + public Config SelectedConfig { get; } public bool Busy { get; set; } + public bool RefreshingPorts { get; set; } } } diff --git a/BaseStationInstaller/ViewModels/MainWindowViewModel.cs b/BaseStationInstaller/ViewModels/MainWindowViewModel.cs index 6c401cd..9fcbaf8 100644 --- a/BaseStationInstaller/ViewModels/MainWindowViewModel.cs +++ b/BaseStationInstaller/ViewModels/MainWindowViewModel.cs @@ -6,18 +6,17 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; -using System.IO.Ports; + using System.Linq; using System.Net; using System.Reactive; using System.Reactive.Linq; using System.Runtime.InteropServices; -using System.Runtime.InteropServices.ComTypes; -using System.Text; using System.Threading; using System.Threading.Tasks; using System.Diagnostics; + namespace BaseStationInstaller.ViewModels { public class MainWindowViewModel : ViewModelBase, IMainWindowViewModel @@ -27,10 +26,6 @@ public class MainWindowViewModel : ViewModelBase, IMainWindowViewModel Signature sig = new Signature(new Identity("random", "random@random.com"), DateTimeOffset.Now); public MainWindowViewModel() { - //WiringDiagram = "pack://application:,,,/Resources/dcc-ex-logo.png"; - Task task = new Task(RefreshComports); - task.Start(); - if (File.Exists("status.log")) { if (File.Exists("status.old.log")) @@ -38,24 +33,30 @@ public MainWindowViewModel() File.Delete("status.old.log"); } File.Move("status.log", "status.old.log"); - //File.Create("status.log"); - }/* else - { - File.Create("status.log"); - }*/ + + } logWriter = new StreamWriter("status.log"); - task = new Task(InitArduinoCLI); + Task task = new Task(InitArduinoCLI); task.Start(); - RefreshComPortButton = ReactiveCommand.Create(RefreshComPortsCommand); + RefreshComPortButton = ReactiveCommand.Create(RefreshComPortsCommand, this.WhenAnyValue(x => x.RefreshingPorts, (refrshing) => { + return !refrshing; + }).ObserveOn(RxApp.MainThreadScheduler)); CompileUpload = ReactiveCommand.Create(CompileandUploadCommand, this.WhenAnyValue(x => x.Busy, (busy) => { return !busy; }).ObserveOn(RxApp.MainThreadScheduler)); SelectedConfig = BaseStationSettings.BaseStationDefaults[0]; this.WhenAnyValue(x => x.SelectedConfig).Subscribe(ProcessConfigChange); + this.WhenAnyValue(x => x.Status).Subscribe(ProcessStatusChange); SelectedConfig = BaseStationSettings.BaseStationDefaults[0]; } + private void ProcessStatusChange(string status) + { + StatusCaret = status.Length; + logWriter.Flush(); + logWriter.Write(status); + } private void ProcessConfigChange(Config cfg) @@ -63,6 +64,8 @@ private void ProcessConfigChange(Config cfg) SelectedSupportedBoards = new ObservableCollection(SelectedConfig.SupportedBoards); SelectedSupportedMotorShields = new ObservableCollection(SelectedConfig.SupportedMotorShields); GitCode(SelectedConfig.Git, $@"{SelectedConfig.Name}"); + Task detect = new Task(helper.DetectBoard); + detect.Start(); } void InitArduinoCLI() @@ -124,8 +127,10 @@ void InitArduinoCLI() start.WindowStyle = ProcessWindowStyle.Hidden; start.CreateNoWindow = true; start.RedirectStandardOutput = true; - Process process = new Process(); - process.StartInfo = start; + Process process = new Process + { + StartInfo = start + }; process.Start(); } } @@ -139,7 +144,30 @@ void InitArduinoCLI() public void Closing(object sender, System.ComponentModel.CancelEventArgs e) { + logWriter.Flush(); logWriter.Close(); + logWriter.Dispose(); + try + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + foreach (Process proc in Process.GetProcessesByName("arduino-cli")) + { + proc.Kill(); + } + } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + foreach (Process proc in Process.GetProcessesByName("arduino-cli.exe")) + { + proc.Kill(); + } + } + } + catch (Exception ex) + { + + } } #region Bindings @@ -285,6 +313,14 @@ public string Status set => this.RaiseAndSetIfChanged(ref _status, value + Environment.NewLine); } + + private int _statusCaret; + public int StatusCaret + { + get => _statusCaret; + + set => this.RaiseAndSetIfChanged(ref _statusCaret, value); + } //private string _wiringDiagram; //public string WiringDiagram //{ @@ -338,7 +374,7 @@ public ReactiveCommand RefreshComPortButton void RefreshComPortsCommand() { - Task task = new Task(RefreshComports); + Task task = new Task(helper.DetectBoard); task.Start(); } @@ -365,33 +401,6 @@ public ReactiveCommand CompileUpload /// /// Refresh list of avaliable comports /// - private async void RefreshComports() - { - Busy = true; - RefreshingPorts = true; - Progress = 0; - Status += "Refreshing Ports..." + Environment.NewLine; - for (int i = 0; i < 5; i++) - { - Progress += 20; - Thread.Sleep(500); - //CommandManager.InvalidateRequerySuggested(); - } - AvailableComPorts = new ObservableCollection(SerialPort.GetPortNames()); - if (AvailableComPorts.Count >= 1) - { - SelectedComPort = AvailableComPorts[0]; - } - Progress = 100; - Busy = false; - RefreshingPorts = false; - Thread.Sleep(500); - Progress = 0; - Status += "Idle" + Environment.NewLine; - Thread.Sleep(10000); - //CommandManager.InvalidateRequerySuggested(); - } - private async void ProcessCompileUpload() { Progress = 0; @@ -404,7 +413,7 @@ private async void ProcessCompileUpload() int currDep = 0; private async Task DownloadPreReqs() { - Status += "Starting Dependency Downloads" + Environment.NewLine; + Status += "Starting Dependency Downloads"; Thread.Sleep(500); foreach (Library dep in SelectedConfig.Libraries) { @@ -417,67 +426,69 @@ private async Task DownloadPreReqs() await GitCode(dep.Repo, dep.Location); } } - Status += $"Gitting {SelectedConfig.DisplayName}" + Environment.NewLine; - await GitCode(SelectedConfig.Git, $@"{SelectedConfig.Name}"); } - private void CompileSketch() + private async void CompileSketch() { Busy = true; - Status += "Changing MotorShield options" + Environment.NewLine; - Progress = 5; + RefreshingPorts = true; + Status += "Changing MotorShield options"; + Progress = 1; string[] config = File.ReadAllLines($@"{SelectedConfig.Name}/{SelectedConfig.ConfigFile}"); - Progress = 10; + Progress = 2; switch (SelectedConfig.Name) { case "BaseStationClassic": config[16] = $"#define MOTOR_SHIELD_TYPE {(int)SelectedMotorShield.ShieldType}"; - break; case "BaseStationEx": config[17] = $"#define MOTOR_SHIELD_TYPE {(int)SelectedMotorShield.ShieldType}"; break; - case "CommandStation": + case "CommandStation-DCC": switch (SelectedMotorShield.ShieldType) { case MotorShieldType.Arduino: - + config[25] = "#define CONFIG_ARDUINO_MOTOR_SHIELD"; break; case MotorShieldType.Pololu: - config[14] = $"// DCC* mainTrack = DCC::Create_Arduino_L298Shield_Main(50);"; - config[15] = $"// DCC* progTrack = DCC::Create_Arduino_L298Shield_Prog(2);"; - config[17] = $"DCC* mainTrack = DCC::Create_Pololu_MC33926Shield_Main(50);"; - config[18] = $"DCC* progTrack = DCC::Create_Pololu_MC33926Shield_Prog(2);"; + config[25] = "#define CONFIG_POLOLU_MOTOR_SHIELD"; + break; + case MotorShieldType.FireBox_MK1: + config[25] = "#define CONFIG_WSM_FIREBOX_MK1"; + break; + case MotorShieldType.FireBox_MK1S: + config[25] = "#define CONFIG_WSM_FIREBOX_MK1S"; break; } break; - } - Progress = 15; File.WriteAllLines($@"{SelectedConfig.Name}/{SelectedConfig.ConfigFile}", config); - Progress = 20; Thread.Sleep(1000); - Status += $"Compiling {SelectedConfig.DisplayName} Sketch" + Environment.NewLine; - helper.ArduinoComplieSketch(SelectedBoard.FQBN, $@"{SelectedConfig.Name}/{SelectedConfig.InputFileLocation}", SelectedComPort); + Progress = 3; + Status += $"Compiling {SelectedConfig.DisplayName} Sketch"; + var dir = new DirectoryInfo($@"./{SelectedConfig.Name}"); + dir.CreateSubdirectory("./build"); + foreach (var file in dir.EnumerateDirectories("_git2*")) + { + file.Delete(); + } + helper.ArduinoComplieSketch(SelectedBoard.FQBN, $@"./{SelectedConfig.Name}/{SelectedConfig.InputFileLocation}"); RefreshingPorts = true; - Thread.Sleep(1000); - //Status += $"Uploading to {SelectedComPort}" + Environment.NewLine; - Progress = 75; - //helper.UploadSketch(SelectedBoard.FQBN, SelectedComPort, Path.GetFileName(SelectedConfig.InputFileLocation)); - Progress = 100; - Thread.Sleep(1000); - Progress = 0; - Busy = false; - RefreshingPorts = false; + Thread.Sleep(5000); + Status += $"Uploading to {SelectedComPort}"; + + helper.UploadSketch(SelectedBoard.FQBN, SelectedComPort, $@"{SelectedConfig.Name}/{SelectedConfig.InputFileLocation}"); + } private async Task GitCode(string url, string location) { Busy = true; + Status += $"Obtaining {url} via git"; CloneOptions options = new CloneOptions(); options.RepositoryOperationCompleted = new LibGit2Sharp.Handlers.RepositoryOperationCompleted(GotCode); Progress = 0; @@ -512,16 +523,16 @@ private async Task GitCode(string url, string location) switch (stashApply) { case StashApplyStatus.Applied: - Status += $"Successfully applied Stashed changes in {location}{Environment.NewLine}"; + Status += $"Successfully applied Stashed changes in {location}"; break; case StashApplyStatus.Conflicts: - Status += $"Reverted to Default Checkout on {location} since changes conflict with upstream{Environment.NewLine}"; + Status += $"Reverted to Default Checkout on {location} since changes conflict with upstream"; break; case StashApplyStatus.NotFound: - Status += $"Stash not found for {location}{Environment.NewLine}"; + Status += $"Stash not found for {location}"; break; case StashApplyStatus.UncommittedChanges: - Status += $"There are uncommited changes in {location}{Environment.NewLine}"; + Status += $"There are uncommited changes in {location}"; break; } } diff --git a/BaseStationInstaller/Views/MainWindow.xaml b/BaseStationInstaller/Views/MainWindow.xaml index e0f41ab..96c36ee 100644 --- a/BaseStationInstaller/Views/MainWindow.xaml +++ b/BaseStationInstaller/Views/MainWindow.xaml @@ -1,4 +1,13 @@ - + @@ -6,12 +15,12 @@ - + - + - + Select Base Station Type @@ -43,10 +52,10 @@ Select COM Port - - + + - + diff --git a/BaseStationInstaller/arduino-cli.yaml b/BaseStationInstaller/arduino-cli.yaml index 9e957cb..2f6229d 100644 --- a/BaseStationInstaller/arduino-cli.yaml +++ b/BaseStationInstaller/arduino-cli.yaml @@ -3,7 +3,7 @@ board_manager: https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json ] daemon: - port: "50051" + port: "27160" directories: data: . downloads: . diff --git a/BaseStationInstaller/board.proto b/BaseStationInstaller/board.proto new file mode 100644 index 0000000..1d3f5e1 --- /dev/null +++ b/BaseStationInstaller/board.proto @@ -0,0 +1,210 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands; + +option go_package = "github.com/arduino/arduino-cli/rpc/commands"; + +import "commands/common.proto"; + +message BoardDetailsReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // The fully qualified board name of the board you want information about + // (e.g., `arduino:avr:uno`). + string fqbn = 2; +} + +message BoardDetailsResp { + // The fully qualified board name of the board. + string fqbn = 1; + // Name used to identify the board to humans (e.g., Arduino/Genuino Uno). + string name = 2; + // Installed version of the board's platform. + string version = 3; + // The board ID component of the FQBN (e.g., `uno`). + string propertiesId = 4; + // Board alias that can be used as a more user friendly alternative to the + // FQBN. + string alias = 5; + // Whether this is an official or 3rd party board. + bool official = 6; + // URL of the board's pinout documentation. + string pinout = 7; + // Data about the package that contains the board's platform. + Package package = 8; + // Data about the board's platform. + BoardPlatform platform = 9; + // Tool dependencies of the board. + repeated ToolsDependencies toolsDependencies = 10; + // The board's custom configuration options. + repeated ConfigOption config_options = 11; + // Identifying information for the board (e.g., USB VID/PID). + repeated IdentificationPref identification_pref = 12; +} + +message IdentificationPref { + // Identifying information for USB-connected boards. + USBID usbID = 1; +} + +message USBID { + // USB vendor ID. + string VID = 1; + // USB product ID. + string PID = 2; +} + +message Package { + // Maintainer of the package. + string maintainer = 1; + // The URL of the platforms index file + // (e.g., https://downloads.arduino.cc/packages/package_index.json). + string url = 2; + // A URL provided by the package author, intended to point to their website. + string websiteURL = 3; + // Email address of the package maintainer. + string email = 4; + // Package vendor name. + string name = 5; + // Resources for getting help about using the package. + Help help = 6; +} + +message Help { + // URL for getting online help. + string online = 1; +} + +message BoardPlatform { + // Architecture of the platform (e.g., `avr`). + string architecture = 1; + // Category of the platform. Set to `Contributed` for 3rd party platforms. + string category = 2; + // Download URL of the platform archive file. + string url = 3; + // File name of the platform archive. + string archiveFileName = 4; + // Checksum of the platform archive. + string checksum = 5; + // File size of the platform archive. + int64 size = 6; + // Name used to identify the platform to humans. + string name = 7; +} + + +message ToolsDependencies { + // Vendor name of the package containing the tool definition. + string packager = 1; + // Tool name. + string name = 2; + // Tool version. + string version = 3; + // Data for the operating system-specific builds of the tool. + repeated Systems systems = 4; +} + +message Systems { + // Checksum of the tool archive. + string checksum = 1; + // Operating system identifier. + string host = 2; + // File name of the tool archive. + string archiveFileName = 3; + // Download URL of the tool archive. + string url = 4; + // File size of the tool archive. + int64 size = 5; +} + + +message ConfigOption { + // ID of the configuration option. For identifying the option to machines. + string option = 1; + // Name of the configuration option for identifying the option to humans. + string option_label = 2; + // Possible values of the configuration option. + repeated ConfigValue values = 3; +} + +message ConfigValue { + // The configuration option value. + string value = 1; + // Label to identify the configuration option to humans. + string value_label = 2; + // Whether the configuration option is selected. + bool selected = 3; +} + +message BoardAttachReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // The board's URI (e.g., /dev/ttyACM0). + string board_uri = 2; + // Path of the sketch to attach the board to. The board attachment + // metadata will be saved to `{sketch_path}/sketch.json`. + string sketch_path = 3; + // Duration in seconds to search the given URI for a connected board before + // timing out. The default value is 5 seconds. + string search_timeout = 4; +} + +message BoardAttachResp { + // Description of the current stage of the board attachment. + TaskProgress task_progress = 1; +} + +message BoardListReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; +} + +message BoardListResp { + // List of ports and the boards detected on those ports. + repeated DetectedPort ports = 1; +} + +message DetectedPort { + // Address of the port (e.g., `serial:///dev/ttyACM0`). + string address = 1; + // Protocol of the port (e.g., `serial`). + string protocol = 2; + // A human friendly description of the protocol (e.g., "Serial Port (USB)"). + string protocol_label = 3; + // The boards attached to the port. + repeated BoardListItem boards = 4; +} + +message BoardListAllReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // The search query to filter the board list by. + repeated string search_args = 2; +} + +message BoardListAllResp { + // List of installed boards. + repeated BoardListItem boards = 1; +} + +message BoardListItem { + // The name for use when identifying the board to a human. + string name = 1; + // The fully qualified board name. Used to identify the board to a machine. + string FQBN = 2; +} diff --git a/BaseStationInstaller/commands.proto b/BaseStationInstaller/commands.proto new file mode 100644 index 0000000..661b4fc --- /dev/null +++ b/BaseStationInstaller/commands.proto @@ -0,0 +1,189 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands; + +option go_package = "github.com/arduino/arduino-cli/rpc/commands"; + +import "commands/common.proto"; +import "commands/board.proto"; +import "commands/compile.proto"; +import "commands/core.proto"; +import "commands/upload.proto"; +import "commands/lib.proto"; + +// The main Arduino Platform Service +service ArduinoCore { + // BOOTSTRAP COMMANDS + //------------------- + + // Start a new instance of the Arduino Core Service + rpc Init(InitReq) returns (stream InitResp) {} + + // Destroy an instance of the Arduino Core Service + rpc Destroy(DestroyReq) returns (DestroyResp) {} + + // Rescan instance of the Arduino Core Service + rpc Rescan(RescanReq) returns (RescanResp) {} + + // Update package index of the Arduino Core Service + rpc UpdateIndex(UpdateIndexReq) returns (stream UpdateIndexResp) {} + + // Update libraries index + rpc UpdateLibrariesIndex(UpdateLibrariesIndexReq) returns (stream UpdateLibrariesIndexResp) {} + + // Get the version of Arduino CLI in use. + rpc Version(VersionReq) returns (VersionResp) {} + + // BOARD COMMANDS + // -------------- + + // Requests details about a board + rpc BoardDetails(BoardDetailsReq) returns (BoardDetailsResp); + + // Attach a board to a sketch. When the `fqbn` field of a request is not + // provided, the FQBN of the attached board will be used. + rpc BoardAttach(BoardAttachReq) returns (stream BoardAttachResp); + + // List the boards currently connected to the computer. + rpc BoardList(BoardListReq) returns (BoardListResp); + + // List all the boards provided by installed platforms. + rpc BoardListAll(BoardListAllReq) returns (BoardListAllResp); + + // Compile an Arduino sketch. + rpc Compile(CompileReq) returns (stream CompileResp); + + // Download and install a platform and its tool dependencies. + rpc PlatformInstall(PlatformInstallReq) returns (stream PlatformInstallResp); + + // Download a platform and its tool dependencies to the `staging/packages` + // subdirectory of the data directory. + rpc PlatformDownload(PlatformDownloadReq) returns (stream PlatformDownloadResp); + + // Uninstall a platform as well as its tool dependencies that are not used by + // other installed platforms. + rpc PlatformUninstall(PlatformUninstallReq) returns (stream PlatformUninstallResp); + + // Upgrade an installed platform to the latest version. + rpc PlatformUpgrade(PlatformUpgradeReq) returns (stream PlatformUpgradeResp); + + // Upload a compiled sketch to an Arduino board. + rpc Upload(UploadReq) returns (stream UploadResp); + + rpc ListProgrammersAvailableForUpload(ListProgrammersAvailableForUploadReq) returns (ListProgrammersAvailableForUploadResp); + + // Burn bootloader to a board. + rpc BurnBootloader(BurnBootloaderReq) returns (stream BurnBootloaderResp); + + // Search for a platform in the platforms indexes. + rpc PlatformSearch(PlatformSearchReq) returns (PlatformSearchResp); + + // List all installed platforms. + rpc PlatformList(PlatformListReq) returns (PlatformListResp); + + // Download the archive file of an Arduino library in the libraries index to + // the staging directory. + rpc LibraryDownload(LibraryDownloadReq) returns (stream LibraryDownloadResp); + + // Download and install an Arduino library from the libraries index. + rpc LibraryInstall(LibraryInstallReq) returns (stream LibraryInstallResp); + + // Uninstall an Arduino library. + rpc LibraryUninstall(LibraryUninstallReq) returns (stream LibraryUninstallResp); + + // Upgrade all installed Arduino libraries to the newest version available. + rpc LibraryUpgradeAll(LibraryUpgradeAllReq) returns (stream LibraryUpgradeAllResp); + + // List the recursive dependencies of a library, as defined by the `depends` + // field of the library.properties files. + rpc LibraryResolveDependencies(LibraryResolveDependenciesReq) returns (LibraryResolveDependenciesResp); + + // Search the Arduino libraries index for libraries. + rpc LibrarySearch(LibrarySearchReq) returns (LibrarySearchResp); + + // List the installed libraries. + rpc LibraryList(LibraryListReq) returns (LibraryListResp); +} + +message InitReq { + // Start a Arduino Core Service instance that will provide only Library + // Manager functionality. + bool library_manager_only = 2; +} + +message InitResp { + // An Arduino Core Service instance. + Instance instance = 1; + // Error messages related to any problems encountered while parsing the + // platforms index files. + repeated string platforms_index_errors = 2; + // Error message if a problem was encountered while parsing the libraries + // index file. + string libraries_index_error = 3; + // Progress of the downloads of platforms and libraries index files. + DownloadProgress download_progress = 4; + // Describes the current stage of the initialization. + TaskProgress task_progress = 5; +} + +message DestroyReq { + // The Arduino Core Service instance to destroy. + Instance instance = 1; +} +message DestroyResp {} + +message RescanReq { + // Arduino Core Service instance from the Init response. + Instance instance = 1; +} + +message RescanResp { + // Error messages related to any problems encountered while parsing the + // platforms index file. + repeated string platforms_index_errors = 1; + // Error message if a problem was encountered while parsing the libraries + // index file. + string libraries_index_error = 2; +} + +message UpdateIndexReq { + // Arduino Core Service instance from the Init response. + Instance instance = 1; +} + +message UpdateIndexResp { + // Progress of the platforms index download. + DownloadProgress download_progress = 1; +} + +message UpdateLibrariesIndexReq { + // Arduino Core Service instance from the Init response. + Instance instance = 1; +} + +message UpdateLibrariesIndexResp { + // Progress of the libraries index download. + DownloadProgress download_progress = 1; +} + +message VersionReq {} + +message VersionResp { + // The version of Arduino CLI in use. + string version = 1; +} diff --git a/BaseStationInstaller/commands/board.proto b/BaseStationInstaller/commands/board.proto new file mode 100644 index 0000000..1d3f5e1 --- /dev/null +++ b/BaseStationInstaller/commands/board.proto @@ -0,0 +1,210 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands; + +option go_package = "github.com/arduino/arduino-cli/rpc/commands"; + +import "commands/common.proto"; + +message BoardDetailsReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // The fully qualified board name of the board you want information about + // (e.g., `arduino:avr:uno`). + string fqbn = 2; +} + +message BoardDetailsResp { + // The fully qualified board name of the board. + string fqbn = 1; + // Name used to identify the board to humans (e.g., Arduino/Genuino Uno). + string name = 2; + // Installed version of the board's platform. + string version = 3; + // The board ID component of the FQBN (e.g., `uno`). + string propertiesId = 4; + // Board alias that can be used as a more user friendly alternative to the + // FQBN. + string alias = 5; + // Whether this is an official or 3rd party board. + bool official = 6; + // URL of the board's pinout documentation. + string pinout = 7; + // Data about the package that contains the board's platform. + Package package = 8; + // Data about the board's platform. + BoardPlatform platform = 9; + // Tool dependencies of the board. + repeated ToolsDependencies toolsDependencies = 10; + // The board's custom configuration options. + repeated ConfigOption config_options = 11; + // Identifying information for the board (e.g., USB VID/PID). + repeated IdentificationPref identification_pref = 12; +} + +message IdentificationPref { + // Identifying information for USB-connected boards. + USBID usbID = 1; +} + +message USBID { + // USB vendor ID. + string VID = 1; + // USB product ID. + string PID = 2; +} + +message Package { + // Maintainer of the package. + string maintainer = 1; + // The URL of the platforms index file + // (e.g., https://downloads.arduino.cc/packages/package_index.json). + string url = 2; + // A URL provided by the package author, intended to point to their website. + string websiteURL = 3; + // Email address of the package maintainer. + string email = 4; + // Package vendor name. + string name = 5; + // Resources for getting help about using the package. + Help help = 6; +} + +message Help { + // URL for getting online help. + string online = 1; +} + +message BoardPlatform { + // Architecture of the platform (e.g., `avr`). + string architecture = 1; + // Category of the platform. Set to `Contributed` for 3rd party platforms. + string category = 2; + // Download URL of the platform archive file. + string url = 3; + // File name of the platform archive. + string archiveFileName = 4; + // Checksum of the platform archive. + string checksum = 5; + // File size of the platform archive. + int64 size = 6; + // Name used to identify the platform to humans. + string name = 7; +} + + +message ToolsDependencies { + // Vendor name of the package containing the tool definition. + string packager = 1; + // Tool name. + string name = 2; + // Tool version. + string version = 3; + // Data for the operating system-specific builds of the tool. + repeated Systems systems = 4; +} + +message Systems { + // Checksum of the tool archive. + string checksum = 1; + // Operating system identifier. + string host = 2; + // File name of the tool archive. + string archiveFileName = 3; + // Download URL of the tool archive. + string url = 4; + // File size of the tool archive. + int64 size = 5; +} + + +message ConfigOption { + // ID of the configuration option. For identifying the option to machines. + string option = 1; + // Name of the configuration option for identifying the option to humans. + string option_label = 2; + // Possible values of the configuration option. + repeated ConfigValue values = 3; +} + +message ConfigValue { + // The configuration option value. + string value = 1; + // Label to identify the configuration option to humans. + string value_label = 2; + // Whether the configuration option is selected. + bool selected = 3; +} + +message BoardAttachReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // The board's URI (e.g., /dev/ttyACM0). + string board_uri = 2; + // Path of the sketch to attach the board to. The board attachment + // metadata will be saved to `{sketch_path}/sketch.json`. + string sketch_path = 3; + // Duration in seconds to search the given URI for a connected board before + // timing out. The default value is 5 seconds. + string search_timeout = 4; +} + +message BoardAttachResp { + // Description of the current stage of the board attachment. + TaskProgress task_progress = 1; +} + +message BoardListReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; +} + +message BoardListResp { + // List of ports and the boards detected on those ports. + repeated DetectedPort ports = 1; +} + +message DetectedPort { + // Address of the port (e.g., `serial:///dev/ttyACM0`). + string address = 1; + // Protocol of the port (e.g., `serial`). + string protocol = 2; + // A human friendly description of the protocol (e.g., "Serial Port (USB)"). + string protocol_label = 3; + // The boards attached to the port. + repeated BoardListItem boards = 4; +} + +message BoardListAllReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // The search query to filter the board list by. + repeated string search_args = 2; +} + +message BoardListAllResp { + // List of installed boards. + repeated BoardListItem boards = 1; +} + +message BoardListItem { + // The name for use when identifying the board to a human. + string name = 1; + // The fully qualified board name. Used to identify the board to a machine. + string FQBN = 2; +} diff --git a/BaseStationInstaller/commands/commands.proto b/BaseStationInstaller/commands/commands.proto new file mode 100644 index 0000000..661b4fc --- /dev/null +++ b/BaseStationInstaller/commands/commands.proto @@ -0,0 +1,189 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands; + +option go_package = "github.com/arduino/arduino-cli/rpc/commands"; + +import "commands/common.proto"; +import "commands/board.proto"; +import "commands/compile.proto"; +import "commands/core.proto"; +import "commands/upload.proto"; +import "commands/lib.proto"; + +// The main Arduino Platform Service +service ArduinoCore { + // BOOTSTRAP COMMANDS + //------------------- + + // Start a new instance of the Arduino Core Service + rpc Init(InitReq) returns (stream InitResp) {} + + // Destroy an instance of the Arduino Core Service + rpc Destroy(DestroyReq) returns (DestroyResp) {} + + // Rescan instance of the Arduino Core Service + rpc Rescan(RescanReq) returns (RescanResp) {} + + // Update package index of the Arduino Core Service + rpc UpdateIndex(UpdateIndexReq) returns (stream UpdateIndexResp) {} + + // Update libraries index + rpc UpdateLibrariesIndex(UpdateLibrariesIndexReq) returns (stream UpdateLibrariesIndexResp) {} + + // Get the version of Arduino CLI in use. + rpc Version(VersionReq) returns (VersionResp) {} + + // BOARD COMMANDS + // -------------- + + // Requests details about a board + rpc BoardDetails(BoardDetailsReq) returns (BoardDetailsResp); + + // Attach a board to a sketch. When the `fqbn` field of a request is not + // provided, the FQBN of the attached board will be used. + rpc BoardAttach(BoardAttachReq) returns (stream BoardAttachResp); + + // List the boards currently connected to the computer. + rpc BoardList(BoardListReq) returns (BoardListResp); + + // List all the boards provided by installed platforms. + rpc BoardListAll(BoardListAllReq) returns (BoardListAllResp); + + // Compile an Arduino sketch. + rpc Compile(CompileReq) returns (stream CompileResp); + + // Download and install a platform and its tool dependencies. + rpc PlatformInstall(PlatformInstallReq) returns (stream PlatformInstallResp); + + // Download a platform and its tool dependencies to the `staging/packages` + // subdirectory of the data directory. + rpc PlatformDownload(PlatformDownloadReq) returns (stream PlatformDownloadResp); + + // Uninstall a platform as well as its tool dependencies that are not used by + // other installed platforms. + rpc PlatformUninstall(PlatformUninstallReq) returns (stream PlatformUninstallResp); + + // Upgrade an installed platform to the latest version. + rpc PlatformUpgrade(PlatformUpgradeReq) returns (stream PlatformUpgradeResp); + + // Upload a compiled sketch to an Arduino board. + rpc Upload(UploadReq) returns (stream UploadResp); + + rpc ListProgrammersAvailableForUpload(ListProgrammersAvailableForUploadReq) returns (ListProgrammersAvailableForUploadResp); + + // Burn bootloader to a board. + rpc BurnBootloader(BurnBootloaderReq) returns (stream BurnBootloaderResp); + + // Search for a platform in the platforms indexes. + rpc PlatformSearch(PlatformSearchReq) returns (PlatformSearchResp); + + // List all installed platforms. + rpc PlatformList(PlatformListReq) returns (PlatformListResp); + + // Download the archive file of an Arduino library in the libraries index to + // the staging directory. + rpc LibraryDownload(LibraryDownloadReq) returns (stream LibraryDownloadResp); + + // Download and install an Arduino library from the libraries index. + rpc LibraryInstall(LibraryInstallReq) returns (stream LibraryInstallResp); + + // Uninstall an Arduino library. + rpc LibraryUninstall(LibraryUninstallReq) returns (stream LibraryUninstallResp); + + // Upgrade all installed Arduino libraries to the newest version available. + rpc LibraryUpgradeAll(LibraryUpgradeAllReq) returns (stream LibraryUpgradeAllResp); + + // List the recursive dependencies of a library, as defined by the `depends` + // field of the library.properties files. + rpc LibraryResolveDependencies(LibraryResolveDependenciesReq) returns (LibraryResolveDependenciesResp); + + // Search the Arduino libraries index for libraries. + rpc LibrarySearch(LibrarySearchReq) returns (LibrarySearchResp); + + // List the installed libraries. + rpc LibraryList(LibraryListReq) returns (LibraryListResp); +} + +message InitReq { + // Start a Arduino Core Service instance that will provide only Library + // Manager functionality. + bool library_manager_only = 2; +} + +message InitResp { + // An Arduino Core Service instance. + Instance instance = 1; + // Error messages related to any problems encountered while parsing the + // platforms index files. + repeated string platforms_index_errors = 2; + // Error message if a problem was encountered while parsing the libraries + // index file. + string libraries_index_error = 3; + // Progress of the downloads of platforms and libraries index files. + DownloadProgress download_progress = 4; + // Describes the current stage of the initialization. + TaskProgress task_progress = 5; +} + +message DestroyReq { + // The Arduino Core Service instance to destroy. + Instance instance = 1; +} +message DestroyResp {} + +message RescanReq { + // Arduino Core Service instance from the Init response. + Instance instance = 1; +} + +message RescanResp { + // Error messages related to any problems encountered while parsing the + // platforms index file. + repeated string platforms_index_errors = 1; + // Error message if a problem was encountered while parsing the libraries + // index file. + string libraries_index_error = 2; +} + +message UpdateIndexReq { + // Arduino Core Service instance from the Init response. + Instance instance = 1; +} + +message UpdateIndexResp { + // Progress of the platforms index download. + DownloadProgress download_progress = 1; +} + +message UpdateLibrariesIndexReq { + // Arduino Core Service instance from the Init response. + Instance instance = 1; +} + +message UpdateLibrariesIndexResp { + // Progress of the libraries index download. + DownloadProgress download_progress = 1; +} + +message VersionReq {} + +message VersionResp { + // The version of Arduino CLI in use. + string version = 1; +} diff --git a/BaseStationInstaller/commands/common.proto b/BaseStationInstaller/commands/common.proto new file mode 100644 index 0000000..0c27645 --- /dev/null +++ b/BaseStationInstaller/commands/common.proto @@ -0,0 +1,47 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands; + +option go_package = "github.com/arduino/arduino-cli/rpc/commands"; + +message Instance { + // The ID of the instance. + int32 id = 1; +} + +message DownloadProgress { + // URL of the download. + string url = 1; + // The file being downloaded. + string file = 2; + // Total size of the file being downloaded. + int64 total_size = 3; + // Size of the downloaded portion of the file. + int64 downloaded = 4; + // Whether the download is complete. + bool completed = 5; +} + +message TaskProgress { + // Description of the task. + string name = 1; + // Additional information about the task. + string message = 2; + // Whether the task is complete. + bool completed = 3; +} diff --git a/BaseStationInstaller/commands/compile.proto b/BaseStationInstaller/commands/compile.proto new file mode 100644 index 0000000..51f8337 --- /dev/null +++ b/BaseStationInstaller/commands/compile.proto @@ -0,0 +1,49 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands; + +option go_package = "github.com/arduino/arduino-cli/rpc/commands"; + +import "commands/common.proto"; + +message CompileReq { + Instance instance = 1; // Arduino Core Service instance from the `Init` response. + string fqbn = 2; // Fully Qualified Board Name, e.g.: `arduino:avr:uno`. If this field is not defined, the FQBN of the board attached to the sketch via the `BoardAttach` method is used. + string sketchPath = 3; // The path where the sketch is stored. + bool showProperties = 4; // Show all build preferences used instead of compiling. + bool preprocess = 5; // Print preprocessed code to stdout instead of compiling. + string buildCachePath = 6; // Builds of 'core.a' are saved into this path to be cached and reused. + string buildPath = 7; // Path to use to store the files used for the compilation. If omitted, a directory will be created in the operating system's default temporary path. + repeated string buildProperties = 8; // List of custom build properties separated by commas. + string warnings = 9; // Used to tell gcc which warning level to use. The level names are: "none", "default", "more" and "all". + bool verbose = 10; // Turns on verbose mode. + bool quiet = 11; // Suppresses almost every output. + string vidPid = 12; // VID/PID specific build properties. + string exportFile = 13 [deprecated = true]; // DEPRECATED: use exportDir instead + int32 jobs = 14; // The max number of concurrent compiler instances to run (as `make -jx`). If jobs is set to 0, it will use the number of available CPUs as the maximum. + repeated string libraries = 15; // List of custom libraries paths separated by commas. + bool optimizeForDebug = 16; // Optimize compile output for debug, not for release. + bool dryRun = 17; // When set to `true` the compiled binary will not be copied to the export directory. + string export_dir = 18; // Optional: save the build artifacts in this directory, the directory must exist. + string programmer = 19; // External programmer for upload +} + +message CompileResp { + bytes out_stream = 1; // The output of the compilation process. + bytes err_stream = 2; // The error output of the compilation process. +} diff --git a/BaseStationInstaller/commands/core.proto b/BaseStationInstaller/commands/core.proto new file mode 100644 index 0000000..b928823 --- /dev/null +++ b/BaseStationInstaller/commands/core.proto @@ -0,0 +1,144 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands; + +option go_package = "github.com/arduino/arduino-cli/rpc/commands"; + +import "commands/common.proto"; + +message PlatformInstallReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Vendor name of the platform (e.g., `arduino`). + string platform_package = 2; + // Architecture name of the platform (e.g., `avr`). + string architecture = 3; + // Platform version to install. + string version = 4; +} + +message PlatformInstallResp { + // Progress of the downloads of the platform and tool files. + DownloadProgress progress = 1; + // Description of the current stage of the installation. + TaskProgress task_progress = 2; +} + +message PlatformDownloadReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + string platform_package = 2; + // Architecture name of the platform (e.g., `avr`). + string architecture = 3; + // Platform version to download. + string version = 4; +} + +message PlatformDownloadResp { + // Progress of the downloads of platform and tool files. + DownloadProgress progress = 1; +} + +message PlatformUninstallReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Vendor name of the platform (e.g., `arduino`). + string platform_package = 2; + // Architecture name of the platform (e.g., `avr`). + string architecture = 3; +} + +message PlatformUninstallResp { + // Description of the current stage of the uninstall. + TaskProgress task_progress = 1; +} + +message PlatformUpgradeReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Vendor name of the platform (e.g., `arduino`). + string platform_package = 2; + // Architecture name of the platform (e.g., `avr`). + string architecture = 3; +} + +message PlatformUpgradeResp { + // Progress of the downloads of the platform and tool files. + DownloadProgress progress = 1; + // Description of the current stage of the upgrade. + TaskProgress task_progress = 2; +} + +message PlatformSearchReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Keywords for the search. + string search_args = 2; + // Whether to show all available versions. `false` causes only the newest + // versions of the cores to be listed in the search results. + bool all_versions = 3; +} + +message PlatformSearchResp { + // Results of the search. + repeated Platform search_output = 1; +} + +message PlatformListReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Set to true to only list platforms which have a newer version available + // than the one currently installed. + bool updatable_only = 2; +} + +message PlatformListResp { + // The installed platforms. + repeated Platform installed_platform = 1; +} + +message Platform { + // Platform ID (e.g., `arduino:avr`). + string ID = 1; + // Version of the platform. + string Installed = 2; + // Newest available version of the platform. + string Latest = 3; + // Name used to identify the platform to humans (e.g., "Arduino AVR Boards"). + string Name = 4; + // Maintainer of the platform's package. + string Maintainer = 5; + // A URL provided by the author of the platform's package, intended to point + // to their website. + string Website = 6; + // Email of the maintainer of the platform's package. + string Email = 7; + // List of boards provided by the platform. If the platform is installed, + // this is the boards listed in the platform's boards.txt. If the platform is + // not installed, this is an arbitrary list of board names provided by the + // platform author for display and may not match boards.txt. + repeated Board Boards = 8; +} + +message Board { + // Name used to identify the board to humans. + string name = 1; + // Fully qualified board name used to identify the board to machines. The FQBN + // is only available for installed boards. + string fqbn = 2; +} \ No newline at end of file diff --git a/BaseStationInstaller/commands/lib.proto b/BaseStationInstaller/commands/lib.proto new file mode 100644 index 0000000..8601a73 --- /dev/null +++ b/BaseStationInstaller/commands/lib.proto @@ -0,0 +1,284 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands; + +option go_package = "github.com/arduino/arduino-cli/rpc/commands"; + +import "commands/common.proto"; + +message LibraryDownloadReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Name of the library. + string name = 2; + // The version of the library to download. + string version = 3; +} + +message LibraryDownloadResp { + // Progress of the library download. + DownloadProgress progress = 1; +} + +message LibraryInstallReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Name of the library. + string name = 2; + // The version of the library to install. + string version = 3; +} + +message LibraryInstallResp { + // Progress of the library download. + DownloadProgress progress = 1; + // Description of the current stage of the installation. + TaskProgress task_progress = 2; +} + +message LibraryUninstallReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Name of the library. + string name = 2; + // The version of the library to uninstall. + string version = 3; +} + +message LibraryUninstallResp { + // Description of the current stage of the uninstallation. + TaskProgress task_progress = 1; +} + +message LibraryUpgradeAllReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; +} + +message LibraryUpgradeAllResp { + // Progress of the downloads of files needed for the upgrades. + DownloadProgress progress = 1; + // Description of the current stage of the upgrade. + TaskProgress task_progress = 2; +} + +message LibraryResolveDependenciesReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Name of the library. + string name = 2; + // The version of the library to check dependencies of. If no version is + // specified, dependencies of the newest version will be listed. + string version = 3; +} + +message LibraryResolveDependenciesResp { + // Dependencies of the library. + repeated LibraryDependencyStatus dependencies = 1; +} + +message LibraryDependencyStatus { + // The name of the library dependency. + string name = 1; + // The required version of the library dependency. + string versionRequired = 2; + // Version of the library dependency currently installed. + string versionInstalled = 3; +} + +message LibrarySearchReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // The search query. + string query = 2; +} + +enum LibrarySearchStatus { + // No search results were found. + failed = 0; + // Search results were found. + success = 1; +} + +message LibrarySearchResp { + // The results of the search. + repeated SearchedLibrary libraries = 1; + // Whether the search yielded results. + LibrarySearchStatus status = 2; +} + +message SearchedLibrary { + // Library name. + string name = 1; + // The index data for the available versions of the library. The key of the + // map is the library version. + map releases = 2; + // The index data for the latest version of the library. + LibraryRelease latest = 3; +} + +message LibraryRelease { + // Value of the `author` field in library.properties. + string author = 1; + // Value of the `version` field in library.properties. + string version = 2; + // Value of the `maintainer` field in library.properties. + string maintainer = 3; + // Value of the `sentence` field in library.properties. + string sentence = 4; + // Value of the `paragraph` field in library.properties. + string paragraph = 5; + // Value of the `url` field in library.properties. + string website = 6; + // Value of the `category` field in library.properties. + string category = 7; + // Value of the `architectures` field in library.properties. + repeated string architectures = 8; + // The type categories of the library, as defined in the libraries index. + // Possible values: `Arduino`, `Partner`, `Recommended`, `Contributed`, + // `Retired`. + repeated string types = 9; + // Information about the library archive file. + DownloadResource resources = 10; + // Value of the `license` field in library.properties. + string license = 11; + // Value of the `includes` field in library.properties. + repeated string provides_includes = 12; + // The names of the library's dependencies, as defined by the 'depends' + // field of library.properties. + repeated LibraryDependency dependencies = 13; +} + +message LibraryDependency { + // Library name of the dependency. + string name = 1; + // Version constraint of the dependency. + string version_constraint = 2; +} + +message DownloadResource { + // Download URL of the library archive. + string url = 1; + // Filename of the library archive. + string archivefilename = 2; + // Checksum of the library archive. + string checksum = 3; + // File size of the library archive. + int64 size = 4; + // The directory under the staging subdirectory of the data directory the + // library archive file will be downloaded to. + string cachepath = 5; +} + +message LibraryListReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Whether to include built-in libraries (from platforms and the Arduino + // IDE) in the listing. + bool all = 2; + // Whether to list only libraries for which there is a newer version than + // the installed version available in the libraries index. + bool updatable = 3; +} + +message LibraryListResp { + // List of installed libraries. + repeated InstalledLibrary installed_library = 1; +} + +message InstalledLibrary { + // Information about the library. + Library library = 1; + // When the `updatable` field of the `LibraryList` request is set to `true`, + // this will contain information on the latest version of the library in the + // libraries index. + LibraryRelease release = 2; +} + +message Library { + // The library's directory name. + string name = 1; + // Value of the `author` field in library.properties. + string author = 2; + // Value of the `maintainer` field in library.properties. + string maintainer = 3; + // Value of the `sentence` field in library.properties. + string sentence = 4; + // Value of the `paragraph` field in library.properties. + string paragraph = 5; + // Value of the `url` field in library.properties. + string website = 6; + // Value of the `category` field in library.properties. + string category = 7; + // Value of the `architectures` field in library.properties. + repeated string architectures = 8; + // The type categories of the library. Possible values: `Arduino`, + // `Partner`, `Recommended`, `Contributed`, `Retired`. + repeated string types = 9; + // The path of the library directory. + string install_dir = 10; + // The location of the library's source files. + string source_dir = 11; + // The location of the library's `utility` directory. + string utility_dir = 12; + // If `location` is `platform_builtin` or `referenced_platform_builtin`, the + // identifying string for the platform containing the library + // (e.g., `arduino:avr@1.8.2`). + string container_platform = 14; + // Value of the `name` field in library.properties. + string real_name = 16; + // Value of the `dot_a_linkage` field in library.properties. + bool dot_a_linkage = 17; + // Value of the `precompiled` field in library.properties. + bool precompiled = 18; + // Value of the `ldflags` field in library.properties. + string ld_flags = 19; + // A library.properties file is not present in the library's root directory. + bool is_legacy = 20; + // Value of the `version` field in library.properties. + string version = 21; + // Value of the `license` field in library.properties. + string license = 22; + // The data from the library's library.properties file, including unused + // fields. + map properties = 23; + // The location type of the library installation. + LibraryLocation location = 24; + // The library format type. + LibraryLayout layout = 25; +} + +enum LibraryLayout { + // Library is in the 1.0 Arduino library format. + flat_layout = 0; + // Library is in the 1.5 Arduino library format. + recursive_layout = 1; +} + +enum LibraryLocation { + // In the `libraries` subdirectory of the Arduino IDE installation. + ide_builtin = 0; + // In the `libraries` subdirectory of the user directory (sketchbook). + user = 1; + // In the `libraries` subdirectory of a platform. + platform_builtin = 2; + // When `LibraryLocation` is used in a context where a board is specified, + // this indicates the library is in the `libraries` subdirectory of a + // platform referenced by the board's platform. + referenced_platform_builtin = 3; +} diff --git a/BaseStationInstaller/commands/upload.proto b/BaseStationInstaller/commands/upload.proto new file mode 100644 index 0000000..2c02c36 --- /dev/null +++ b/BaseStationInstaller/commands/upload.proto @@ -0,0 +1,92 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands; + +option go_package = "github.com/arduino/arduino-cli/rpc/commands"; + +import "commands/common.proto"; + +message UploadReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Fully qualified board name of the target board (e.g., `arduino:avr:uno`). + // If this field is not defined, the FQBN of the board attached to the sketch + // via the `BoardAttach` method is used. + string fqbn = 2; + // Path where the sketch to be uploaded is stored. Unless the `import_file` + // field is defined, the compiled binary is assumed to be at the location and + // filename under this path where it is saved by the `Compile` method. + string sketch_path = 3; + // The port of the board. + string port = 4; + // Whether to turn on verbose output during the upload. + bool verbose = 5; + // After upload, verify that the contents of the memory on the board match the + // uploaded binary. + bool verify = 6; + string import_file = 7 [deprecated = true]; // DEPRECATED: Use import_dir instead + // Custom path to a directory containing compiled files. When `import_dir` is + // not specified, the standard build directory under `sketch_path` is used. + string import_dir = 8; + string programmer = 9; +} + +message UploadResp { + // The output of the upload process. + bytes out_stream = 1; + // The error output of the upload process. + bytes err_stream = 2; +} + +message BurnBootloaderReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Fully qualified board name of the target board (e.g., `arduino:avr:uno`). + string fqbn = 2; + // The port of the programmer used to program the bootloader. + string port = 3; + // Whether to turn on verbose output during the programming. + bool verbose = 4; + // After programming, verify the contents of the memory on the board match the + // uploaded binary. + bool verify = 5; + // The programmer to use for burning bootloader. + string programmer = 6; +} + +message BurnBootloaderResp { + // The output of the burn bootloader process. + bytes out_stream = 1; + // The error output of the burn bootloader process. + bytes err_stream = 2; +} + +message ListProgrammersAvailableForUploadReq { + Instance instance = 1; + string fqbn = 2; +} + +message ListProgrammersAvailableForUploadResp { + repeated Programmer programmers = 1; +} + +message Programmer { + string platform = 1; + string id = 2; + string name = 3; +} diff --git a/BaseStationInstaller/common.proto b/BaseStationInstaller/common.proto new file mode 100644 index 0000000..0c27645 --- /dev/null +++ b/BaseStationInstaller/common.proto @@ -0,0 +1,47 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands; + +option go_package = "github.com/arduino/arduino-cli/rpc/commands"; + +message Instance { + // The ID of the instance. + int32 id = 1; +} + +message DownloadProgress { + // URL of the download. + string url = 1; + // The file being downloaded. + string file = 2; + // Total size of the file being downloaded. + int64 total_size = 3; + // Size of the downloaded portion of the file. + int64 downloaded = 4; + // Whether the download is complete. + bool completed = 5; +} + +message TaskProgress { + // Description of the task. + string name = 1; + // Additional information about the task. + string message = 2; + // Whether the task is complete. + bool completed = 3; +} diff --git a/BaseStationInstaller/compile.proto b/BaseStationInstaller/compile.proto new file mode 100644 index 0000000..51f8337 --- /dev/null +++ b/BaseStationInstaller/compile.proto @@ -0,0 +1,49 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands; + +option go_package = "github.com/arduino/arduino-cli/rpc/commands"; + +import "commands/common.proto"; + +message CompileReq { + Instance instance = 1; // Arduino Core Service instance from the `Init` response. + string fqbn = 2; // Fully Qualified Board Name, e.g.: `arduino:avr:uno`. If this field is not defined, the FQBN of the board attached to the sketch via the `BoardAttach` method is used. + string sketchPath = 3; // The path where the sketch is stored. + bool showProperties = 4; // Show all build preferences used instead of compiling. + bool preprocess = 5; // Print preprocessed code to stdout instead of compiling. + string buildCachePath = 6; // Builds of 'core.a' are saved into this path to be cached and reused. + string buildPath = 7; // Path to use to store the files used for the compilation. If omitted, a directory will be created in the operating system's default temporary path. + repeated string buildProperties = 8; // List of custom build properties separated by commas. + string warnings = 9; // Used to tell gcc which warning level to use. The level names are: "none", "default", "more" and "all". + bool verbose = 10; // Turns on verbose mode. + bool quiet = 11; // Suppresses almost every output. + string vidPid = 12; // VID/PID specific build properties. + string exportFile = 13 [deprecated = true]; // DEPRECATED: use exportDir instead + int32 jobs = 14; // The max number of concurrent compiler instances to run (as `make -jx`). If jobs is set to 0, it will use the number of available CPUs as the maximum. + repeated string libraries = 15; // List of custom libraries paths separated by commas. + bool optimizeForDebug = 16; // Optimize compile output for debug, not for release. + bool dryRun = 17; // When set to `true` the compiled binary will not be copied to the export directory. + string export_dir = 18; // Optional: save the build artifacts in this directory, the directory must exist. + string programmer = 19; // External programmer for upload +} + +message CompileResp { + bytes out_stream = 1; // The output of the compilation process. + bytes err_stream = 2; // The error output of the compilation process. +} diff --git a/BaseStationInstaller/core.proto b/BaseStationInstaller/core.proto new file mode 100644 index 0000000..b928823 --- /dev/null +++ b/BaseStationInstaller/core.proto @@ -0,0 +1,144 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands; + +option go_package = "github.com/arduino/arduino-cli/rpc/commands"; + +import "commands/common.proto"; + +message PlatformInstallReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Vendor name of the platform (e.g., `arduino`). + string platform_package = 2; + // Architecture name of the platform (e.g., `avr`). + string architecture = 3; + // Platform version to install. + string version = 4; +} + +message PlatformInstallResp { + // Progress of the downloads of the platform and tool files. + DownloadProgress progress = 1; + // Description of the current stage of the installation. + TaskProgress task_progress = 2; +} + +message PlatformDownloadReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + string platform_package = 2; + // Architecture name of the platform (e.g., `avr`). + string architecture = 3; + // Platform version to download. + string version = 4; +} + +message PlatformDownloadResp { + // Progress of the downloads of platform and tool files. + DownloadProgress progress = 1; +} + +message PlatformUninstallReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Vendor name of the platform (e.g., `arduino`). + string platform_package = 2; + // Architecture name of the platform (e.g., `avr`). + string architecture = 3; +} + +message PlatformUninstallResp { + // Description of the current stage of the uninstall. + TaskProgress task_progress = 1; +} + +message PlatformUpgradeReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Vendor name of the platform (e.g., `arduino`). + string platform_package = 2; + // Architecture name of the platform (e.g., `avr`). + string architecture = 3; +} + +message PlatformUpgradeResp { + // Progress of the downloads of the platform and tool files. + DownloadProgress progress = 1; + // Description of the current stage of the upgrade. + TaskProgress task_progress = 2; +} + +message PlatformSearchReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Keywords for the search. + string search_args = 2; + // Whether to show all available versions. `false` causes only the newest + // versions of the cores to be listed in the search results. + bool all_versions = 3; +} + +message PlatformSearchResp { + // Results of the search. + repeated Platform search_output = 1; +} + +message PlatformListReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Set to true to only list platforms which have a newer version available + // than the one currently installed. + bool updatable_only = 2; +} + +message PlatformListResp { + // The installed platforms. + repeated Platform installed_platform = 1; +} + +message Platform { + // Platform ID (e.g., `arduino:avr`). + string ID = 1; + // Version of the platform. + string Installed = 2; + // Newest available version of the platform. + string Latest = 3; + // Name used to identify the platform to humans (e.g., "Arduino AVR Boards"). + string Name = 4; + // Maintainer of the platform's package. + string Maintainer = 5; + // A URL provided by the author of the platform's package, intended to point + // to their website. + string Website = 6; + // Email of the maintainer of the platform's package. + string Email = 7; + // List of boards provided by the platform. If the platform is installed, + // this is the boards listed in the platform's boards.txt. If the platform is + // not installed, this is an arbitrary list of board names provided by the + // platform author for display and may not match boards.txt. + repeated Board Boards = 8; +} + +message Board { + // Name used to identify the board to humans. + string name = 1; + // Fully qualified board name used to identify the board to machines. The FQBN + // is only available for installed boards. + string fqbn = 2; +} \ No newline at end of file diff --git a/BaseStationInstaller/lib.proto b/BaseStationInstaller/lib.proto new file mode 100644 index 0000000..8601a73 --- /dev/null +++ b/BaseStationInstaller/lib.proto @@ -0,0 +1,284 @@ +// This file is part of arduino-cli. +// +// Copyright 2020 ARDUINO SA (http://www.arduino.cc/) +// +// This software is released under the GNU General Public License version 3, +// which covers the main part of arduino-cli. +// The terms of this license can be found at: +// https://www.gnu.org/licenses/gpl-3.0.en.html +// +// You can be released from the requirements of the above licenses by purchasing +// a commercial license. Buying such a license is mandatory if you want to +// modify or otherwise use the software for commercial activities involving the +// Arduino software without disclosing the source code of your own applications. +// To purchase a commercial license, send an email to license@arduino.cc. + +syntax = "proto3"; + +package cc.arduino.cli.commands; + +option go_package = "github.com/arduino/arduino-cli/rpc/commands"; + +import "commands/common.proto"; + +message LibraryDownloadReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Name of the library. + string name = 2; + // The version of the library to download. + string version = 3; +} + +message LibraryDownloadResp { + // Progress of the library download. + DownloadProgress progress = 1; +} + +message LibraryInstallReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Name of the library. + string name = 2; + // The version of the library to install. + string version = 3; +} + +message LibraryInstallResp { + // Progress of the library download. + DownloadProgress progress = 1; + // Description of the current stage of the installation. + TaskProgress task_progress = 2; +} + +message LibraryUninstallReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Name of the library. + string name = 2; + // The version of the library to uninstall. + string version = 3; +} + +message LibraryUninstallResp { + // Description of the current stage of the uninstallation. + TaskProgress task_progress = 1; +} + +message LibraryUpgradeAllReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; +} + +message LibraryUpgradeAllResp { + // Progress of the downloads of files needed for the upgrades. + DownloadProgress progress = 1; + // Description of the current stage of the upgrade. + TaskProgress task_progress = 2; +} + +message LibraryResolveDependenciesReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Name of the library. + string name = 2; + // The version of the library to check dependencies of. If no version is + // specified, dependencies of the newest version will be listed. + string version = 3; +} + +message LibraryResolveDependenciesResp { + // Dependencies of the library. + repeated LibraryDependencyStatus dependencies = 1; +} + +message LibraryDependencyStatus { + // The name of the library dependency. + string name = 1; + // The required version of the library dependency. + string versionRequired = 2; + // Version of the library dependency currently installed. + string versionInstalled = 3; +} + +message LibrarySearchReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // The search query. + string query = 2; +} + +enum LibrarySearchStatus { + // No search results were found. + failed = 0; + // Search results were found. + success = 1; +} + +message LibrarySearchResp { + // The results of the search. + repeated SearchedLibrary libraries = 1; + // Whether the search yielded results. + LibrarySearchStatus status = 2; +} + +message SearchedLibrary { + // Library name. + string name = 1; + // The index data for the available versions of the library. The key of the + // map is the library version. + map releases = 2; + // The index data for the latest version of the library. + LibraryRelease latest = 3; +} + +message LibraryRelease { + // Value of the `author` field in library.properties. + string author = 1; + // Value of the `version` field in library.properties. + string version = 2; + // Value of the `maintainer` field in library.properties. + string maintainer = 3; + // Value of the `sentence` field in library.properties. + string sentence = 4; + // Value of the `paragraph` field in library.properties. + string paragraph = 5; + // Value of the `url` field in library.properties. + string website = 6; + // Value of the `category` field in library.properties. + string category = 7; + // Value of the `architectures` field in library.properties. + repeated string architectures = 8; + // The type categories of the library, as defined in the libraries index. + // Possible values: `Arduino`, `Partner`, `Recommended`, `Contributed`, + // `Retired`. + repeated string types = 9; + // Information about the library archive file. + DownloadResource resources = 10; + // Value of the `license` field in library.properties. + string license = 11; + // Value of the `includes` field in library.properties. + repeated string provides_includes = 12; + // The names of the library's dependencies, as defined by the 'depends' + // field of library.properties. + repeated LibraryDependency dependencies = 13; +} + +message LibraryDependency { + // Library name of the dependency. + string name = 1; + // Version constraint of the dependency. + string version_constraint = 2; +} + +message DownloadResource { + // Download URL of the library archive. + string url = 1; + // Filename of the library archive. + string archivefilename = 2; + // Checksum of the library archive. + string checksum = 3; + // File size of the library archive. + int64 size = 4; + // The directory under the staging subdirectory of the data directory the + // library archive file will be downloaded to. + string cachepath = 5; +} + +message LibraryListReq { + // Arduino Core Service instance from the `Init` response. + Instance instance = 1; + // Whether to include built-in libraries (from platforms and the Arduino + // IDE) in the listing. + bool all = 2; + // Whether to list only libraries for which there is a newer version than + // the installed version available in the libraries index. + bool updatable = 3; +} + +message LibraryListResp { + // List of installed libraries. + repeated InstalledLibrary installed_library = 1; +} + +message InstalledLibrary { + // Information about the library. + Library library = 1; + // When the `updatable` field of the `LibraryList` request is set to `true`, + // this will contain information on the latest version of the library in the + // libraries index. + LibraryRelease release = 2; +} + +message Library { + // The library's directory name. + string name = 1; + // Value of the `author` field in library.properties. + string author = 2; + // Value of the `maintainer` field in library.properties. + string maintainer = 3; + // Value of the `sentence` field in library.properties. + string sentence = 4; + // Value of the `paragraph` field in library.properties. + string paragraph = 5; + // Value of the `url` field in library.properties. + string website = 6; + // Value of the `category` field in library.properties. + string category = 7; + // Value of the `architectures` field in library.properties. + repeated string architectures = 8; + // The type categories of the library. Possible values: `Arduino`, + // `Partner`, `Recommended`, `Contributed`, `Retired`. + repeated string types = 9; + // The path of the library directory. + string install_dir = 10; + // The location of the library's source files. + string source_dir = 11; + // The location of the library's `utility` directory. + string utility_dir = 12; + // If `location` is `platform_builtin` or `referenced_platform_builtin`, the + // identifying string for the platform containing the library + // (e.g., `arduino:avr@1.8.2`). + string container_platform = 14; + // Value of the `name` field in library.properties. + string real_name = 16; + // Value of the `dot_a_linkage` field in library.properties. + bool dot_a_linkage = 17; + // Value of the `precompiled` field in library.properties. + bool precompiled = 18; + // Value of the `ldflags` field in library.properties. + string ld_flags = 19; + // A library.properties file is not present in the library's root directory. + bool is_legacy = 20; + // Value of the `version` field in library.properties. + string version = 21; + // Value of the `license` field in library.properties. + string license = 22; + // The data from the library's library.properties file, including unused + // fields. + map properties = 23; + // The location type of the library installation. + LibraryLocation location = 24; + // The library format type. + LibraryLayout layout = 25; +} + +enum LibraryLayout { + // Library is in the 1.0 Arduino library format. + flat_layout = 0; + // Library is in the 1.5 Arduino library format. + recursive_layout = 1; +} + +enum LibraryLocation { + // In the `libraries` subdirectory of the Arduino IDE installation. + ide_builtin = 0; + // In the `libraries` subdirectory of the user directory (sketchbook). + user = 1; + // In the `libraries` subdirectory of a platform. + platform_builtin = 2; + // When `LibraryLocation` is used in a context where a board is specified, + // this indicates the library is in the `libraries` subdirectory of a + // platform referenced by the board's platform. + referenced_platform_builtin = 3; +}