diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8dada3e --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/extension/GlobalSuppressions.cs b/extension/GlobalSuppressions.cs new file mode 100644 index 0000000..768315f --- /dev/null +++ b/extension/GlobalSuppressions.cs @@ -0,0 +1,26 @@ +// Copyright 2015 Oklahoma State University +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. Project-level +// suppressions either have no target or are given a specific target +// and scoped to a namespace, type, member, etc. +// +// To add a suppression to this file, right-click the message in the +// Error List, point to "Suppress Message(s)", and click "In Project +// Suppression File". You do not need to add suppressions to this +// file manually. + +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1017:MarkAssembliesWithComVisible")] diff --git a/extension/Guids.cs b/extension/Guids.cs new file mode 100644 index 0000000..0bd1d42 --- /dev/null +++ b/extension/Guids.cs @@ -0,0 +1,28 @@ +// Copyright 2015 Oklahoma State University +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Guids.cs +// MUST match guids.h +using System; + +namespace mageload.extension +{ + static class GuidList + { + public const string guidextensionPkgString = "bb99eb3c-b0b5-450b-a131-9c08565f7ed8"; + public const string guidextensionCmdSetString = "b01a2907-cab4-4441-8ada-95a9729996c1"; + + public static readonly Guid guidextensionCmdSet = new Guid(guidextensionCmdSetString); + }; +} \ No newline at end of file diff --git a/extension/PkgCmdID.cs b/extension/PkgCmdID.cs new file mode 100644 index 0000000..3f70f5e --- /dev/null +++ b/extension/PkgCmdID.cs @@ -0,0 +1,25 @@ +// Copyright 2015 Oklahoma State University +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// PkgCmdID.cs +// MUST match PkgCmdID.h + +namespace mageload.extension +{ + static class PkgCmdIDList + { + public const uint cmdDeploy = 0x100; + public const uint cmdChoosePort = 0x101; + }; +} \ No newline at end of file diff --git a/extension/Properties/AssemblyInfo.cs b/extension/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b4244f1 --- /dev/null +++ b/extension/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System; +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("mageload")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("OSU ECE Department")] +[assembly: AssemblyProduct("mageload")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: CLSCompliant(false)] +[assembly: NeutralResourcesLanguage("en-US")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + + + diff --git a/extension/Resources.Designer.cs b/extension/Resources.Designer.cs new file mode 100644 index 0000000..ad61645 --- /dev/null +++ b/extension/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace mageload.extension { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("mageload.extension.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/extension/Resources.resx b/extension/Resources.resx new file mode 100644 index 0000000..891c592 --- /dev/null +++ b/extension/Resources.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/extension/Resources/mageload.ico b/extension/Resources/mageload.ico new file mode 100644 index 0000000..a51eab9 Binary files /dev/null and b/extension/Resources/mageload.ico differ diff --git a/extension/VSPackage.resx b/extension/VSPackage.resx new file mode 100644 index 0000000..ced0235 --- /dev/null +++ b/extension/VSPackage.resx @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + mageload + + + Integrates mageload with Atmel Studio + + + Resources\mageload.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/extension/extension.csproj b/extension/extension.csproj new file mode 100644 index 0000000..f8933da --- /dev/null +++ b/extension/extension.csproj @@ -0,0 +1,203 @@ + + + + 12.0 + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + Resources\mageload.ico + + + + Debug + AnyCPU + 2.0 + {46EC26BD-9166-4697-BED5-4B06200695E2} + {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + mageload.extension + mageload extension + false + + + v4.5 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + True + C:\Users\CJ\AppData\Local\Atmel\AtmelStudio\7.0\Extensions\mageload + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + + + + + + True + + + + + + + + True + + + True + + + True + + + true + + + + + + + + + + + + + + + + {80CC9F66-E7D8-4DDD-85B6-D9E6CD0E93E2} + 8 + 0 + 0 + primary + False + False + + + {26AD1324-4B7C-44BC-84F8-B86AED45729F} + 10 + 0 + 0 + primary + False + False + + + {1A31287A-4D7D-413E-8E32-3B374931BD89} + 8 + 0 + 0 + primary + False + False + + + {2CE2370E-D744-4936-A090-3FFFE667B0E1} + 9 + 0 + 0 + primary + False + False + + + {1CBA492E-7263-47BB-87FE-639000619B15} + 8 + 0 + 0 + primary + False + False + + + {00020430-0000-0000-C000-000000000046} + 2 + 0 + 0 + primary + False + False + + + + + + True + True + Resources.resx + + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + true + VSPackage + Designer + + + + + Designer + + + + + Menus.ctmenu + Designer + + + + + {0134ceda-c750-4f2d-94ec-15c67c160d35} + mageload + + + + + + Always + true + + + + true + + + + + if $(ConfigurationName) == Release ( echo f | xcopy.exe "$(TargetDir)mageload extension.vsix" $(ProjectDir)..\release\mageload-2.2.vsix /Y /C ) + + + \ No newline at end of file diff --git a/extension/extension.vsct b/extension/extension.vsct new file mode 100644 index 0000000..dae0002 --- /dev/null +++ b/extension/extension.vsct @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extension/extensionPackage.cs b/extension/extensionPackage.cs new file mode 100644 index 0000000..9dbd8fd --- /dev/null +++ b/extension/extensionPackage.cs @@ -0,0 +1,115 @@ +// Copyright 2015 Oklahoma State University +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Runtime.InteropServices; +using EnvDTE; +using Microsoft.VisualStudio; +using Microsoft.VisualStudio.Shell; +using Microsoft.VisualStudio.Shell.Interop; + +namespace mageload.extension +{ + [PackageRegistration(UseManagedResourcesOnly = true)] + [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] + [ProvideMenuResource("Menus.ctmenu", 1)] + [Guid(GuidList.guidextensionPkgString)] + [ProvideAutoLoad("ADFC4E64-0397-11D1-9F4E-00A0C911004F")] + public sealed class ExtensionPackage : Package, IDisposable + { + private DTE _dte; + private BackgroundWorker _worker; + + public void Dispose() + { + _worker.Dispose(); + } + + protected override void Initialize() + { + base.Initialize(); + + OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; + if (null != mcs) + { + CommandID deployID = new CommandID(GuidList.guidextensionCmdSet, (int)PkgCmdIDList.cmdDeploy); + OleMenuCommand deploy = new OleMenuCommand(Deploy, deployID); + deploy.BeforeQueryStatus += button_BeforeQueryStatus; + mcs.AddCommand(deploy); + + CommandID chooseportID = new CommandID(GuidList.guidextensionCmdSet, (int)PkgCmdIDList.cmdChoosePort); + OleMenuCommand chooseport = new OleMenuCommand(ChoosePort, chooseportID); + chooseport.BeforeQueryStatus += button_BeforeQueryStatus; + mcs.AddCommand(chooseport); + + IVsOutputWindow outputWindow = GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow; + if (outputWindow != null) + { + IVsOutputWindowPane pane; + outputWindow.CreatePane(VSConstants.OutputWindowPaneGuid.GeneralPane_guid, "mageload", 1, 0); + outputWindow.GetPane(VSConstants.OutputWindowPaneGuid.GeneralPane_guid, out pane); + Program.Pane = pane; + } + } + _worker = new BackgroundWorker(); + _worker.DoWork += DoDeploy; + + _dte = GetGlobalService(typeof(DTE)) as DTE; + if (_dte != null) _dte.Commands.Item("Tools.Deploy").Bindings = "Global::F8"; + } + + private void Deploy(object sender, EventArgs e) + { + if (_worker.IsBusy) return; + _worker.RunWorkerAsync(); + } + + private void DoDeploy(object sender, DoWorkEventArgs e) + { + Project proj = null; + foreach (Project p in _dte.Solution.Projects) + { + proj = p; + } + if (proj == null) return; + + _dte.Solution.SolutionBuild.Build(true); + if (_dte.Solution.SolutionBuild.LastBuildInfo != 0) return; + + string dir = proj.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputDirectory").Value.ToString(); + string file = proj.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputFile").Value.ToString(); + file = file.Replace(".elf", ".hex"); + + Program.Main(new[] { "-f", dir + "\\" + file }); + } + + private void ChoosePort(object sender, EventArgs e) + { + if (_worker.IsBusy) return; + Program.Main(new[] {"-p"}); + } + + private void button_BeforeQueryStatus(object sender, EventArgs e) + { + bool enabled = _dte.Solution.IsOpen; + OleMenuCommand menuCommand = sender as OleMenuCommand; + if (menuCommand != null) + { + menuCommand.Enabled = enabled; + } + } + } +} diff --git a/extension/source.extension.vsixmanifest b/extension/source.extension.vsixmanifest new file mode 100644 index 0000000..7f11ee2 --- /dev/null +++ b/extension/source.extension.vsixmanifest @@ -0,0 +1,19 @@ + + + + + mageload + Integrates mageload with Atmel Studio + https://github.com/cjvaughter/mageload + Resources\mageload.ico + + + + + + + + + + + diff --git a/mageload.sln b/mageload.sln index 215b77a..d99e048 100644 --- a/mageload.sln +++ b/mageload.sln @@ -1,10 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mageload", "mageload\mageload.csproj", "{0134CEDA-C750-4F2D-94EC-15C67C160D35}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "extension", "extension\extension.csproj", "{46EC26BD-9166-4697-BED5-4B06200695E2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {0134CEDA-C750-4F2D-94EC-15C67C160D35}.Debug|Any CPU.Build.0 = Debug|Any CPU {0134CEDA-C750-4F2D-94EC-15C67C160D35}.Release|Any CPU.ActiveCfg = Release|Any CPU {0134CEDA-C750-4F2D-94EC-15C67C160D35}.Release|Any CPU.Build.0 = Release|Any CPU + {46EC26BD-9166-4697-BED5-4B06200695E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {46EC26BD-9166-4697-BED5-4B06200695E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {46EC26BD-9166-4697-BED5-4B06200695E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {46EC26BD-9166-4697-BED5-4B06200695E2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/mageload/PortWindow.Designer.cs b/mageload/PortWindow.Designer.cs index f6c02cd..0fbae09 100644 --- a/mageload/PortWindow.Designer.cs +++ b/mageload/PortWindow.Designer.cs @@ -1,4 +1,18 @@ -namespace mageload +// Copyright 2015 Oklahoma State University +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace mageload { partial class PortWindow { diff --git a/mageload/PortWindow.cs b/mageload/PortWindow.cs index 30b2181..b87e09d 100644 --- a/mageload/PortWindow.cs +++ b/mageload/PortWindow.cs @@ -1,13 +1,21 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; +// Copyright 2015 Oklahoma State University +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; using System.IO.Ports; +using System.Windows.Forms; +using mageload.Properties; namespace mageload { @@ -21,12 +29,12 @@ public PortWindow() foreach (string p in ports) { cbPort.Items.Add(p); - if (Properties.Settings.Default.Port == p) + if (Settings.Default.Port == p) cbPort.Text = p; } } - public string getPort() + public string GetPort() { return _port; } diff --git a/mageload/Program.cs b/mageload/Program.cs index 844104a..224bc22 100644 --- a/mageload/Program.cs +++ b/mageload/Program.cs @@ -1,4 +1,18 @@ -using System; +// Copyright 2015 Oklahoma State University +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; using System.IO; using System.IO.Ports; using System.Linq; @@ -6,6 +20,7 @@ using System.Threading; using System.Windows.Forms; using mageload.Properties; +using Microsoft.VisualStudio.Shell.Interop; namespace mageload { @@ -41,8 +56,10 @@ public enum RecordType : byte StartLinAddress } - class Program + public class Program { + public static IVsOutputWindowPane Pane = null; + static bool _verbose; static bool _ota; static string _port = ""; @@ -67,11 +84,24 @@ class Program + " If no port specified, a window will appear\n\n" + "-f file: The hex file to load\n\n"; - static void Main(string[] args) + public static void Main(string[] args) { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); + _verbose = false; + _ota = false; + _port = ""; + _file = ""; + _hex = ""; + _pageSize = 0; + _data = null; + _maxAddress = 0; + _serial = null; + if (!ParseArgs(args)) return; + if (Pane != null) + { + Pane.Clear(); + Pane.Activate(); + } if (!LoadFile()) return; if (!InitializeSerial()) return; if (!ParseFile()) return; @@ -89,7 +119,7 @@ static void Main(string[] args) } } SerialClose(); - Console.Write("\nUpload successful\n"); + Write("\nUpload successful\n"); } static bool ParseArgs(string[] args) @@ -97,7 +127,7 @@ static bool ParseArgs(string[] args) int argIndex = 0; if (args.Length == 0) { - Console.Write(Usage); + Write(Usage); return false; } if (args[argIndex].ToLower() == "-v") @@ -115,10 +145,11 @@ static bool ParseArgs(string[] args) argIndex++; if (argIndex == args.Length) { + Application.EnableVisualStyles(); PortWindow window = new PortWindow(); DialogResult r = window.ShowDialog(); if (r != DialogResult.OK) return false; - _port = window.getPort(); + _port = window.GetPort(); Settings.Default.Port = _port; Settings.Default.Save(); } @@ -140,12 +171,12 @@ static bool ParseArgs(string[] args) } if (_file == "" && _port == "") { - Console.Write(Usage); + Write(Usage); return false; } if (_file == "") return false; - if (_port == "") _port = Settings.Default.Port; _port = Settings.Default.Port; + _port = Settings.Default.Port; return true; } @@ -154,7 +185,7 @@ static bool LoadFile() { if (!File.Exists(_file)) { - Console.Write("\nFile does not exist: " + _file + "\n\n"); + Write("\nFile does not exist: " + _file + "\n\n"); return false; } try @@ -166,8 +197,8 @@ static bool LoadFile() } catch (Exception e) { - Console.Write("\nThe file could not be read\n\n"); - if (_verbose) Console.WriteLine(e.Message); + Write("\nThe file could not be read\n\n"); + if (_verbose) WriteLine(e.Message); return false; } return true; @@ -211,16 +242,16 @@ static bool ParseFile() break; case RecordType.ExtLinAddress: case RecordType.StartLinAddress: - Console.Write("\nUnknown record type in file\n\n"); - if (_verbose) Console.WriteLine("Type: " + type); + Write("\nUnknown record type in file\n\n"); + if (_verbose) WriteLine("Type: " + type); break; } } } catch(Exception e) { - Console.Write("\nUnrecognized file\n\n"); - if (_verbose) Console.WriteLine(e.Message); + Write("\nUnrecognized file\n\n"); + if (_verbose) WriteLine(e.Message); return false; } @@ -231,7 +262,7 @@ static bool InitializeSerial() { if (!SerialPort.GetPortNames().Contains(_port)) { - Console.Write("\nInvalid COM port: " + _port + "\n\n"); + Write("\nInvalid COM port: " + _port + "\n\n"); return false; } @@ -257,8 +288,8 @@ static bool InitializeSerial() } catch (Exception e) { - Console.Write("\nCould not open COM port\n\n"); - if(_verbose) Console.WriteLine(e.Message); + Write("\nCould not open COM port\n\n"); + if(_verbose) WriteLine(e.Message); return false; } @@ -285,28 +316,28 @@ static bool InitializeSerial() inbfr[2] == (byte) Signature.PIU_2 && inbfr[3] == (byte) Commands.OK) { _pageSize = 256; - if (_verbose) Console.WriteLine("Player Interface Unit found\n"); + if (_verbose) WriteLine("Player Interface Unit found\n"); _data = Enumerable.Repeat(0xFF, 261120).ToArray(); //leave space for bootloader } else if (inbfr[0] == (byte) Signature.Cert_0 && inbfr[1] == (byte) Signature.Cert_1 && inbfr[2] == (byte) Signature.Cert_2 && inbfr[3] == (byte) Commands.OK) { _pageSize = 128; - if (_verbose) Console.WriteLine("MCU Certification Board found\n"); + if (_verbose) WriteLine("MCU Certification Board found\n"); _data = Enumerable.Repeat(0xFF, 32000).ToArray(); } else { - Console.Write("\nInvalid device detected\n\n"); + Write("\nInvalid device detected\n\n"); if (_verbose) - Console.WriteLine(inbfr[0].ToString("X") + " " + inbfr[1].ToString("X") + " " + inbfr[2].ToString("X")); + WriteLine(inbfr[0].ToString("X") + " " + inbfr[1].ToString("X") + " " + inbfr[2].ToString("X")); return false; } } catch (Exception e) { - Console.Write("\nCould not read device signature\n\n"); - if (_verbose) Console.WriteLine(e.Message); + Write("\nCould not read device signature\n\n"); + if (_verbose) WriteLine(e.Message); return false; } @@ -323,18 +354,18 @@ static bool SendData() return false; } - if (!_verbose) Console.Write("Writing "); + if (!_verbose) Write("Writing "); _serial.ReadExisting(); uint lastpercent = 0; for (uint i = 0; i < _maxAddress; i += _pageSize) { if (!_verbose) { - uint percent = (uint) (((float) i/(float) _maxAddress)*50); + uint percent = (uint) (((float) i/_maxAddress)*50); if (percent >= lastpercent) { for (; lastpercent <= percent; lastpercent++) - Console.Write("+"); + Write("+"); } } byte[] bfr = new byte[6]; @@ -345,7 +376,7 @@ static bool SendData() bfr[3] = (byte)(address >> 8); bfr[4] = (byte)(address); bfr[5] = (byte)Commands.Execute; - if (_verbose) Console.Write("ADDRESS " + ToHex(bfr) + " "); + if (_verbose) Write("ADDRESS " + ToHex(bfr) + " "); _serial.Write(bfr, 0, 6); if (_ota) Thread.Sleep(60); @@ -354,11 +385,11 @@ static bool SendData() if (!_ota) { response = (byte) _serial.ReadByte(); - if (_verbose) Console.WriteLine(ToHex(response)); + if (_verbose) WriteLine(ToHex(response)); if (response != (byte) Commands.OK) { - Console.Write("\nFailed to address memory\n\n"); - if (_verbose) Console.WriteLine("Invalid response: 0x" + response.ToString("X")); + Write("\nFailed to address memory\n\n"); + if (_verbose) WriteLine("Invalid response: 0x" + response.ToString("X")); return false; } } @@ -368,10 +399,10 @@ static bool SendData() bfr[1] = (byte)(_pageSize >> 8); bfr[2] = (byte)(_pageSize); bfr[3] = (byte)(Commands.Execute); - if (_verbose) Console.Write("WRITE " + ToHex(bfr) + " "); + if (_verbose) Write("WRITE " + ToHex(bfr) + " "); _serial.Write(bfr, 0, 4); if (_ota) Thread.Sleep(60); - if (_verbose) Console.Write("...DATA... "); + if (_verbose) Write("...DATA... "); if (_ota) { int size = _pageSize/4; @@ -397,22 +428,22 @@ static bool SendData() if (!_ota) { response = (byte) _serial.ReadByte(); - if (_verbose) Console.WriteLine(ToHex(response)); + if (_verbose) WriteLine(ToHex(response)); if (response != (byte) Commands.OK) { - Console.Write("\nFailed to write memory\n\n"); - if (_verbose) Console.WriteLine("Invalid response: 0x" + response.ToString("X")); + Write("\nFailed to write memory\n\n"); + if (_verbose) WriteLine("Invalid response: 0x" + response.ToString("X")); return false; } } - if(_verbose && _ota) Console.WriteLine(""); + if(_verbose && _ota) WriteLine(""); } - if (!_verbose) Console.Write("\n\n"); + if (!_verbose) Write("\n\n"); } catch (Exception e) { - Console.Write("\nCommunication failure\n\n"); - if (_verbose) Console.WriteLine(e.Message); + Write("\nCommunication failure\n\n"); + if (_verbose) WriteLine(e.Message); return false; } return true; @@ -422,18 +453,18 @@ static bool VerifyData() { try { - if (!_verbose) Console.Write("Verifying "); + if (!_verbose) Write("Verifying "); byte[] bfr; uint lastpercent = 0; for (uint i = 0; i < _maxAddress; i += _pageSize) { if (!_verbose) { - uint percent = (uint)(((float)i / (float)_maxAddress) * 50); + uint percent = (uint)(((float)i / _maxAddress) * 50); if (percent >= lastpercent) { for (; lastpercent <= percent; lastpercent++) - Console.Write("+"); + Write("+"); } } bfr = new byte[6]; @@ -444,15 +475,15 @@ static bool VerifyData() bfr[3] = (byte)(address >> 8); bfr[4] = (byte)(address); bfr[5] = (byte)Commands.Execute; - if (_verbose) Console.Write("ADDRESS " + ToHex(bfr) + " "); + if (_verbose) Write("ADDRESS " + ToHex(bfr) + " "); _serial.Write(bfr, 0, 6); byte response = (byte)_serial.ReadByte(); - if (_verbose) Console.WriteLine(ToHex(response)); + if (_verbose) WriteLine(ToHex(response)); if (response != (byte)Commands.OK) { - Console.Write("\nFailed to address memory\n\n"); - if (_verbose) Console.WriteLine("Invalid response: 0x" + response.ToString("X")); + Write("\nFailed to address memory\n\n"); + if (_verbose) WriteLine("Invalid response: 0x" + response.ToString("X")); return false; } @@ -461,22 +492,22 @@ static bool VerifyData() bfr[1] = (byte)(_pageSize >> 8); bfr[2] = (byte)(_pageSize); bfr[3] = (byte)(Commands.Execute); - if (_verbose) Console.Write("READ " + ToHex(bfr) + " "); + if (_verbose) Write("READ " + ToHex(bfr) + " "); _serial.Write(bfr, 0, 4); byte[] data = new byte[_pageSize]; - if (_verbose) Console.Write("...DATA... "); + if (_verbose) Write("...DATA... "); for (int j = 0; j < _pageSize; j++) { data[j] = (byte)_serial.ReadByte(); } response = (byte)_serial.ReadByte(); - if (_verbose) Console.WriteLine(ToHex(response)); + if (_verbose) WriteLine(ToHex(response)); if (response != (byte)Commands.OK) { - Console.Write("\nFailed to read memory\n\n"); - if (_verbose) Console.WriteLine("Invalid response: 0x" + response.ToString("X")); + Write("\nFailed to read memory\n\n"); + if (_verbose) WriteLine("Invalid response: 0x" + response.ToString("X")); return false; } @@ -484,26 +515,26 @@ static bool VerifyData() { if (_data[i + j] != data[j]) { - Console.Write("\nFailed to verify memory\n\n"); - if (_verbose) Console.WriteLine("Address: " + i.ToString("X") + "\nRead: " + _data[i+j].ToString("X") + " Expected: " + data[j].ToString("X")); + Write("\nFailed to verify memory\n\n"); + if (_verbose) WriteLine("Address: " + i.ToString("X") + "\nRead: " + _data[i+j].ToString("X") + " Expected: " + data[j].ToString("X")); return false; } } } - if (!_verbose) Console.Write("\n"); + if (!_verbose) Write("\n"); bfr = new byte[2]; bfr[0] = (byte)Commands.Exit; bfr[1] = (byte)(Commands.Execute); - if (_verbose) Console.WriteLine("EXIT"); + if (_verbose) WriteLine("EXIT"); _serial.Write(bfr, 0, 2); SerialClose(); } catch (Exception e) { - Console.Write("\nCommunication failure\n\n"); - if (_verbose) Console.WriteLine(e.Message); + Write("\nCommunication failure\n\n"); + if (_verbose) WriteLine(e.Message); return false; } return true; @@ -517,13 +548,13 @@ static void SerialClose() { if (!ATMode()) return; - if (_verbose) Console.WriteLine("Setting API 2 mode"); + if (_verbose) WriteLine("Setting API 2 mode"); _serial.Write("ATAP 2\r".ToCharArray(), 0, 7); _serial.ReadChar(); _serial.ReadChar(); if (_serial.ReadByte() != 0x0D) { - Console.Write("\nCould not set API 2 mode\n\n"); + Write("\nCould not set API 2 mode\n\n"); return; } @@ -533,8 +564,8 @@ static void SerialClose() } catch (Exception e) { - Console.Write("\nCould not close " + _port + "\n\n"); - if(_verbose) Console.WriteLine(e.Message); + Write("\nCould not close " + _port + "\n\n"); + if(_verbose) WriteLine(e.Message); } } @@ -542,19 +573,19 @@ private static bool OTA() { byte[] dfuCommand = { 0x7E, 0x00, 0x0F, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0xFF, 0xF5}; - if(_verbose) Console.WriteLine("Broadcasting DFU command..."); + if(_verbose) WriteLine("Broadcasting DFU command..."); _serial.Write(dfuCommand, 0, 19); Thread.Sleep(100); if (!ATMode()) return false; - if (_verbose) Console.WriteLine("Setting transparent mode"); + if (_verbose) WriteLine("Setting transparent mode"); _serial.Write("ATAP 0\r".ToCharArray(), 0, 7); _serial.ReadChar(); _serial.ReadChar(); if (_serial.ReadByte() != 0x0D) { - Console.Write("\nCould not set transparent mode\n\n"); + Write("\nCould not set transparent mode\n\n"); return false; } @@ -582,7 +613,7 @@ static bool ATMode() { while (_serial.BytesToWrite != 0) {} while (_serial.BytesToRead != 0) { _serial.ReadByte(); } - if (_verbose) Console.WriteLine("Entering AT mode"); + if (_verbose) WriteLine("Entering AT mode"); Thread.Sleep(200); _serial.Write("+++".ToCharArray(), 0, 3); Thread.Sleep(10); @@ -590,7 +621,7 @@ static bool ATMode() _serial.ReadChar(); if (_serial.ReadByte() != 0x0D) { - Console.Write("\nCould not enter AT mode\n\n"); + Write("\nCould not enter AT mode\n\n"); return false; } return true; @@ -598,16 +629,40 @@ static bool ATMode() static bool ExitATMode() { - if (_verbose) Console.WriteLine("Exiting AT mode"); + if (_verbose) WriteLine("Exiting AT mode"); _serial.Write("ATCN\r".ToCharArray(), 0, 5); _serial.ReadChar(); _serial.ReadChar(); if (_serial.ReadByte() != 0x0D) { - Console.Write("\nCould not exit AT mode\n\n"); + Write("\nCould not exit AT mode\n\n"); return false; } return true; } + + static void Write(string output) + { + if (Pane != null) + { + Pane.OutputString(output); + } + else + { + Console.Write(output); + } + } + + static void WriteLine(string output) + { + if (Pane != null) + { + Pane.OutputString(output + "\n"); + } + else + { + Console.WriteLine(output); + } + } } } diff --git a/mageload/Properties/AssemblyInfo.cs b/mageload/Properties/AssemblyInfo.cs index 80913c3..34f0d67 100644 --- a/mageload/Properties/AssemblyInfo.cs +++ b/mageload/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/mageload/Resources/mageload.ico b/mageload/Resources/mageload.ico new file mode 100644 index 0000000..a51eab9 Binary files /dev/null and b/mageload/Resources/mageload.ico differ diff --git a/mageload/mageload.csproj b/mageload/mageload.csproj index f107962..14e000c 100644 --- a/mageload/mageload.csproj +++ b/mageload/mageload.csproj @@ -63,7 +63,21 @@ LocalIntranet + + false + + + + + + + + + + Resources\mageload.ico + + @@ -118,9 +132,13 @@ false + + + + - echo f | xcopy.exe $(TargetPath) $(ProjectDir)..\release\mageload-2.0.exe /Y /C + if $(ConfigurationName) == Release ( echo f | xcopy.exe $(TargetPath) $(ProjectDir)..\release\mageload-2.2.exe /Y /C )