├── spelling_exclusion.dic
├── assets
└── nf-logo.png
├── USB Test App WPF
├── NFApp34.bin
├── Serial Test App WPF.nugetreferenceswitcher
├── Serial Test App WPF.previous.nugetreferenceswitcher
├── App.config
├── Services
│ └── NanoFrameworkService
│ │ ├── INFDebugClientBaseService.cs
│ │ ├── INFSerialDebugClientService.cs
│ │ └── NFSerialDebugClientService.cs
├── App.xaml
├── ViewModel
│ └── ViewModelLocator.cs
├── App.xaml.cs
└── Properties
│ ├── AssemblyInfo.cs
│ └── Resources.Designer.cs
├── nanoFramework.Tools.DebugLibrary.Net
├── key.snk
├── FodyWeavers.xml
├── app.config
├── PortDefinitions
│ └── PortBase.cs
├── FodyWeavers.xsd
└── nanoFramework.Tools.DebugLibrary.Net.csproj
├── nanoFramework.Tools.DebugLibrary.Shared
├── NFDevice
│ ├── INanoDevice.cs
│ ├── NanoSerialDevice.cs
│ ├── SrecParseResult.cs
│ ├── CachedDeviceInfo.cs
│ └── NanoDevice.cs
├── WireProtocol
│ ├── ConnectionSource.cs
│ ├── ControllerBase.cs
│ ├── IControllerLocal.cs
│ ├── PortFilter.cs
│ ├── PublicKeyIndex.cs
│ ├── MessageBase.cs
│ ├── PingConnectionType.cs
│ ├── MessageRaw.cs
│ ├── IControllerRemote.cs
│ ├── TransportType.cs
│ ├── StringEventArgs.cs
│ ├── VersionStruct.cs
│ ├── IControllerHostLocal.cs
│ ├── IControllerHost.cs
│ ├── IController.cs
│ ├── ThreadStatus.cs
│ ├── ConnectPortResult.cs
│ ├── RebootOptions.cs
│ ├── Packet.cs
│ ├── Flags.cs
│ ├── TypeSysLookup.cs
│ ├── IncomingMessage.cs
│ ├── EngineState.cs
│ ├── DeploymentBlock.cs
│ ├── WireProtocolRequestsStore.cs
│ ├── DeploymentSector.cs
│ ├── OutgoingMessage.cs
│ ├── WireProtocolRequest.cs
│ ├── FifoBuffer.cs
│ ├── ReleaseInfo.cs
│ └── TargetInfo.cs
├── PortSerial
│ ├── SerialDeviceProperties.cs
│ └── SerialDeviceInformation.cs
├── MFDeployTool
│ ├── IAppDomainInfo.cs
│ ├── IAssemblyInfo.cs
│ ├── EraseOptions.cs
│ ├── AppDomainInfo.cs
│ ├── INanoFrameworkDeviceInfo.cs
│ └── AssemblyInfoFromResolveAssembly.cs
├── DeviceConfiguration
│ ├── Wireless80211ConfigurationPropertiesBase.cs
│ ├── X509CaRootBundlePropertiesBase.cs
│ ├── DeviceConfigurationBase.cs
│ ├── X509DeviceCertificatesPropertiesBase.cs
│ ├── NanoFrameworkDevices.cs
│ ├── WirelessAPConfigurationPropertiesBase.cs
│ ├── X509CaRootBundleBase.cs
│ ├── X509DeviceCertificatesBase.cs
│ ├── NetworkConfigurationPropertiesBase.cs
│ ├── DeviceConfiguration.X509CaRootBundleProperties.cs
│ ├── DeviceConfiguration.X509DeviceCertificatesProperties.cs
│ ├── DeviceConfigurationOption.cs
│ ├── WirelessConfigurationPropertiesBase.cs
│ ├── Wireless80211Base.cs
│ ├── WirelessAPBase.cs
│ ├── DeviceConfiguration.Wireless80211ConfigurationProperties.cs
│ ├── DeviceConfiguration.WirelessAPConfigurationProperties.cs
│ ├── NetworkConfigurationBase.cs
│ └── DeviceConfiguration.NetworkConfigurationProperties.cs
├── Runtime
│ ├── RuntimeValue_Object.cs
│ ├── ReflectionDefinition.cs
│ ├── RuntimeValue_Internal.cs
│ ├── RuntimeValue_ValueType.cs
│ ├── RuntimeValue_ByRef.cs
│ ├── RuntimeValue_Class.cs
│ ├── RuntimeValue_Array.cs
│ ├── RuntimeValue_Reflection.cs
│ ├── RuntimeValue_String.cs
│ ├── RuntimeValue_Indirect.cs
│ └── RuntimeValue_Primitive.cs
├── PortDefinitions
│ ├── PortMessageBase.cs
│ ├── IPort.cs
│ ├── DeviceWatcherStatus.cs
│ └── PortBase.cs
├── PortTcpIp
│ ├── NetworkDeviceInformation.cs
│ └── NanoNetworkDevice.cs
├── Exceptions
│ ├── DeviceNotConnectedException.cs
│ ├── NanoUserExitException.cs
│ ├── RemotedException.cs
│ ├── DebugSessionAlreadyOpenException.cs
│ ├── NanoBooterConnectionFailureException.cs
│ ├── CouldntOpenNanoFrameworkDeviceException.cs
│ └── NanoFrameworkDeviceNoResponseException.cs
├── Extensions
│ ├── IncomingMessageExtensions.cs
│ ├── DeploymentSectorExtensions.cs
│ ├── DeviceConfigurationExtensions.cs
│ ├── DeviceInformationExtensions.cs
│ ├── CancellationTokenExtensions.cs
│ ├── MonitorFlashSectorMapExtensions.cs
│ ├── TaskExtensions.cs
│ ├── FlashSectorDataExtensions.cs
│ └── TypeExtensions.cs
├── Capabilities
│ ├── Nxp.TargetCapabilities.cs
│ ├── Esp32.TargetCapabilities.cs
│ ├── TICC32xx.TargetCapabilities.cs
│ └── Stm32.TargetCapabilities.cs
├── NetworkInformation
│ ├── AddressMode.cs
│ ├── RadioType.cs
│ ├── NetworkInterfaceType.cs
│ ├── WirelessAP_ConfigurationOptions.cs
│ ├── Wireless80211_ConfigurationOptions.cs
│ ├── EncryptionType.cs
│ └── AuthenticationType.cs
├── nanoFramework.Tools.DebugLibrary.Shared.shproj
├── Message.cs
├── MessageWithProgress.cs
├── MessageCall.cs
├── SupportedUSBDevices
│ └── STM_Discovery4.cs
├── ArrayEqualityComparer.cs
└── PortComposite
│ └── PortCompositeDeviceManager.cs
├── README-BEFORE-UPDATE-REFS.txt
├── version.json
├── LICENSE.md
├── README.md
├── .github
└── workflows
│ └── scorecard.yml
└── nanoFramework.Tools.Debugger.sln
/spelling_exclusion.dic:
--------------------------------------------------------------------------------
1 | nano
2 |
--------------------------------------------------------------------------------
/assets/nf-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nanoframework/nf-debugger/HEAD/assets/nf-logo.png
--------------------------------------------------------------------------------
/USB Test App WPF/NFApp34.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nanoframework/nf-debugger/HEAD/USB Test App WPF/NFApp34.bin
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Net/key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nanoframework/nf-debugger/HEAD/nanoFramework.Tools.DebugLibrary.Net/key.snk
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Net/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/USB Test App WPF/Serial Test App WPF.nugetreferenceswitcher:
--------------------------------------------------------------------------------
1 | nanoFramework.Tools.DebugLibrary.Net ../nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj ../packages/nanoFramework.Tools.Debugger.Net.0.5.0-alpha108/lib/net46/nanoFramework.Tools.Debugger.dll
2 |
--------------------------------------------------------------------------------
/USB Test App WPF/Serial Test App WPF.previous.nugetreferenceswitcher:
--------------------------------------------------------------------------------
1 | nanoFramework.Tools.DebugLibrary.Net ../nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj ../packages/nanoFramework.Tools.Debugger.Net.0.5.0-alpha108/lib/net46/nanoFramework.Tools.Debugger.dll
2 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Net/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/USB Test App WPF/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/USB Test App WPF/Services/NanoFrameworkService/INFDebugClientBaseService.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.ANT.Services.NanoFrameworkService
7 | {
8 | public interface INFDebugClientBaseService
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/INanoDevice.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | public interface INanoDevice
9 | {
10 | ConnectPortResult Connect();
11 |
12 | void Disconnect(bool force = false);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/ConnectionSource.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger.WireProtocol
7 | {
8 | public enum ConnectionSource
9 | {
10 | Unknown = 0,
11 | nanoBooter,
12 | nanoCLR,
13 | };
14 | }
15 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/ControllerBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger.WireProtocol
8 | {
9 | public abstract class ControllerBase
10 | {
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/IControllerLocal.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger.WireProtocol
8 | {
9 | public interface IControllerLocal : IController
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/PortSerial/SerialDeviceProperties.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 | using System;
6 |
7 | namespace nanoFramework.Tools.Debugger.Serial
8 | {
9 | public class SerialDeviceProperties
10 | {
11 | public const String DeviceInstanceId = "System.Devices.DeviceInstanceId";
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/PortFilter.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | public enum PortFilter
10 | {
11 | Serial,
12 | Usb,
13 | Emulator,
14 | TcpIp,
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/PublicKeyIndex.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger.WireProtocol
8 | {
9 | public enum PublicKeyIndex
10 | {
11 | FirmwareKey = 0,
12 | DeploymentKey = 1
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/MessageBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger.WireProtocol
8 | {
9 | public class MessageBase
10 | {
11 | public Packet Header;
12 | public object Payload;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/PingConnectionType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | public enum PingConnectionType
10 | {
11 | nanoCLR,
12 | nanoBooter,
13 | NoConnection,
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/USB Test App WPF/Services/NanoFrameworkService/INFSerialDebugClientService.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 | using nanoFramework.Tools.Debugger;
6 |
7 | namespace nanoFramework.ANT.Services.NanoFrameworkService
8 | {
9 | public interface INFSerialDebugClientService : INFDebugClientBaseService
10 | {
11 | PortBase SerialDebugClient { get; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/README-BEFORE-UPDATE-REFS.txt:
--------------------------------------------------------------------------------
1 | Notes on updating the project references:
2 |
3 | IMPORTANT VERSION CONSTRAINTS:
4 | - Can't reference any library requiring System.Threading.Tasks.Extensions must not be updated beyond version 4.5.4
5 | Reason: The VS2019 extension will fail due to a transitive dependency conflict between
6 | Compilers.Services.Unsafe and System.Collections.Immutable.
7 | - Can't update Polly beyond version 7.2.4 because of dependency conflicts with System.Threading.Tasks.Extensions.
8 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoSerialDevice.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | public class NanoSerialDevice
9 | {
10 | ///
11 | /// Default timeout for serial device (in milliseconds).
12 | ///
13 | public const int SafeDefaultTimeout = 1000;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/IAppDomainInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | public interface IAppDomainInfo
10 | {
11 | string Name { get; }
12 | uint ID { get; }
13 | uint[] AssemblyIndices { get; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/version.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3 | "version": "2.5",
4 | "assemblyVersion": {
5 | "precision": "minor"
6 | },
7 | "semVer1NumericIdentifierPadding": 3,
8 | "nugetPackageVersion": {
9 | "semVer": 2
10 | },
11 | "publicReleaseRefSpec": [
12 | "^$"
13 | ],
14 | "cloudBuild": {
15 | "setVersionVariables": true,
16 | "setAllVariables": true
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/MessageRaw.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger.WireProtocol
10 | {
11 | [Serializable]
12 | public class MessageRaw
13 | {
14 | public byte[] Header;
15 | public byte[] Payload;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/IControllerRemote.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 |
8 | namespace nanoFramework.Tools.Debugger.WireProtocol
9 | {
10 | public interface IControllerRemote : IController
11 | {
12 | bool RegisterEndpoint(uint epType, uint epId);
13 | void DeregisterEndpoint(uint epType, uint epId);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/Wireless80211ConfigurationPropertiesBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | ///
9 | /// Base class for wireless 802.11 configuration properties.
10 | ///
11 | public partial class Wireless80211ConfigurationPropertiesBase : WirelessConfigurationPropertiesBase
12 | {
13 | // No additional properties needed for now
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/TransportType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger.WireProtocol
8 | {
9 | ///
10 | /// Defines the .Net Micro Framework transport type for device connection
11 | ///
12 | public enum TransportType
13 | {
14 | Serial,
15 | Usb,
16 | TcpIp,
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Object.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | public class RuntimeValue_Object : RuntimeValue_Indirect
10 | {
11 | protected internal RuntimeValue_Object(Engine eng, WireProtocol.Commands.Debugging_Value[] array, int pos) : base(eng, array, pos)
12 | {
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/IAssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System.Collections.Generic;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | public interface IAssemblyInfo
12 | {
13 | string Name { get; }
14 | System.Version Version { get; }
15 | uint Index { get; }
16 | List InAppDomains { get; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/StringEventArgs.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | public class StringEventArgs : EventArgs
12 | {
13 | public StringEventArgs(string eventArgs)
14 | {
15 | EventText = eventArgs;
16 | }
17 |
18 | public string EventText { get; private set; } = null;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/USB Test App WPF/Services/NanoFrameworkService/NFSerialDebugClientService.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 | using nanoFramework.Tools.Debugger;
6 |
7 | namespace nanoFramework.ANT.Services.NanoFrameworkService
8 | {
9 | public class NFSerialDebugClientService : INFSerialDebugClientService
10 | {
11 | public PortBase SerialDebugClient { get; private set; }
12 |
13 | public NFSerialDebugClientService(PortBase client)
14 | {
15 | SerialDebugClient = client;
16 | }
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/PortDefinitions/PortMessageBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 |
8 | namespace nanoFramework.Tools.Debugger
9 | {
10 | public abstract class PortMessageBase
11 | {
12 | ///
13 | /// Event that is raised when a log message is available.
14 | ///
15 | public abstract event EventHandler LogMessageAvailable;
16 |
17 | //public abstract void OnLogMessageAvailable(string text);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/SrecParseResult.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System.Collections.Generic;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | internal class SrecParseResult
12 | {
13 | public uint EntryPoint { get; internal set; }
14 | public uint ImageSize { get; internal set; }
15 | public Dictionary Records { get; set; } = new Dictionary();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/PortTcpIp/NetworkDeviceInformation.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger.PortTcpIp
7 | {
8 | public class NetworkDeviceInformation
9 | {
10 | public string Host { get; set; }
11 | public int Port { get; set; }
12 |
13 | public string DeviceId => $"tcpip://{Host}:{Port}";
14 |
15 | public NetworkDeviceInformation(string host, int port)
16 | {
17 | Host = host;
18 | Port = port;
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/USB Test App WPF/App.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/VersionStruct.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger.WireProtocol
10 | {
11 | public class VersionStruct
12 | {
13 | public ushort major;
14 | public ushort minor;
15 | public ushort build;
16 | public ushort revision;
17 |
18 | public Version Version
19 | {
20 | get { return new Version(major, minor, build, revision); }
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Exceptions/DeviceNotConnectedException.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 | using System;
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | internal class DeviceNotConnectedException : Exception
10 | {
11 | public DeviceNotConnectedException()
12 | {
13 | }
14 |
15 | public DeviceNotConnectedException(string message) : base(message)
16 | {
17 | }
18 |
19 | public DeviceNotConnectedException(string message, Exception innerException) : base(message, innerException)
20 | {
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/IControllerHostLocal.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger.WireProtocol
10 | {
11 | public interface IControllerHostLocal : IControllerHost
12 | {
13 | bool ProcessMessage(IncomingMessage msg, bool fReply);
14 |
15 | int SendBuffer(byte[] buffer);
16 |
17 | byte[] ReadBuffer(int bytesToRead);
18 |
19 | int AvailableBytes { get; }
20 |
21 | void ReplyBadPacket(uint flags);
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/CachedDeviceInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | internal class CachedDeviceInfo
9 | {
10 | public string TargetName;
11 | public string PlatformName;
12 | public int BaudRate;
13 |
14 | public CachedDeviceInfo(
15 | string targetName,
16 | string platformName,
17 | int baudRate = 0)
18 | {
19 | TargetName = targetName;
20 | PlatformName = platformName;
21 | BaudRate = baudRate;
22 | }
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/IControllerHost.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger.WireProtocol
10 | {
11 | public interface IControllerHost
12 | {
13 | bool IsConnected { get; }
14 |
15 | bool IsCRC32EnabledForWireProtocol { get; }
16 |
17 | void SpuriousCharacters(byte[] buf, int offset, int count);
18 |
19 | event EventHandler SpuriousCharactersReceived;
20 |
21 | void ProcessExited();
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Extensions/IncomingMessageExtensions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using nanoFramework.Tools.Debugger.WireProtocol;
7 |
8 | namespace nanoFramework.Tools.Debugger.Extensions
9 | {
10 | public static class IncomingMessageExtensions
11 | {
12 | ///
13 | ///
14 | ///
15 | ///
16 | ///
17 | public static bool IsPositiveAcknowledge(this IncomingMessage message)
18 | {
19 | return message != null && ((message.Header.Flags & Flags.c_ACK) != 0);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Exceptions/NanoUserExitException.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | internal class NanoUserExitException : Exception
12 | {
13 | public NanoUserExitException()
14 | {
15 | }
16 |
17 | public NanoUserExitException(string message) : base(message)
18 | {
19 | }
20 |
21 | public NanoUserExitException(string message, Exception innerException) : base(message, innerException)
22 | {
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/EraseOptions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | [Flags]
12 | public enum EraseOptions
13 | {
14 | Deployment = 0x01,
15 | UserStorage = 0x02,
16 | FileSystem = 0x04,
17 | Firmware = 0x08,
18 | UpdateStorage = 0x10,
19 | SimpleStorage = 0x20,
20 | Configuration = 0x40,
21 |
22 | All = SimpleStorage | UpdateStorage | Firmware | FileSystem | UserStorage | Deployment | Configuration
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Exceptions/RemotedException.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | public class RemotedException
12 | {
13 | public string m_message;
14 | public RemotedException(Exception payload)
15 | {
16 | m_message = payload.Message;
17 | }
18 |
19 | public void Raise()
20 | {
21 | throw new Exception("Remote exception" + m_message);
22 | //throw new System.Runtime.Remoting.RemotingException(m_message);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Capabilities/Nxp.TargetCapabilities.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | /////////////////////////////////////////////////////////////////////////////////////////////////////////
9 | // !!! KEEP IN SYNC WITH platform_target_capabilities.h (in nf-interpreter inside the platform folder) //
10 | /////////////////////////////////////////////////////////////////////////////////////////////////////////
11 |
12 | public partial class Nxp
13 | {
14 | public enum TargetCapabilities : byte
15 | {
16 | // This platform has no declared target capabilities
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Capabilities/Esp32.TargetCapabilities.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | /////////////////////////////////////////////////////////////////////////////////////////////////////////
9 | // !!! KEEP IN SYNC WITH platform_target_capabilities.h (in nf-interpreter inside the platform folder) //
10 | /////////////////////////////////////////////////////////////////////////////////////////////////////////
11 |
12 | public partial class Esp32
13 | {
14 | public enum TargetCapabilities : byte
15 | {
16 | // This platform has no declared target capabilities
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/X509CaRootBundlePropertiesBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using PropertyChanged;
7 |
8 | namespace nanoFramework.Tools.Debugger
9 | {
10 | [AddINotifyPropertyChangedInterface]
11 | public partial class X509CaRootBundlePropertiesBase
12 | {
13 | private byte[] _certificate;
14 |
15 | public uint CertificateSize { get; set; }
16 |
17 | public byte[] Certificate
18 | {
19 | get => _certificate;
20 | set
21 | {
22 | _certificate = value;
23 | CertificateSize = (uint)value.Length;
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Capabilities/TICC32xx.TargetCapabilities.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | /////////////////////////////////////////////////////////////////////////////////////////////////////////
9 | // !!! KEEP IN SYNC WITH platform_target_capabilities.h (in nf-interpreter inside the platform folder) //
10 | /////////////////////////////////////////////////////////////////////////////////////////////////////////
11 |
12 | public partial class TiCC32xx
13 | {
14 | public enum TargetCapabilities : byte
15 | {
16 | // This platform has no declared target capabilities
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/DeviceConfigurationBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | public class DeviceConfigurationBase
10 | {
11 | public NetworkConfigurationBase[] NetworkConfigurations;
12 |
13 | public Wireless80211ConfigurationBase[] Wireless80211Configurations { get; internal set; }
14 |
15 | public WirelessAPConfigurationBase[] WirelessAPConfigurations { get; internal set; }
16 |
17 | public X509CaRootBundleBase[] X509CaRootBundle { get; internal set; }
18 |
19 | public X509DeviceCertificatesBase[] X509DeviceCertificates { get; internal set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Exceptions/DebugSessionAlreadyOpenException.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | internal class DebugSessionAlreadyOpenException : Exception
12 | {
13 | public DebugSessionAlreadyOpenException()
14 | {
15 | }
16 |
17 | public DebugSessionAlreadyOpenException(string message) : base(message)
18 | {
19 | }
20 |
21 | public DebugSessionAlreadyOpenException(string message, Exception innerException) : base(message, innerException)
22 | {
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/PortDefinitions/IPort.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System;
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | public interface IPort
9 | {
10 | ///
11 | /// Gets the Instance ID of the port that is unique among all ports
12 | /// (regardless of the type of port).
13 | ///
14 | string InstanceId { get; }
15 |
16 | int AvailableBytes { get; }
17 |
18 | int SendBuffer(byte[] buffer);
19 |
20 | byte[] ReadBuffer(int bytesToRead);
21 |
22 | ConnectPortResult ConnectDevice();
23 |
24 | void DisconnectDevice(bool force = false);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/X509DeviceCertificatesPropertiesBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using PropertyChanged;
7 |
8 | namespace nanoFramework.Tools.Debugger
9 | {
10 | [AddINotifyPropertyChangedInterface]
11 | public partial class X509DeviceCertificatesPropertiesBase
12 | {
13 | private byte[] _certificate;
14 |
15 | public uint CertificateSize { get; set; }
16 |
17 | public byte[] Certificate
18 | {
19 | get => _certificate;
20 | set
21 | {
22 | _certificate = value;
23 | CertificateSize = (uint)value.Length;
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Exceptions/NanoBooterConnectionFailureException.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | internal class NanoBooterConnectionFailureException : Exception
12 | {
13 | public NanoBooterConnectionFailureException()
14 | {
15 | }
16 |
17 | public NanoBooterConnectionFailureException(string message) : base(message)
18 | {
19 | }
20 |
21 | public NanoBooterConnectionFailureException(string message, Exception innerException) : base(message, innerException)
22 | {
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Exceptions/CouldntOpenNanoFrameworkDeviceException.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | internal class CouldntOpenNanoFrameworkDeviceException : Exception
12 | {
13 | public CouldntOpenNanoFrameworkDeviceException()
14 | {
15 | }
16 |
17 | public CouldntOpenNanoFrameworkDeviceException(string message) : base(message)
18 | {
19 | }
20 |
21 | public CouldntOpenNanoFrameworkDeviceException(string message, Exception innerException) : base(message, innerException)
22 | {
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Exceptions/NanoFrameworkDeviceNoResponseException.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | internal class NanoFrameworkDeviceNoResponseException : Exception
12 | {
13 | public NanoFrameworkDeviceNoResponseException()
14 | {
15 | }
16 |
17 | public NanoFrameworkDeviceNoResponseException(string message) : base(message)
18 | {
19 | }
20 |
21 | public NanoFrameworkDeviceNoResponseException(string message, Exception innerException) : base(message, innerException)
22 | {
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Extensions/DeploymentSectorExtensions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using nanoFramework.Tools.Debugger.WireProtocol;
7 | using System.Collections.Generic;
8 |
9 | namespace nanoFramework.Tools.Debugger.Extensions
10 | {
11 | public static class DeploymentSectorExtensions
12 | {
13 | public static List ToDeploymentBlockList(this List value)
14 | {
15 | List blocks = new List();
16 |
17 | foreach(DeploymentSector sector in value)
18 | {
19 | blocks.AddRange(sector.Blocks);
20 | }
21 |
22 | return blocks;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Runtime/ReflectionDefinition.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | public class ReflectionDefinition
10 | {
11 | public enum Kind : ushort
12 | {
13 | REFLECTION_INVALID = 0x00,
14 | REFLECTION_ASSEMBLY = 0x01,
15 | REFLECTION_TYPE = 0x02,
16 | REFLECTION_TYPE_DELAYED = 0x03,
17 | REFLECTION_CONSTRUCTOR = 0x04,
18 | REFLECTION_METHOD = 0x05,
19 | REFLECTION_FIELD = 0x06,
20 | };
21 |
22 | public ushort m_kind;
23 | public ushort m_levels;
24 |
25 | public uint m_raw;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/IController.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 | using System.Threading;
9 | using System.Threading.Tasks;
10 |
11 | namespace nanoFramework.Tools.Debugger.WireProtocol
12 | {
13 | public interface IController
14 | {
15 | DateTime LastActivity { get; }
16 |
17 | ushort GetNextSequenceId();
18 |
19 | void StopProcessing();
20 |
21 | void ResumeProcessing();
22 |
23 | uint GetUniqueEndpointId();
24 |
25 | CLRCapabilities Capabilities { get; set; }
26 |
27 | Converter CreateConverter();
28 |
29 | bool Send(MessageRaw raw);
30 |
31 | bool IsIdle();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Capabilities/Stm32.TargetCapabilities.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | /////////////////////////////////////////////////////////////////////////////////////////////////////////
9 | // !!! KEEP IN SYNC WITH platform_target_capabilities.h (in nf-interpreter inside the platform folder) //
10 | /////////////////////////////////////////////////////////////////////////////////////////////////////////
11 |
12 | public partial class Stm32
13 | {
14 | public enum TargetCapabilities : ulong
15 | {
16 | JtagUpdate = CLRCapabilities.Capability.TargetCapability_0,
17 |
18 | DfuUpdate = CLRCapabilities.Capability.TargetCapability_1,
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/NanoFrameworkDevices.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System;
5 | using System.Collections.ObjectModel;
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | public class NanoFrameworkDevices : ObservableCollection
10 | {
11 | private static readonly Lazy _instance =
12 | new Lazy(() => new NanoFrameworkDevices());
13 |
14 | public static NanoFrameworkDevices Instance
15 | {
16 | get
17 | {
18 | lock (_instance)
19 | {
20 | return _instance.Value;
21 | }
22 | }
23 | }
24 |
25 | private NanoFrameworkDevices() { }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/ThreadStatus.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using nanoFramework.Tools.Debugger.WireProtocol;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | public class ThreadStatus
12 | {
13 | public const uint STATUS_Ready = Commands.Debugging_Thread_Stack.Reply.TH_S_Ready;
14 | public const uint STATUS_Waiting = Commands.Debugging_Thread_Stack.Reply.TH_S_Waiting;
15 | public const uint STATUS_Terminated = Commands.Debugging_Thread_Stack.Reply.TH_S_Terminated;
16 |
17 | public const uint FLAGS_Suspended = Commands.Debugging_Thread_Stack.Reply.TH_F_Suspended;
18 |
19 | public uint m_pid;
20 | public uint m_flags;
21 | public uint m_status;
22 | public string[] m_calls;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Internal.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | public class RuntimeValue_Internal : RuntimeValue
10 | {
11 | protected internal RuntimeValue_Internal(Engine eng, WireProtocol.Commands.Debugging_Value handle) : base(eng, handle)
12 | {
13 | }
14 |
15 | public override bool IsReference { get { return false; } }
16 | public override bool IsNull { get { return false; } }
17 | public override bool IsPrimitive { get { return false; } }
18 | public override bool IsValueType { get { return false; } }
19 | public override bool IsArray { get { return false; } }
20 | public override bool IsReflection { get { return false; } }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_ValueType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | public class RuntimeValue_ValueType : RuntimeValue_Class
10 | {
11 | protected internal RuntimeValue_ValueType(Engine eng, WireProtocol.Commands.Debugging_Value handle) : base(eng, handle)
12 | {
13 | }
14 |
15 | public override bool IsReference { get { return false; } }
16 | public override bool IsNull { get { return false; } }
17 | public override bool IsPrimitive { get { return false; } }
18 | public override bool IsValueType { get { return true; } }
19 | public override bool IsArray { get { return false; } }
20 | public override bool IsReflection { get { return false; } }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/WirelessAPConfigurationPropertiesBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | ///
9 | /// Base class for wireless Access Point configuration properties.
10 | ///
11 | public partial class WirelessAPConfigurationPropertiesBase : WirelessConfigurationPropertiesBase
12 | {
13 | ///
14 | /// Channel for the network.
15 | ///
16 | public byte Channel { get; set; }
17 |
18 | ///
19 | /// Maximum number of connections allowed.
20 | ///
21 | public byte MaxConnections { get; set; }
22 |
23 | ///
24 | /// Configuration options for the network.
25 | ///
26 | public WirelessAP_ConfigurationOptions WirelessAPOptions { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Extensions/DeviceConfigurationExtensions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System.Collections.Generic;
7 |
8 | namespace nanoFramework.Tools.Debugger.Extensions
9 | {
10 | public static class DeviceConfigurationExtensions
11 | {
12 | public static bool ValidateIndex(this List collection, uint blockIndex)
13 | {
14 | // if collection has items, check if requested index is in range
15 | if (collection.Count > 0)
16 | {
17 | return (blockIndex < collection.Count);
18 | }
19 | else if (collection.Count == 0)
20 | {
21 | // if collection is empty and requested index is 0
22 | return (blockIndex == 0);
23 | }
24 | else
25 | {
26 | return false;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/PortSerial/SerialDeviceInformation.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 |
8 |
9 | namespace nanoFramework.Tools.Debugger.Serial
10 | {
11 | public class SerialDeviceInformation
12 | {
13 | private readonly string _deviceSelector;
14 |
15 | public string InstanceId
16 | {
17 | get
18 | {
19 | return _deviceSelector;
20 | }
21 | }
22 |
23 | ///
24 | /// The class is mainly used as a DeviceInformation wrapper so that the UI can bind to a list of these.
25 | ///
26 | ///
27 | /// The AQS used to find this device
28 | public SerialDeviceInformation(String deviceSelector)
29 | {
30 | _deviceSelector = deviceSelector;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/X509CaRootBundleBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | public class X509CaRootBundleBase
9 | {
10 | ///
11 | /// This is the marker placeholder for this configuration block
12 | /// 4 bytes length.
13 | ///
14 | public byte[] Marker;
15 |
16 | ///
17 | /// Size of the certificate.
18 | ///
19 | public uint CertificateSize;
20 |
21 | ///
22 | /// Certificate
23 | ///
24 | public byte[] Certificate;
25 |
26 | public X509CaRootBundleBase()
27 | {
28 | // need to init these here to match the expected size on the struct to be sent to the device
29 | Marker = new byte[4];
30 | Certificate = new byte[64];
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/NetworkInformation/AddressMode.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | public enum AddressMode : byte
9 | {
10 | ////////////////////////////////////////////////////////////////////////////////////
11 | // NEED TO KEEP THESE IN SYNC WITH native 'AddressMode' enum in nanoHAL_Network.h //
12 | ////////////////////////////////////////////////////////////////////////////////////
13 |
14 | ///
15 | /// Invalid state.
16 | ///
17 | Invalid = 0,
18 |
19 | ///
20 | /// IP address from DHCP.
21 | ///
22 | DHCP = 1,
23 |
24 | ///
25 | /// Static IP address.
26 | ///
27 | Static = 2,
28 |
29 | ///
30 | /// Auto IP.
31 | ///
32 | AutoIP = 3,
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/X509DeviceCertificatesBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | public class X509DeviceCertificatesBase
9 | {
10 | ///
11 | /// This is the marker placeholder for this configuration block
12 | /// 4 bytes length.
13 | ///
14 | public byte[] Marker;
15 |
16 | ///
17 | /// Size of the certificate.
18 | ///
19 | public uint CertificateSize;
20 |
21 | ///
22 | /// Certificate
23 | ///
24 | public byte[] Certificate;
25 |
26 | public X509DeviceCertificatesBase()
27 | {
28 | // need to init these here to match the expected size on the struct to be sent to the device
29 | Marker = new byte[4];
30 | Certificate = new byte[64];
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/AppDomainInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using nanoFramework.Tools.Debugger.WireProtocol;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | class AppDomainInfo : IAppDomainInfo
12 | {
13 | private readonly uint m_id;
14 | readonly Commands.Debugging_Resolve_AppDomain.Reply m_reply;
15 |
16 | public AppDomainInfo(uint id, Commands.Debugging_Resolve_AppDomain.Reply reply)
17 | {
18 | m_id = id;
19 | m_reply = reply;
20 | }
21 |
22 | public string Name
23 | {
24 | get { return m_reply.Name; }
25 | }
26 |
27 | public uint ID
28 | {
29 | get { return m_id; }
30 | }
31 |
32 | public uint[] AssemblyIndices
33 | {
34 | get { return m_reply.m_data; }
35 | }
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_ByRef.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | public class RuntimeValue_ByRef : RuntimeValue_Indirect
12 | {
13 | protected internal RuntimeValue_ByRef(Engine eng, WireProtocol.Commands.Debugging_Value[] array, int pos) : base(eng, array, pos)
14 | {
15 | if (m_value == null && m_handle.m_arrayref_referenceID != 0)
16 | {
17 | m_value = m_eng.GetArrayElement(m_handle.m_arrayref_referenceID, m_handle.m_arrayref_index);
18 | }
19 |
20 | if (m_value == null)
21 | {
22 | throw new ArgumentException();
23 | }
24 | }
25 |
26 | public override bool IsReference { get { return true; } }
27 | public override bool IsNull { get { return m_value.IsNull; } }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Extensions/DeviceInformationExtensions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 |
7 | namespace nanoFramework.Tools.Debugger.Extensions
8 | {
9 | public static class DeviceInformationExtensions
10 | {
11 | // TODO
12 | //public static string GetSerialNumber(this DeviceInformation value)
13 | //{
14 | // // typical ID string is \\?\USB#VID_0483&PID_5740#NANO_3267335D#{86e0d1e0-8089-11d0-9ce4-08003e301f73}
15 |
16 | // int startIndex = value.Id.IndexOf("USB");
17 |
18 | // int endIndex = value.Id.LastIndexOf("#");
19 |
20 | // // sanity check
21 | // if(startIndex < 0 || endIndex < 0)
22 | // {
23 | // return null;
24 | // }
25 |
26 | // // get device ID portion
27 | // var deviceIDCollection = value.Id.Substring(startIndex, endIndex - startIndex).Split('#');
28 |
29 | // return deviceIDCollection?.GetValue(2) as string;
30 | //}
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) .NET Foundation and Contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/nanoFramework.Tools.DebugLibrary.Shared.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 31472cae-4b1a-4ab9-9b2a-8f28dbe01bcf
5 | 16.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Extensions/CancellationTokenExtensions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 | using System.Threading;
8 |
9 | namespace nanoFramework.Tools.Debugger.Extensions
10 | {
11 | static class CancellationTokenExtensions
12 | {
13 | ///
14 | /// Links cancellation token source with a set timeout cancellation token.
15 | ///
16 | ///
17 | /// Timeout to link with cancelation token.
18 | /// A linked cancellation token.
19 | public static CancellationToken AddTimeout(this CancellationToken cancellationToken, TimeSpan timeout)
20 | {
21 | var timeoutCancellatioToken = new CancellationTokenSource(timeout).Token;
22 | timeoutCancellatioToken.ThrowIfCancellationRequested();
23 | return CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCancellatioToken).Token;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/ConnectPortResult.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace nanoFramework.Tools.Debugger
5 | {
6 | public enum ConnectPortResult
7 | {
8 | ///
9 | /// No result set for the connect port.
10 | ///
11 | None,
12 |
13 | ///
14 | /// Port connected successfully.
15 | ///
16 | Connected,
17 |
18 | ///
19 | /// Couldn't connect to the specified port.
20 | ///
21 | NotConnected,
22 |
23 | ///
24 | /// Connection to the specified port is not authorized
25 | ///
26 | Unauthorized,
27 |
28 | ///
29 | /// Exception occurred when attempting to connect to the specified port.
30 | ///
31 | ExceptionOccurred,
32 |
33 | ///
34 | /// Exclusive access to the device was not granted.
35 | ///
36 | NoExclusiveAccess
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/USB Test App WPF/ViewModel/ViewModelLocator.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using CommunityToolkit.Mvvm.DependencyInjection;
7 | using Microsoft.Extensions.DependencyInjection;
8 | using Serial_Test_App_WPF.ViewModel;
9 |
10 | namespace Serial_Test_App_WPF.ViewModel
11 | {
12 | public class ViewModelLocator
13 | {
14 | private static bool _isConfigured = false;
15 | private static readonly object _lock = new object();
16 |
17 | public ViewModelLocator()
18 | {
19 | if (!_isConfigured)
20 | {
21 | lock (_lock)
22 | {
23 | if (!_isConfigured)
24 | {
25 | Ioc.Default.ConfigureServices(
26 | new ServiceCollection()
27 | .AddSingleton()
28 | .BuildServiceProvider());
29 | _isConfigured = true;
30 | }
31 | }
32 | }
33 | }
34 |
35 | public MainViewModel Main => Ioc.Default.GetService();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Message.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using nanoFramework.Tools.Debugger.WireProtocol;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | internal class Message
12 | {
13 | internal readonly EndPoint m_source;
14 | internal readonly Commands.Debugging_Messaging_Address m_addr;
15 | internal readonly byte[] m_payload;
16 |
17 | internal Message(EndPoint source, Commands.Debugging_Messaging_Address addr, byte[] payload)
18 | {
19 | m_source = source;
20 | m_addr = addr;
21 | m_payload = payload;
22 | }
23 |
24 | public object Payload
25 | {
26 | get
27 | {
28 | return m_source._engine.CreateBinaryFormatter().Deserialize(m_payload);
29 | }
30 | }
31 |
32 | public void Reply(object data)
33 | {
34 | byte[] payload = m_source._engine.CreateBinaryFormatter().Serialize(data);
35 | m_source.ReplyInner(this, payload);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/MessageWithProgress.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | public class MessageWithProgress : IProgress
12 | {
13 | private readonly Action startMessageWithProgress;
14 |
15 | public MessageWithProgress(Action startMessageWithProgress)
16 | {
17 | this.startMessageWithProgress = startMessageWithProgress;
18 | }
19 |
20 | public MessageWithProgress(string message, uint current = 100, uint total = 100)
21 | {
22 | Current = current;
23 | Total = total;
24 | Message = message;
25 | }
26 |
27 |
28 | public uint Current { get; private set; }
29 | public uint Total { get; private set; }
30 | public string Message { get; private set; }
31 |
32 |
33 | public void Report(MessageWithProgress value)
34 | {
35 | startMessageWithProgress(Message, Current, Total);
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/MessageCall.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | //using System.Runtime.Remoting.Messaging;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | internal class MessageCall
12 | {
13 | public readonly string Name;
14 | public readonly object[] Args;
15 |
16 | public MessageCall(string name, object[] args)
17 | {
18 | Name = name;
19 | Args = args;
20 | }
21 |
22 | //public static MessageCall CreateFromIMethodMessage(IMethodMessage message)
23 | //{
24 | // return new MessageCall(message.MethodName, message.Args);
25 | //}
26 |
27 | public object CreateMessagePayload()
28 | {
29 | return new object[] { Name, Args };
30 | }
31 |
32 | public static MessageCall CreateFromMessagePayload(object payload)
33 | {
34 | object[] data = (object[])payload;
35 | string name = (string)data[0];
36 | object[] args = (object[])data[1];
37 |
38 | return new MessageCall(name, args);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Class.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | public class RuntimeValue_Class : RuntimeValue
10 | {
11 | protected internal RuntimeValue_Class(Engine eng, WireProtocol.Commands.Debugging_Value handle) : base(eng, handle)
12 | {
13 | }
14 |
15 | public override bool IsReference { get { return false; } }
16 | public override bool IsNull { get { return false; } }
17 | public override bool IsPrimitive { get { return false; } }
18 | public override bool IsValueType { get { return false; } }
19 | public override bool IsArray { get { return false; } }
20 | public override bool IsReflection { get { return false; } }
21 |
22 | public override uint NumOfFields
23 | {
24 | get
25 | {
26 | return m_handle.m_size - 1;
27 | }
28 | }
29 |
30 | public override RuntimeValue GetField(uint offset, uint fd)
31 | {
32 | return m_eng.GetFieldValue(this, offset, fd);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/RebootOptions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | ///
12 | /// Reboot options for nanoFramework device.
13 | ///
14 | [Flags]
15 | public enum RebootOptions
16 | {
17 | ///
18 | /// Hard reboot CPU.
19 | ///
20 | #pragma warning disable S2346 // Need this to be 0 because of native implementation
21 | NormalReboot = 0,
22 | #pragma warning restore S2346 // Flags enumerations zero-value members should be named "None"
23 |
24 | ///
25 | /// Reboot and enter nanoBooter.
26 | ///
27 | EnterNanoBooter = 1,
28 |
29 | ///
30 | /// Reboot CLR only.
31 | ///
32 | ClrOnly = 2,
33 |
34 | ///
35 | /// Wait for debugger.
36 | ///
37 | WaitForDebugger = 4,
38 |
39 | ///
40 | /// Reboot and enter proprietary bootloader.
41 | ///
42 | EnterProprietaryBooter = 8,
43 | };
44 | }
45 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/INanoFrameworkDeviceInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System.Collections.Generic;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | public interface INanoFrameworkDeviceInfo
12 | {
13 | bool Valid { get; }
14 | System.Version HalBuildVersion { get; }
15 | string HalBuildInfo { get; }
16 | byte OEM { get; }
17 | byte Model { get; }
18 | ushort SKU { get; }
19 | string TargetName { get; }
20 | string Platform { get; }
21 | string ModuleSerialNumber { get; }
22 | string SystemSerialNumber { get; }
23 | System.Version ClrBuildVersion { get; }
24 | string ClrBuildInfo { get; }
25 | System.Version TargetFrameworkVersion { get; }
26 | System.Version SolutionBuildVersion { get; }
27 | string SolutionBuildInfo { get; }
28 | IAppDomainInfo[] AppDomains { get; }
29 | IAssemblyInfo[] Assemblies { get; }
30 | List NativeAssemblies { get; }
31 | byte PlatformCapabilities { get; }
32 | byte TargetCapabilities { get; }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/SupportedUSBDevices/STM_Discovery4.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 |
8 | namespace nanoFramework.Tools.Debugger.Usb
9 | {
10 | // This class is kept here for reference only.
11 | // It was to provide backwards compatibility with NETMF WinUSB devices of v4.4
12 | // In the current nanoFramework implementation USB connection with devices is carried using USB CDC
13 |
14 | public class STM_Discovery4
15 | {
16 | public const UInt16 DeviceVid = 0x0483;
17 |
18 | public const UInt16 DevicePid = 0xA08F;
19 |
20 | ///
21 | /// USB device interface class GUID. For NETMF debug capable devices this must be {D32D1D64-963D-463E-874A-8EC8C8082CBF}.
22 | ///
23 | public static Guid DeviceInterfaceClass = new Guid("{D32D1D64-963D-463E-874A-8EC8C8082CBF}");
24 |
25 | ///
26 | /// ID string for the device
27 | ///
28 | public static String IDString
29 | {
30 | get { return String.Format("VID_{0:X4}&PID_{1:X4}", DeviceVid, DevicePid); }
31 | }
32 |
33 | public static new string ToString()
34 | {
35 | return "ST Discovery4";
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Packet.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 | using System.Text;
9 |
10 | namespace nanoFramework.Tools.Debugger.WireProtocol
11 | {
12 | [Serializable]
13 | public class Packet
14 | {
15 | #pragma warning disable S1104 // Fields should not have public accessibility
16 | // this is required because of the way the de-serialization works in Wire Protocol
17 |
18 | public readonly static string MARKER_DEBUGGER_V1 = "NFDBGV1\0"; // Used to identify the debugger at boot time.
19 | public readonly static string MARKER_PACKET_V1 = "NFPKTV1\0"; // Used to identify the start of a packet.
20 | public const int SIZE_OF_MARKER = 8;
21 |
22 | public byte[] Marker = Encoding.UTF8.GetBytes(MARKER_PACKET_V1);
23 | public uint CrcHeader = 0;
24 | public uint CrcData = 0;
25 |
26 | public uint Cmd = 0;
27 | public ushort Seq = 0;
28 | public ushort SeqReply = 0;
29 | public uint Flags = 0;
30 | public uint Size = 0;
31 |
32 | #pragma warning restore S1104 // Fields should not have public accessibility
33 |
34 | public Packet()
35 | {
36 |
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Array.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | public class RuntimeValue_Array : RuntimeValue
10 | {
11 | protected internal RuntimeValue_Array(Engine eng, WireProtocol.Commands.Debugging_Value handle) : base(eng, handle)
12 | {
13 | }
14 |
15 | public override bool IsReference { get { return false; } }
16 | public override bool IsNull { get { return false; } }
17 | public override bool IsPrimitive { get { return false; } }
18 | public override bool IsValueType { get { return false; } }
19 | public override bool IsArray { get { return true; } }
20 | public override bool IsReflection { get { return false; } }
21 |
22 | public override RuntimeValue GetElement(uint index)
23 | {
24 | return m_eng.GetArrayElement(m_handle.m_referenceID, index);
25 | }
26 |
27 | public override uint Length { get { return m_handle.m_array_numOfElements; } }
28 | public override uint Depth { get { return m_handle.m_array_depth; } }
29 | public override uint Type { get { return m_handle.m_array_typeIndex; } }
30 |
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Flags.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger.WireProtocol
8 | {
9 | public class Flags
10 | {
11 | ///
12 | /// Constant for empty flags.
13 | ///
14 | public const ushort c_NoFlags = 0;
15 |
16 | public const ushort c_NonCritical = 0x0001; // This doesn't need an acknowledge.
17 | public const ushort c_Reply = 0x0002; // This is the result of a command.
18 | public const ushort c_BadHeader = 0x0004;
19 | public const ushort c_BadPayload = 0x0008;
20 | public const ushort c_Spare0010 = 0x0010;
21 | public const ushort c_Spare0020 = 0x0020;
22 | public const ushort c_Spare0040 = 0x0040;
23 | public const ushort c_Spare0080 = 0x0080;
24 | public const ushort c_Spare0100 = 0x0100;
25 | public const ushort c_Spare0200 = 0x0200;
26 | public const ushort c_Spare0400 = 0x0400;
27 | public const ushort c_Spare0800 = 0x0800;
28 | public const ushort c_Spare1000 = 0x1000;
29 | public const ushort c_NoCaching = 0x2000;
30 | public const ushort c_NACK = 0x4000;
31 | public const ushort c_ACK = 0x8000;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/NetworkInformation/RadioType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System.ComponentModel;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | /////////////////////////////////////////////////////////////////////////////////////////////////////
12 | // !!! KEEP IN SYNC WITH System.Net.NetworkInformation.RadioType (in nanoFramework.System.Net) !!! //
13 | /////////////////////////////////////////////////////////////////////////////////////////////////////
14 |
15 | ///
16 | /// Radio type for the Wireless network interface.
17 | ///
18 | public enum RadioType : byte
19 | {
20 | ///
21 | /// 802.11a-compatible radio.
22 | ///
23 | [Description("802.11a")]
24 | _802_11a = 1,
25 |
26 | ///
27 | /// 802.11b-compatible radio.
28 | ///
29 | [Description("802.11b")]
30 | _802_11b = 2,
31 |
32 | ///
33 | /// 802.11g-compatible radio.
34 | ///
35 | [Description("802.11g")]
36 | _802_11g = 4,
37 |
38 | ///
39 | /// 802.11n-compatible radio.
40 | ///
41 | [Description("802.11n")]
42 | _802_11n = 8,
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/NetworkConfigurationPropertiesBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using PropertyChanged;
7 | using System.Net;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | [AddINotifyPropertyChangedInterface]
12 | public partial class NetworkConfigurationPropertiesBase
13 | {
14 | public IPAddress IPv4Address { get; set; }
15 | public IPAddress IPv4DNSAddress1 { get; set; }
16 | public IPAddress IPv4DNSAddress2 { get; set; }
17 | public IPAddress IPv4GatewayAddress { get; set; }
18 | public IPAddress IPv4NetMask { get; set; }
19 | public IPAddress IPv6Address { get; set; }
20 | public IPAddress IPv6DNSAddress1 { get; set; }
21 | public IPAddress IPv6DNSAddress2 { get; set; }
22 | public IPAddress IPv6GatewayAddress { get; set; }
23 | public IPAddress IPv6NetMask { get; set; }
24 | public byte[] MacAddress { get; set; }
25 | public NetworkInterfaceType InterfaceType { get; set; }
26 | public AddressMode StartupAddressMode { get; set; }
27 | public uint? SpecificConfigId { get; set; }
28 | public bool AutomaticDNS { get; set; }
29 |
30 | public NetworkConfigurationPropertiesBase()
31 | {
32 | MacAddress = new byte[] { 0, 0, 0, 0, 0, 0 };
33 | InterfaceType = NetworkInterfaceType.Ethernet;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/PortTcpIp/NanoNetworkDevice.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 | using System.Net.Sockets;
8 |
9 | namespace nanoFramework.Tools.Debugger.PortTcpIp
10 | {
11 | public class NanoNetworkDevice: IDisposable
12 | {
13 | private NetworkStream _networkStream;
14 |
15 | private TcpClient _networkClient;
16 |
17 | public const int SafeDefaultTimeout = 1000;
18 |
19 | public bool Connected => _networkClient?.Connected == true;
20 |
21 | public int AvailableBytes => _networkClient?.Connected == true ? _networkClient.Available : -1;
22 |
23 | public NetworkDeviceInformation NetworkDeviceInformation { get; set; }
24 |
25 | public NetworkStream Connect()
26 | {
27 | if(_networkClient?.Connected == true)
28 | return _networkStream;
29 |
30 | _networkClient = new TcpClient(NetworkDeviceInformation.Host, NetworkDeviceInformation.Port);
31 | _networkStream = _networkClient.GetStream();
32 | return _networkStream;
33 | }
34 |
35 | public void Close()
36 | {
37 | _networkStream?.Close();
38 | _networkClient?.Close();
39 | }
40 |
41 | public void Dispose()
42 | {
43 | _networkStream?.Dispose();
44 | _networkClient?.Dispose();
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/PortDefinitions/DeviceWatcherStatus.cs:
--------------------------------------------------------------------------------
1 | namespace nanoFramework.Tools.Debugger
2 | {
3 | public enum DeviceWatcherStatus
4 | {
5 | ///
6 | /// The watcher has aborted operation. No subsequent events will be raised.
7 | ///
8 | Aborted = 5,
9 |
10 | ///
11 | /// This is the initial state of a Watcher object. During this state clients can register event handlers.
12 | ///
13 | Created = 0,
14 |
15 | ///
16 | /// The watcher has completed enumerating the initial collection. Items can still be added, updated or removed from the collection.
17 | ///
18 | EnumerationCompleted = 2,
19 |
20 | ///
21 | /// The watcher transitions to the Started state once Start is called. The watcher is enumerating the initial collection. Note that during this enumeration phase it is possible to receive Updated and Removed notifications but only to items that have already been Added.
22 | ///
23 | Started = 1,
24 |
25 | ///
26 | /// The client has called Stop and the watcher has completed all outstanding events. No further events will be raised.
27 | ///
28 | Stopped = 4,
29 |
30 | ///
31 | /// The client has called Stop and the watcher is still in the process of stopping. Events may still be raised.
32 | ///
33 | Stopping = 3
34 |
35 | }
36 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/DeviceConfiguration.X509CaRootBundleProperties.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System.Text;
7 |
8 | namespace nanoFramework.Tools.Debugger
9 | {
10 | public partial class DeviceConfiguration
11 | {
12 | public partial class X509CaRootBundleProperties : X509CaRootBundlePropertiesBase
13 | {
14 | public bool IsUnknown { get; set; }
15 |
16 | public X509CaRootBundleProperties()
17 | {
18 | }
19 |
20 | public X509CaRootBundleProperties(X509CaRootBundleBase certificate)
21 | {
22 | CertificateSize = (uint)certificate.Certificate.Length;
23 | Certificate = certificate.Certificate;
24 |
25 | // reset unknown flag
26 | IsUnknown = false;
27 | }
28 |
29 | // operator to allow casting a X509CaRootBundleProperties object to X509CaRootBundleBase
30 | public static explicit operator X509CaRootBundleBase(X509CaRootBundleProperties value)
31 | {
32 | var x509Certificate = new X509CaRootBundleBase()
33 | {
34 | Marker = Encoding.UTF8.GetBytes(MarkerConfigurationX509CaRootBundle_v1),
35 |
36 | CertificateSize = (uint)value.Certificate.Length,
37 | Certificate = value.Certificate,
38 | };
39 |
40 | return x509Certificate;
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/TypeSysLookup.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System.Collections.Generic;
8 |
9 | namespace nanoFramework.Tools.Debugger.WireProtocol
10 | {
11 | internal class TypeSysLookup
12 | {
13 | public enum Type : uint
14 | {
15 | Type,
16 | Method,
17 | Field
18 | }
19 |
20 | private Dictionary m_lookup;
21 |
22 | private void EnsureHashtable()
23 | {
24 | lock (this)
25 | {
26 | if (m_lookup == null)
27 | {
28 | m_lookup = new Dictionary();
29 | }
30 | }
31 | }
32 |
33 | private ulong KeyFromTypeToken(Type type, uint token)
34 | {
35 | return ((ulong)type) << 32 | token;
36 | }
37 |
38 | public object Lookup(Type type, uint token)
39 | {
40 | EnsureHashtable();
41 |
42 | ulong key = KeyFromTypeToken(type, token);
43 |
44 | // need to use a try method because the key may not exist
45 | m_lookup.TryGetValue(key, out object typeValue);
46 |
47 | return typeValue;
48 | }
49 |
50 | public void Add(Type type, uint token, object val)
51 | {
52 | EnsureHashtable();
53 |
54 | ulong key = KeyFromTypeToken(type, token);
55 |
56 | m_lookup[key] = val;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/DeviceConfiguration.X509DeviceCertificatesProperties.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System.Text;
7 |
8 | namespace nanoFramework.Tools.Debugger
9 | {
10 | public partial class DeviceConfiguration
11 | {
12 | public partial class X509DeviceCertificatesProperties : X509DeviceCertificatesPropertiesBase
13 | {
14 | public bool IsUnknown { get; set; }
15 |
16 | public X509DeviceCertificatesProperties()
17 | {
18 | }
19 |
20 | public X509DeviceCertificatesProperties(X509DeviceCertificatesBase certificate)
21 | {
22 | CertificateSize = (uint)certificate.Certificate.Length;
23 | Certificate = certificate.Certificate;
24 |
25 | // reset unknown flag
26 | IsUnknown = false;
27 | }
28 |
29 | // operator to allow casting a X509DeviceCertificatesProperties object to X509DeviceCertificatesBase
30 | public static explicit operator X509DeviceCertificatesBase(X509DeviceCertificatesProperties value)
31 | {
32 | var x509Certificate = new X509DeviceCertificatesBase()
33 | {
34 | Marker = Encoding.UTF8.GetBytes(MarkerConfigurationX509DeviceCertificate_v1),
35 |
36 | CertificateSize = (uint)value.Certificate.Length,
37 | Certificate = value.Certificate,
38 | };
39 |
40 | return x509Certificate;
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/AssemblyInfoFromResolveAssembly.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using nanoFramework.Tools.Debugger.WireProtocol;
8 | using System.Collections.Generic;
9 |
10 | namespace nanoFramework.Tools.Debugger
11 | {
12 | class AssemblyInfoFromResolveAssembly : IAssemblyInfo
13 | {
14 | private readonly Commands.DebuggingResolveAssembly _dra;
15 | private readonly List _appDomains = new List();
16 |
17 | public AssemblyInfoFromResolveAssembly(Commands.DebuggingResolveAssembly dra)
18 | {
19 | _dra = dra;
20 | }
21 |
22 | public string Name
23 | {
24 | get { return _dra.Result.Name; }
25 | }
26 |
27 | public System.Version Version
28 | {
29 | get
30 | {
31 | Commands.DebuggingResolveAssembly.Version version = _dra.Result.Version;
32 | return new System.Version(version.MajorVersion, version.MinorVersion, version.BuildNumber, version.RevisionNumber);
33 | }
34 | }
35 |
36 | public uint Index
37 | {
38 | get { return _dra.Idx; }
39 | }
40 |
41 | public List InAppDomains
42 | {
43 | get { return _appDomains; }
44 | }
45 |
46 | public void AddDomain(IAppDomainInfo adi)
47 | {
48 | if (adi != null)
49 | {
50 | _appDomains.Add(adi);
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/IncomingMessage.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger.WireProtocol
8 | {
9 | public class IncomingMessage
10 | {
11 | readonly IController _parent;
12 |
13 | readonly MessageRaw _raw;
14 | readonly MessageBase _base;
15 |
16 | public IncomingMessage(IController parent, MessageRaw raw, MessageBase messageBase)
17 | {
18 | _parent = parent;
19 | _raw = raw;
20 | _base = messageBase;
21 | }
22 |
23 | public MessageRaw Raw => _raw;
24 |
25 | public MessageBase Base => _base;
26 |
27 | public IController Parent => _parent;
28 |
29 | public Packet Header => _base.Header;
30 |
31 | public object Payload
32 | {
33 | get
34 | {
35 | return _base.Payload;
36 | }
37 | set
38 | {
39 | object payload = null;
40 |
41 | if (_raw.Payload != null)
42 | {
43 | if (value != null)
44 | {
45 | new Converter(_parent.Capabilities).Deserialize(value, _raw.Payload);
46 | payload = value;
47 | }
48 | else
49 | {
50 | payload = _raw.Payload.Clone();
51 | }
52 | }
53 |
54 | _base.Payload = payload;
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/NetworkInformation/NetworkInterfaceType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System.ComponentModel;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
12 | // !!! KEEP IN SYNC WITH System.Net.NetworkInformation.NetworkInterfaceType (in nanoFramework.System.Net) !!! //
13 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
14 | ///
15 | /// Network interface type.
16 | ///
17 | public enum NetworkInterfaceType : byte
18 | {
19 | ///
20 | /// The network interface type is unknown or not specified.
21 | ///
22 | [Description("")]
23 | Unknown = 1,
24 |
25 | ///
26 | /// The network interface uses an Ethernet connection. Ethernet is defined in IEEE standard 802.3.
27 | ///
28 | [Description("Ethernet")]
29 | Ethernet = 6,
30 |
31 | ///
32 | /// The network interface uses a wireless LAN connection (IEEE 802.11 standard).
33 | ///
34 | [Description("Wi-Fi (802.11)")]
35 | Wireless80211 = 71,
36 |
37 |
38 | ///
39 | /// The network interface uses a wireless Soft AP connection (IEEE 802.11 standard).
40 | ///
41 | [Description("Wi-Fi Access Point (802.11)")]
42 | WirelessAP = 72,
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/DeviceConfigurationOption.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | public partial class DeviceConfiguration
9 | {
10 | ///
11 | /// Device configuration option
12 | ///
13 | public enum DeviceConfigurationOption : byte
14 | {
15 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 | // NEED TO KEEP THESE IN SYNC WITH native 'DeviceConfigurationOption' enum in nanoHAL_ConfigurationManager.h //
17 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
18 |
19 | ///
20 | /// Network configuration block
21 | ///
22 | Network = 1,
23 |
24 | ///
25 | /// Wireless Network configuration block
26 | ///
27 | Wireless80211Network = 2,
28 |
29 | ///
30 | /// Wireless Network as AP configuration block
31 | ///
32 | WirelessNetworkAP = 3,
33 |
34 | ///
35 | /// X509 Certificate block
36 | ///
37 | X509Certificate = 4,
38 |
39 | ///
40 | /// X509 Device Certificates
41 | ///
42 | X509DeviceCertificates = 5,
43 |
44 | ///
45 | /// All configuration blocks
46 | ///
47 | All = 255,
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Reflection.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | public class RuntimeValue_Reflection : RuntimeValue
12 | {
13 | private readonly ReflectionDefinition m_rd;
14 |
15 | protected internal RuntimeValue_Reflection(Engine eng, WireProtocol.Commands.Debugging_Value handle) : base(eng, handle)
16 | {
17 | m_rd = (ReflectionDefinition)Activator.CreateInstance((typeof(ReflectionDefinition)));
18 |
19 | m_eng.CreateConverter().Deserialize(m_rd, handle.m_builtinValue);
20 | }
21 |
22 | public override bool IsReference { get { return false; } }
23 | public override bool IsNull { get { return false; } }
24 | public override bool IsPrimitive { get { return false; } }
25 | public override bool IsValueType { get { return false; } }
26 | public override bool IsArray { get { return false; } }
27 | public override bool IsReflection { get { return true; } }
28 |
29 | public ReflectionDefinition.Kind ReflectionType
30 | {
31 | get
32 | {
33 | return (ReflectionDefinition.Kind)m_rd.m_kind;
34 | }
35 | }
36 |
37 | public ushort ArrayDepth
38 | {
39 | get
40 | {
41 | return m_rd.m_levels;
42 | }
43 | }
44 |
45 | public uint ReflectionIndex
46 | {
47 | get
48 | {
49 | return m_rd.m_raw;
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/WirelessConfigurationPropertiesBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using PropertyChanged;
7 |
8 | namespace nanoFramework.Tools.Debugger
9 | {
10 | ///
11 | /// Base class for common wireless configuration properties.
12 | ///
13 | [AddINotifyPropertyChangedInterface]
14 | public partial class WirelessConfigurationPropertiesBase
15 | {
16 | ///
17 | /// Id of the configuration.
18 | ///
19 | public uint Id { get; set; }
20 |
21 | ///
22 | /// Authentication type for the network.
23 | ///
24 | public AuthenticationType Authentication { get; set; }
25 |
26 | ///
27 | /// Encryption type for the network.
28 | ///
29 | public EncryptionType Encryption { get; set; }
30 |
31 | ///
32 | /// Radio type for the network.
33 | ///
34 | public RadioType Radio { get; set; }
35 |
36 | ///
37 | /// SSID of the network.
38 | ///
39 | /// Maximum allowed length for network password is 32.
40 | public string Ssid { get; set; }
41 |
42 | ///
43 | /// Password for the network.
44 | ///
45 | /// Maximum allowed length for network password is 64
46 | public string Password { get; set; }
47 |
48 | ///
49 | /// Configuration options for the network.
50 | ///
51 | public Wireless80211_ConfigurationOptions Wireless80211Options { get; set; }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/NetworkInformation/WirelessAP_ConfigurationOptions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 | using System.ComponentModel;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
12 | // !!! KEEP IN SYNC WITH System.Net.NetworkInformation.WirelessAPConfiguration.ConfigurationOptions (in nanoFramework.System.Net) !!! //
13 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
14 |
15 | ///
16 | /// Configuration flags used for Wireless Soft AP configuration.
17 | ///
18 | [Flags]
19 | public enum WirelessAP_ConfigurationOptions : byte
20 | {
21 | ///
22 | /// No option set.
23 | ///
24 | None = 0,
25 |
26 | ///
27 | /// Disables the Wireless Soft AP.
28 | ///
29 | Disable = 0x01,
30 |
31 | ///
32 | /// Enables the Wireless Soft AP.
33 | /// If not set the Wireless Soft AP is disabled.
34 | ///
35 | Enable = 0x02,
36 |
37 | ///
38 | /// Will automatically start the Soft AP when CLR starts.
39 | /// This option forces enabling the Wireless Soft AP.
40 | ///
41 | [Description("Auto start")]
42 | AutoStart = 0x04 | Enable,
43 |
44 | ///
45 | /// The SSID for the Soft AP will be hidden.
46 | ///
47 | [Description("SSID hidden")]
48 | HiddenSSID = 0x08,
49 | };
50 | }
51 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/NetworkInformation/Wireless80211_ConfigurationOptions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 | using System.ComponentModel;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
12 | // !!! KEEP IN SYNC WITH System.Net.NetworkInformation.Wireless80211Configuration.ConfigurationOptions (in nanoFramework.System.Net) !!! //
13 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
14 |
15 | ///
16 | /// Configuration flags used for Wireless configuration.
17 | ///
18 | [Flags]
19 | public enum Wireless80211_ConfigurationOptions : byte
20 | {
21 | ///
22 | /// No option set.
23 | ///
24 | None = 0,
25 |
26 | ///
27 | /// Disables the Wireless station.
28 | ///
29 | Disable = 0x01,
30 |
31 | ///
32 | /// Enables the Wireless station.
33 | /// If not set the wireless station is disabled.
34 | ///
35 | Enable = 0x02,
36 |
37 | ///
38 | /// Will auto connect when AP is available or after being disconnected.
39 | /// This option forces enabling the Wireless station.
40 | ///
41 | [Description("Auto connect")]
42 | AutoConnect = 0x04 | Enable,
43 |
44 | ///
45 | /// Enables SmartConfig (if available) for this Wireless station.
46 | /// This option forces enabling the Wireless station.
47 | ///
48 | SmartConfig = 0x08 | Enable,
49 | };
50 | }
51 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/ArrayEqualityComparer.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Threading;
9 | using System.Threading.Tasks;
10 |
11 | namespace nanoFramework.Tools.Debugger
12 | {
13 | public sealed class ArrayEqualityComparer : IEqualityComparer
14 | {
15 | public bool Equals(
16 | T[] x,
17 | T[] y)
18 | {
19 | if (x is null)
20 | {
21 | throw new ArgumentNullException(nameof(x));
22 | }
23 |
24 | if (y is null)
25 | {
26 | throw new ArgumentNullException(nameof(y));
27 | }
28 |
29 | var elementComparer = EqualityComparer.Default;
30 |
31 | if (x == y)
32 | {
33 | return true;
34 | }
35 |
36 | if (x.Length != y.Length)
37 | {
38 | return false;
39 | }
40 | for (int i = 0; i < x.Length; i++)
41 | {
42 | if (!elementComparer.Equals(x[i], y[i]))
43 | {
44 | return false;
45 | }
46 | }
47 | return true;
48 | }
49 |
50 | public int GetHashCode(T[] obj)
51 | {
52 | var elementComparer = EqualityComparer.Default;
53 |
54 | unchecked
55 | {
56 | if (obj == null)
57 | {
58 | return 0;
59 | }
60 | int hash = 17;
61 | foreach (T element in obj)
62 | {
63 | hash = hash * 31 + elementComparer.GetHashCode(element);
64 | }
65 | return hash;
66 | }
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Extensions/MonitorFlashSectorMapExtensions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using nanoFramework.Tools.Debugger.WireProtocol;
7 |
8 | namespace nanoFramework.Tools.Debugger.Extensions
9 | {
10 | public static class MonitorFlashSectorMapExtensions
11 | {
12 | public static string UsageAsString(this Commands.Monitor_FlashSectorMap.FlashSectorData value)
13 | {
14 | switch (value.Flags & Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_MASK)
15 | {
16 | case Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_BOOTSTRAP:
17 | return "nanoBooter";
18 | case Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_CODE:
19 | return "nanoCLR";
20 | case Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_CONFIG:
21 | return "Configuration";
22 | case Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_DEPLOYMENT:
23 | return "Deployment";
24 | case Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_UPDATE:
25 | return "Update Storage";
26 | case Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_FS:
27 | return "File System";
28 | case Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_SIMPLE_A:
29 | return "Simple Storage (A)";
30 | case Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_SIMPLE_B:
31 | return "Simple Storage (B)";
32 | case Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_STORAGE_A:
33 | return "EWR Storage (A)";
34 | case Commands.Monitor_FlashSectorMap.c_MEMORY_USAGE_STORAGE_B:
35 | return "EWR Storage (B)";
36 | default:
37 | return "";
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/NetworkInformation/EncryptionType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System.ComponentModel;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | //////////////////////////////////////////////////////////////////////////////////////////////////////////
12 | // !!! KEEP IN SYNC WITH System.Net.NetworkInformation.EncryptionType (in nanoFramework.System.Net) !!! //
13 | //////////////////////////////////////////////////////////////////////////////////////////////////////////
14 |
15 | ///
16 | /// Encryption type for the Wireless network interface.
17 | ///
18 | public enum EncryptionType : byte
19 | {
20 | ///
21 | /// No encryption.
22 | ///
23 | [Description("")]
24 | None = 0,
25 |
26 | ///
27 | /// Wired Equivalent Privacy encryption.
28 | ///
29 | [Description("WEP")]
30 | WEP,
31 |
32 | ///
33 | /// Wireless Protected Access encryption.
34 | ///
35 | [Description("WPA")]
36 | WPA,
37 |
38 | ///
39 | /// Wireless Protected Access 2 encryption.
40 | ///
41 | [Description("WPA2")]
42 | WPA2,
43 |
44 | ///
45 | /// Wireless Protected Access Pre-Shared Key encryption.
46 | ///
47 | [Description("WPA Pre-Shared Key")]
48 | WPA_PSK,
49 |
50 | ///
51 | /// Wireless Protected Access 2 Pre-Shared Key encryption.
52 | ///
53 | [Description("WPA2 Pre-Shared Key")]
54 | WPA2_PSK2,
55 |
56 | ///
57 | /// Certificate encryption.
58 | ///
59 | [Description("Certificate")]
60 | Certificate,
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Extensions/TaskExtensions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 | using System.Threading;
8 | using System.Threading.Tasks;
9 |
10 | namespace nanoFramework.Tools.Debugger.Extensions
11 | {
12 | public static class TaskExtensions
13 | {
14 | ///
15 | /// Extension to tell the compiler that we actually use the instance for something. This is that the "fire-and-forget" mechanism is being used intentionally.
16 | ///
17 | ///
18 | public static void FireAndForget(this Task task)
19 | {
20 | }
21 |
22 | ///
23 | /// Extension to tell the compiler that we actually use the instance for something. This is that the "fire-and-forget" mechanism is being used intentionally.
24 | ///
25 | ///
26 | ///
27 | public static void FireAndForget(this Task task)
28 | {
29 | }
30 |
31 | public static async Task CancelAfterAsync(this Task task, int timeoutMilliseconds, CancellationTokenSource taskCts)
32 | {
33 | // sanity check for reasonable timeout values
34 | if (timeoutMilliseconds < 0 || (timeoutMilliseconds > 0 && timeoutMilliseconds < 100))
35 | {
36 | throw new ArgumentOutOfRangeException();
37 | }
38 |
39 | var timerCts = new CancellationTokenSource();
40 | if (await Task.WhenAny(task, Task.Delay(timeoutMilliseconds, timerCts.Token)) == task)
41 | {
42 | // task completed, get rid of timer
43 | timerCts.Cancel();
44 | }
45 | else
46 | {
47 | // timer completed, cancel task
48 | taskCts.Cancel();
49 | }
50 |
51 | // caller should test for exceptions or task cancellation
52 | return await task;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/USB Test App WPF/App.xaml.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 | using System.Collections.Generic;
8 | using CommunityToolkit.Mvvm.DependencyInjection;
9 | using nanoFramework.ANT.Services.NanoFrameworkService;
10 | using nanoFramework.Tools.Debugger;
11 | using Serial_Test_App_WPF.ViewModel;
12 |
13 | namespace Serial_Test_App_WPF
14 | {
15 | ///
16 | /// Interaction logic for App.xaml
17 | ///
18 | public partial class App : System.Windows.Application
19 | {
20 | public ViewModelLocator vml;
21 |
22 | public App()
23 | {
24 | Activated += App_Activated;
25 | Deactivated += App_Deactivated;
26 | Exit += App_Exit;
27 | vml = new ViewModelLocator();
28 |
29 | var serialClient = CreateSerialDebugClient();
30 | Ioc.Default.GetService().SerialDebugService = serialClient;
31 | }
32 |
33 | private void App_Exit(object sender, System.Windows.ExitEventArgs e)
34 | {
35 | var serialClient = Ioc.Default.GetService().SerialDebugService;
36 | serialClient.SerialDebugClient.StopDeviceWatchers();
37 | }
38 |
39 | private void App_Deactivated(object sender, EventArgs e)
40 | {
41 | //throw new NotImplementedException();
42 | }
43 |
44 | private void App_Activated(object sender, EventArgs e)
45 | {
46 | //throw new NotImplementedException();
47 | }
48 |
49 | private INFSerialDebugClientService CreateSerialDebugClient()
50 | {
51 | // add here any COM ports to exclude from the search
52 | var devicesToExclude = new List() { "COM3", "COM4", "COM14" };
53 |
54 | var composite = PortBase.CreateInstanceForComposite(new[]
55 | {
56 | PortBase.CreateInstanceForSerial(false, devicesToExclude),
57 | //PortBase.CreateInstanceForNetwork()
58 | }, true);
59 |
60 | return new NFSerialDebugClientService(composite);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/Wireless80211Base.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9 | // !!! KEEP IN SYNC WITH System.Net.NetworkInformation.Wireless80211Configuration (in nanoFramework.System.Net) !!! //
10 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11 |
12 | public class Wireless80211ConfigurationBase
13 | {
14 | ///
15 | /// This is the marker placeholder for this configuration block
16 | /// 4 bytes length.
17 | ///
18 | public byte[] Marker;
19 |
20 | ///
21 | /// Id for the configuration
22 | ///
23 | public uint Id;
24 |
25 | ///
26 | /// Type of authentication used on the wireless network
27 | ///
28 | public byte Authentication;
29 |
30 | ///
31 | /// Type of encryption used on the wireless network.
32 | ///
33 | public byte Encryption;
34 |
35 | ///
36 | /// Type of radio used by the wireless network adapter.
37 | ///
38 | public byte Radio;
39 |
40 | ///
41 | /// Network SSID
42 | /// 32 bytes length.
43 | ///
44 | public byte[] Ssid;
45 |
46 | ///
47 | /// Network password
48 | /// 64 bytes length.
49 | ///
50 | public byte[] Password;
51 |
52 | ///
53 | /// Options
54 | /// 1 byte length.
55 | ///
56 | public byte Options;
57 |
58 | public Wireless80211ConfigurationBase()
59 | {
60 | // need to init these here to match the expected size on the struct to be sent to the device
61 | Marker = new byte[4];
62 | Ssid = new byte[32];
63 | Password = new byte[64];
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/NetworkInformation/AuthenticationType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System.ComponentModel;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////
12 | // !!! KEEP IN SYNC WITH System.Net.NetworkInformation.AuthenticationType (in nanoFramework.System.Net) !!! //
13 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////
14 |
15 | ///
16 | /// Specifies the authentication type used for joining a Wi-Fi network.
17 | ///
18 | public enum AuthenticationType : byte
19 | {
20 | ///
21 | /// No protocol.
22 | ///
23 | None = 0,
24 |
25 | ///
26 | /// Extensible Authentication Protocol.
27 | ///
28 | EAP,
29 |
30 | ///
31 | /// Protected Extensible Authentication Protocol.
32 | ///
33 | PEAP,
34 |
35 | ///
36 | /// Microsoft Windows Connect Now protocol.
37 | ///
38 | WCN,
39 |
40 | ///
41 | /// Open System authentication, for use with WEP encryption type.
42 | ///
43 | [Description("WEP Open")]
44 | Open,
45 |
46 | ///
47 | /// Shared Key authentication, for use with WEP encryption type.
48 | ///
49 | [Description("WEP Shared")]
50 | Shared,
51 |
52 | ///
53 | /// Wired Equivalent Privacy protocol.
54 | ///
55 | [Description("WEP")]
56 | WEP,
57 |
58 | ///
59 | /// Wi-Fi Protected Access protocol.
60 | ///
61 | [Description("WPA")]
62 | WPA,
63 |
64 | ///
65 | /// Wi-Fi Protected Access 2 protocol.
66 | ///
67 | [Description("WPA2")]
68 | WPA2,
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/EngineState.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | internal class EngineState
12 | {
13 | public enum Value
14 | {
15 | NotStarted,
16 | Starting,
17 | Started,
18 | Stopping,
19 | Resume,
20 | Stopped,
21 | Disposing,
22 | Disposed
23 | }
24 |
25 | private Value _value;
26 | public object SyncObject { get; private set; }
27 |
28 | public EngineState(object syncObject)
29 | {
30 | _value = Value.NotStarted;
31 | SyncObject = syncObject;
32 | }
33 |
34 | public Value GetValue()
35 | {
36 | return _value;
37 | }
38 |
39 | public bool SetValue(Value value)
40 | {
41 | return SetValue(value, false);
42 | }
43 |
44 | public bool SetValue(Value value, bool fThrow)
45 | {
46 | lock (SyncObject)
47 | {
48 | if ((_value == Value.Stopping || _value == Value.Stopped )
49 | && value == Value.Resume)
50 | {
51 | _value = Value.Started;
52 | return true;
53 | }
54 | else if (_value < value)
55 | {
56 | _value = value;
57 | return true;
58 | }
59 | else
60 | {
61 | if (fThrow)
62 | {
63 | throw new Exception(string.Format("Cannot set State to {0}", value));
64 | }
65 |
66 | return false;
67 | }
68 | }
69 | }
70 |
71 | public bool IsRunning
72 | {
73 | get
74 | {
75 | Value val = _value;
76 |
77 | return val == Value.Starting || val == Value.Started;
78 | }
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://sonarcloud.io/dashboard?id=nanoframework_nf-debugger) [](https://sonarcloud.io/dashboard?id=nanoframework_nf-debugger) [](https://dev.azure.com/nanoframework/debugger/_build/latest?definitionId=33&repoName=nanoframework%2Fnf-debugger&branchName=main) [](https://www.nuget.org/packages/nanoFramework.Tools.Debugger.Net/) [](https://github.com/nanoframework/Home/blob/main/CONTRIBUTING.md) [](https://discord.gg/gCyBu8T)
2 |
3 | 
4 |
5 | -----
6 |
7 | ### Welcome to the .NET **nanoFramework** debugger library repository
8 |
9 | The debugger library provides debugging and communication capabilities to .NET applications and allows debugging and communicate with .NET **nanoFramework** devices.
10 | It's provided as source code and as a NuGet package that can be integrated on any application.
11 |
12 | ## Feedback and documentation
13 |
14 | For documentation, providing feedback, issues and finding out how to contribute please refer to the [Home repo](https://github.com/nanoframework/Home).
15 |
16 | Join our Discord community [here](https://discord.gg/gCyBu8T).
17 |
18 | ## Credits
19 |
20 | The list of contributors to this project can be found at [CONTRIBUTORS](https://github.com/nanoframework/Home/blob/main/CONTRIBUTORS.md).
21 |
22 | ## License
23 |
24 | The nanoFramework debugger library is licensed under the [MIT license](LICENSE.md).
25 |
26 | ## Code of Conduct
27 |
28 | This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community.
29 | For more information see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct).
30 |
31 | ### .NET Foundation
32 |
33 | This project is supported by the [.NET Foundation](https://dotnetfoundation.org).
34 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/DeploymentBlock.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger.WireProtocol
10 | {
11 | public class DeploymentBlock
12 | {
13 | ///
14 | /// Start address of block
15 | ///
16 | public int StartAddress { get; }
17 |
18 | ///
19 | /// Block size
20 | ///
21 | public int Size { get; }
22 |
23 | ///
24 | /// Data to deploy to the device
25 | ///
26 | public byte[] DeploymentData { get { return _deploymentData; } }
27 | private byte[] _deploymentData;
28 |
29 | ///
30 | /// Available space in this block
31 | ///
32 | public int AvailableSpace
33 | {
34 | get
35 | {
36 | return Size - DeploymentData.Length;
37 | }
38 | }
39 |
40 | ///
41 | /// Required aliment of programming word.
42 | ///
43 | public int ProgramAligment { get; } = 0;
44 |
45 | ///
46 | /// Creates a new starting at with size.
47 | ///
48 | /// Start address of the block.
49 | /// Size of the block.
50 | /// Alignment size for programming.
51 | public DeploymentBlock(int startAddress, int size, int programAligment)
52 | {
53 | // empty deployment data
54 | _deploymentData = new byte[0];
55 |
56 | StartAddress = startAddress;
57 | Size = size;
58 | ProgramAligment = programAligment;
59 | }
60 |
61 | internal void AddDeploymentData(byte[] buffer)
62 | {
63 | // resize deployment data array
64 | int previousLenght = _deploymentData.Length;
65 | Array.Resize(ref _deploymentData, previousLenght + buffer.Length);
66 |
67 | Array.Copy(buffer, 0, _deploymentData, previousLenght, buffer.Length);
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/USB Test App WPF/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 | using System.Windows;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("USB Test App WPF")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("USB Test App WPF")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | //In order to begin building localizable applications, set
23 | //CultureYouAreCodingWith in your .csproj file
24 | //inside a . For example, if you are using US english
25 | //in your source files, set the to en-US. Then uncomment
26 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
27 | //the line below to match the UICulture setting in the project file.
28 |
29 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
30 |
31 |
32 | [assembly: ThemeInfo(
33 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
34 | //(used if a resource is not found in the page,
35 | // or application resource dictionaries)
36 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
37 | //(used if a resource is not found in the page,
38 | // app, or any theme specific resource dictionaries)
39 | )]
40 |
41 |
42 | // Version information for an assembly consists of the following four values:
43 | //
44 | // Major Version
45 | // Minor Version
46 | // Build Number
47 | // Revision
48 | //
49 | // You can specify all the values or you can default the Build and Revision Numbers
50 | // by using the '*' as shown below:
51 | // [assembly: AssemblyVersion("1.0.*")]
52 | [assembly: AssemblyVersion("1.0.0.0")]
53 | [assembly: AssemblyFileVersion("1.0.0.0")]
54 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/WirelessAPBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | namespace nanoFramework.Tools.Debugger
7 | {
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9 | // !!! KEEP IN SYNC WITH System.Net.NetworkInformation.WirelessAPConfiguration (in nanoFramework.System.Net) !!! //
10 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11 |
12 | public class WirelessAPConfigurationBase
13 | {
14 | ///
15 | /// This is the marker placeholder for this configuration block
16 | /// 4 bytes length.
17 | ///
18 | public byte[] Marker;
19 |
20 | ///
21 | /// Id for the configuration
22 | ///
23 | public uint Id;
24 |
25 | ///
26 | /// Type of authentication used on the wireless network
27 | ///
28 | public byte Authentication;
29 |
30 | ///
31 | /// Type of encryption used on the wireless network.
32 | ///
33 | public byte Encryption;
34 |
35 | ///
36 | /// Type of radio used by the wireless network adapter.
37 | ///
38 | public byte Radio;
39 |
40 | ///
41 | /// Network SSID
42 | /// 32 bytes length.
43 | ///
44 | public byte[] Ssid;
45 |
46 | ///
47 | /// Network password
48 | /// 64 bytes length.
49 | ///
50 | public byte[] Password;
51 |
52 | ///
53 | /// Options
54 | /// 1 byte length.
55 | ///
56 | public byte Options;
57 |
58 | ///
59 | /// Channel
60 | /// 1 byte length.
61 | ///
62 | public byte Channel;
63 |
64 | ///
65 | /// Max connections
66 | /// 1 byte length.
67 | ///
68 | public byte MaxConnections;
69 |
70 | public WirelessAPConfigurationBase()
71 | {
72 | // need to init these here to match the expected size on the struct to be sent to the device
73 | Marker = new byte[4];
74 | Ssid = new byte[32];
75 | Password = new byte[64];
76 | }
77 | }
78 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/WireProtocolRequestsStore.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 | using System.Collections.Generic;
8 |
9 | namespace nanoFramework.Tools.Debugger.WireProtocol
10 | {
11 | public class WireProtocolRequestsStore
12 | {
13 | private readonly object _requestsLock = new object();
14 | private readonly Dictionary, WireProtocolRequest> _requests = new();
15 |
16 | public void Add(WireProtocolRequest request)
17 | {
18 | lock (_requestsLock)
19 | {
20 | // it's wise to check if this key is already on the dictionary
21 | // can't use TryAdd because that's only available on the UWP API
22 | Tuple newKey = GetKey(request);
23 |
24 | if (_requests.ContainsKey(newKey))
25 | {
26 | // remove the last one, before adding this
27 | _ = _requests.Remove(newKey);
28 | }
29 |
30 | _requests.Add(newKey, request);
31 | }
32 | }
33 |
34 | public bool Remove(Packet header)
35 | {
36 | lock (_requestsLock)
37 | {
38 | return _requests.Remove(new Tuple(header.Cmd, header.Seq));
39 | }
40 | }
41 |
42 | public bool Remove(WireProtocolRequest request)
43 | {
44 | lock (_requestsLock)
45 | {
46 | if(_requests.Remove(GetKey(request)))
47 | {
48 | request.RequestAborted();
49 |
50 | return true;
51 | }
52 | else
53 | {
54 | return false;
55 | }
56 | }
57 | }
58 |
59 | public int GetCount()
60 | {
61 | lock (_requestsLock)
62 | {
63 | return _requests.Count;
64 | }
65 | }
66 |
67 | public WireProtocolRequest GetByReplyHeader(Packet header)
68 | {
69 | lock (_requestsLock)
70 | {
71 | return _requests.TryGetValue(new Tuple(header.Cmd, header.SeqReply), out WireProtocolRequest requestState) ? requestState : null;
72 | }
73 | }
74 |
75 | private Tuple GetKey(WireProtocolRequest request)
76 | {
77 | return new Tuple(request.OutgoingMessage.Header.Cmd, request.OutgoingMessage.Header.Seq);
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/DeviceConfiguration.Wireless80211ConfigurationProperties.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 | using System.Text;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | public partial class DeviceConfiguration
12 | {
13 | public partial class Wireless80211ConfigurationProperties : Wireless80211ConfigurationPropertiesBase
14 | {
15 | public bool IsUnknown { get; set; }
16 |
17 | public Wireless80211ConfigurationProperties()
18 | {
19 | }
20 |
21 | public Wireless80211ConfigurationProperties(Wireless80211ConfigurationBase config)
22 | {
23 | Id = config.Id;
24 | Authentication = (AuthenticationType)config.Authentication;
25 | Encryption = (EncryptionType)config.Encryption;
26 | Radio = (RadioType)config.Radio;
27 | Ssid = Encoding.UTF8.GetString(config.Ssid).Trim('\0');
28 | Password = Encoding.UTF8.GetString(config.Password).Trim('\0');
29 | Wireless80211Options = (Wireless80211_ConfigurationOptions)config.Options;
30 |
31 | // reset unknown flag
32 | IsUnknown = false;
33 | }
34 |
35 | // operator to allow casting a Wireless80211ConfigurationProperties object to Wireless80211ConfigurationBase
36 | public static explicit operator Wireless80211ConfigurationBase(Wireless80211ConfigurationProperties value)
37 | {
38 | var networkWirelessConfig = new Wireless80211ConfigurationBase()
39 | {
40 | Marker = Encoding.UTF8.GetBytes(MarkerConfigurationWireless80211_v1),
41 |
42 | Id = value.Id,
43 | Authentication = (byte)value.Authentication,
44 | Encryption = (byte)value.Encryption,
45 | Radio = (byte)value.Radio,
46 | Options = (byte)value.Wireless80211Options
47 | };
48 |
49 | // the following ones are strings so they need to be copied over to the array
50 | // this is required to when serializing the class the struct size matches the one in the native end
51 | Array.Copy(Encoding.UTF8.GetBytes(value.Ssid), 0, networkWirelessConfig.Ssid, 0, value.Ssid.Length);
52 | Array.Copy(Encoding.UTF8.GetBytes(value.Password), 0, networkWirelessConfig.Password, 0, value.Password.Length);
53 |
54 | return networkWirelessConfig;
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/DeploymentSector.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 |
11 | namespace nanoFramework.Tools.Debugger.WireProtocol
12 | {
13 | public class DeploymentSector
14 | {
15 | ///
16 | /// Start address of sector
17 | ///
18 | public int StartAddress { get { return Blocks.First().StartAddress; } }
19 |
20 | ///
21 | /// Number of blocks in this sector
22 | ///
23 | public int NumBlocks { get { return Blocks.Count; } }
24 |
25 | ///
26 | /// Bytes per block in this sector
27 | ///
28 | public int BytesPerBlock { get { return Blocks.First().Size; } }
29 |
30 | public int Size
31 | {
32 | get
33 | {
34 | return Blocks.Sum(b => b.Size);
35 | }
36 | }
37 |
38 |
39 | public List Blocks { get; internal set; }
40 |
41 | public byte[] DeploymentData
42 | {
43 |
44 | set
45 | {
46 | int remainingBytes = value.Length;
47 | int currentPosition = 0;
48 |
49 | // find first block with available space
50 | while (remainingBytes > 0)
51 | {
52 | var block = Blocks.First(b => b.AvailableSpace > 0);
53 | int currentDataSize = block.DeploymentData.Length;
54 |
55 | int bytesToCopy = Math.Min(block.AvailableSpace, remainingBytes);
56 |
57 | byte[] tempBuffer = new byte[bytesToCopy];
58 |
59 | Array.Copy(value, currentPosition, tempBuffer, 0, bytesToCopy);
60 | block.AddDeploymentData(tempBuffer);
61 |
62 | remainingBytes -= bytesToCopy;
63 | currentPosition += bytesToCopy;
64 | }
65 |
66 | }
67 | }
68 |
69 | ///
70 | /// Available space in this sector
71 | ///
72 | public int AvailableSpace
73 | {
74 | get
75 | {
76 | int sum = 0;
77 |
78 | Blocks.Select(b => sum += b.Size - b.DeploymentData.Length).ToList();
79 |
80 | return sum;
81 | }
82 | }
83 |
84 |
85 | public DeploymentSector(List blocks)
86 | {
87 | Blocks = blocks;
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_String.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 | using System.Text;
9 |
10 | namespace nanoFramework.Tools.Debugger
11 | {
12 | public class RuntimeValue_String : RuntimeValue
13 | {
14 | internal string m_value;
15 |
16 | protected internal RuntimeValue_String(Engine eng, WireProtocol.Commands.Debugging_Value handle) : base(eng, handle)
17 | {
18 | byte[] buf = handle.m_builtinValue;
19 |
20 | if (handle.m_bytesInString >= buf.Length)
21 | {
22 | var result = m_eng.ReadMemory(m_handle.m_charsInString, m_handle.m_bytesInString);
23 |
24 | if (!result.Success)
25 | {
26 | // Revert to the preview on failure
27 | buf = handle.m_builtinValue;
28 | }
29 | else
30 | {
31 | // copy return value back to handler value
32 | Array.Copy(result.Buffer, 0, handle.m_builtinValue, 0, result.Buffer.Length);
33 | }
34 | }
35 |
36 | m_value = WireProtocol.Commands.GetZeroTerminatedString(buf, true);
37 | }
38 |
39 | public override bool IsReference { get { return false; } }
40 | public override bool IsNull { get { return false; } }
41 | public override bool IsPrimitive { get { return false; } }
42 | public override bool IsValueType { get { return false; } }
43 | public override bool IsArray { get { return false; } }
44 | public override bool IsReflection { get { return false; } }
45 |
46 | public override object Value
47 | {
48 | get
49 | {
50 | return m_value;
51 | }
52 |
53 | set
54 | {
55 | throw new NotImplementedException();
56 | }
57 | }
58 |
59 | internal override void SetStringValue(string val)
60 | {
61 | byte[] buf = Encoding.UTF8.GetBytes(val);
62 |
63 | if (buf.Length != m_handle.m_bytesInString)
64 | {
65 | throw new ArgumentException("String must have same length");
66 | }
67 |
68 | WireProtocol.AccessMemoryErrorCodes errorCode = m_eng.WriteMemory(m_handle.m_charsInString, buf);
69 |
70 | if (errorCode != WireProtocol.AccessMemoryErrorCodes.NoError)
71 | {
72 | throw new ArgumentException("Cannot write string");
73 | }
74 |
75 | m_value = val;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDevice.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 | using nanoFramework.Tools.Debugger.PortTcpIp;
9 | using nanoFramework.Tools.Debugger.WireProtocol;
10 |
11 | namespace nanoFramework.Tools.Debugger
12 | {
13 | public partial class NanoDevice : NanoDeviceBase, IDisposable, INanoDevice where T : new()
14 | {
15 | private bool _disposed;
16 |
17 | public T Device { get; set; }
18 |
19 | public string DeviceId { get; set; }
20 |
21 | public NanoDevice()
22 | {
23 | Device = new T();
24 |
25 | if (Device is NanoSerialDevice)
26 | {
27 | Transport = TransportType.Serial;
28 | }
29 | }
30 |
31 | #region Disposable implementation
32 |
33 | ~NanoDevice()
34 | {
35 | Dispose(false);
36 | }
37 |
38 | private void Dispose(bool disposing)
39 | {
40 | if (!_disposed)
41 | {
42 | if (disposing)
43 | {
44 | try
45 | {
46 | // release managed components
47 | Disconnect();
48 | }
49 | catch
50 | {
51 | // required to catch exceptions from Engine dispose calls
52 | }
53 |
54 | _disposed = true;
55 | }
56 | }
57 | }
58 |
59 | ///
60 | /// Standard Dispose method for releasing resources such as the connection to the device.
61 | ///
62 | public void Dispose()
63 | {
64 | Dispose(true);
65 | GC.SuppressFinalize(this);
66 | }
67 |
68 | #endregion
69 |
70 | ///
71 | /// Connect to nanoFramework device
72 | ///
73 | /// result after attempting to connect to the device.
74 | public ConnectPortResult Connect()
75 | {
76 | if (Device is NanoSerialDevice || Device is NanoNetworkDevice)
77 | {
78 | return ConnectionPort.ConnectDevice();
79 | }
80 |
81 | return ConnectPortResult.NotConnected;
82 | }
83 |
84 | ///
85 | /// Disconnect nanoFramework device
86 | ///
87 | public override void Disconnect(bool force = false)
88 | {
89 | ConnectionPort.DisconnectDevice(force);
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/DeviceConfiguration.WirelessAPConfigurationProperties.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 | using System.Text;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | public partial class DeviceConfiguration
12 | {
13 | public partial class WirelessAPConfigurationProperties : WirelessAPConfigurationPropertiesBase
14 | {
15 | public bool IsUnknown { get; set; }
16 |
17 | public WirelessAPConfigurationProperties()
18 | {
19 | }
20 |
21 | public WirelessAPConfigurationProperties(WirelessAPConfigurationBase config)
22 | {
23 | Id = config.Id;
24 | Authentication = (AuthenticationType)config.Authentication;
25 | Encryption = (EncryptionType)config.Encryption;
26 | Radio = (RadioType)config.Radio;
27 | Ssid = Encoding.UTF8.GetString(config.Ssid).Trim('\0');
28 | Password = Encoding.UTF8.GetString(config.Password).Trim('\0');
29 | WirelessAPOptions = (WirelessAP_ConfigurationOptions)config.Options;
30 | Channel = config.Channel;
31 | MaxConnections = config.MaxConnections;
32 |
33 | // reset unknown flag
34 | IsUnknown = false;
35 | }
36 |
37 | // operator to allow casting a WirelessAPConfigurationProperties object to WirelessAPConfigurationBase
38 | public static explicit operator WirelessAPConfigurationBase(WirelessAPConfigurationProperties value)
39 | {
40 | var networkWirelessConfig = new WirelessAPConfigurationBase()
41 | {
42 | Marker = Encoding.UTF8.GetBytes(MarkerConfigurationWireless80211AP_v1),
43 |
44 | Id = value.Id,
45 | Authentication = (byte)value.Authentication,
46 | Encryption = (byte)value.Encryption,
47 | Radio = (byte)value.Radio,
48 | Options = (byte)value.WirelessAPOptions,
49 | Channel = value.Channel,
50 | MaxConnections = value.MaxConnections
51 | };
52 |
53 | // the following ones are strings so they need to be copied over to the array
54 | // this is required to when serializing the class the struct size matches the one in the native end
55 | Array.Copy(Encoding.UTF8.GetBytes(value.Ssid), 0, networkWirelessConfig.Ssid, 0, value.Ssid.Length);
56 | Array.Copy(Encoding.UTF8.GetBytes(value.Password), 0, networkWirelessConfig.Password, 0, value.Password.Length);
57 |
58 | return networkWirelessConfig;
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/OutgoingMessage.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | namespace nanoFramework.Tools.Debugger.WireProtocol
8 | {
9 | public class OutgoingMessage
10 | {
11 | readonly ushort _sequenceId;
12 |
13 | public MessageRaw Raw { get; private set; }
14 | public MessageBase Base { get; private set; }
15 |
16 | public Packet Header => Base.Header;
17 |
18 | public object Payload => Base.Payload;
19 |
20 | public bool NeedsReply =>
21 | !(((Header.Flags & Flags.c_NonCritical) == Flags.c_NonCritical) ||
22 | ((Header.Flags & Flags.c_Reply) == Flags.c_Reply));
23 |
24 | public OutgoingMessage(ushort sequenceId, Converter converter, uint command, uint flags, object payload)
25 | {
26 | _sequenceId = sequenceId;
27 |
28 | InitializeForSend(converter, command, flags, payload);
29 |
30 | UpdateCRC(converter);
31 | }
32 |
33 | internal OutgoingMessage(ushort sequenceId, IncomingMessage request, Converter converter, uint flags, object payload)
34 | {
35 | _sequenceId = sequenceId;
36 |
37 | InitializeForSend(converter, request.Header.Cmd, flags, payload);
38 |
39 | Base.Header.SeqReply = request.Header.Seq;
40 | Base.Header.Flags |= Flags.c_Reply;
41 |
42 | UpdateCRC(converter);
43 | }
44 |
45 |
46 | internal void InitializeForSend(Converter converter, uint cmd, uint flags, object payload)
47 | {
48 | Packet header = new Packet
49 | {
50 | Seq = _sequenceId,
51 | Cmd = cmd,
52 | Flags = flags
53 | };
54 |
55 | Raw = new MessageRaw();
56 |
57 | Base = new MessageBase
58 | {
59 | Header = header,
60 | Payload = payload
61 | };
62 |
63 | if (payload != null)
64 | {
65 | Raw.Payload = converter.Serialize(payload);
66 |
67 | Base.Header.Size = (uint)Raw.Payload.Length;
68 | Base.Header.CrcData = CRC.ComputeCRC(Raw.Payload, 0);
69 | }
70 | }
71 |
72 | private void UpdateCRC(Converter converter)
73 | {
74 | Packet header = Base.Header;
75 |
76 | //
77 | // The CRC for the header is computed setting the CRC field to zero and then running the CRC algorithm.
78 | //
79 | header.CrcHeader = 0;
80 | header.CrcHeader = CRC.ComputeCRC(converter.Serialize(header), 0);
81 |
82 | Raw.Header = converter.Serialize(header);
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Net/PortDefinitions/PortBase.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System.Collections.Generic;
5 | using nanoFramework.Tools.Debugger.PortComposite;
6 | using nanoFramework.Tools.Debugger.PortSerial;
7 | using nanoFramework.Tools.Debugger.PortTcpIp;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | // write intellisense documentation for this class
12 | public abstract partial class PortBase : PortMessageBase
13 | {
14 | protected PortBase()
15 | {
16 | NanoFrameworkDevices = NanoFrameworkDevices.Instance;
17 | }
18 |
19 | #region creating serial instances
20 |
21 | public static PortBase CreateInstanceForSerial()
22 | {
23 | return new PortSerialManager(true, null);
24 | }
25 |
26 | public static PortBase CreateInstanceForSerial(List portExclusionList)
27 | {
28 | return new PortSerialManager(
29 | true,
30 | portExclusionList);
31 | }
32 | public static PortBase CreateInstanceForSerial(bool startDeviceWatchers)
33 | {
34 | return new PortSerialManager(
35 | startDeviceWatchers,
36 | null);
37 | }
38 |
39 | public static PortBase CreateInstanceForSerial(
40 | bool startDeviceWatchers,
41 | int bootTime = 1000)
42 | {
43 | return new PortSerialManager(
44 | startDeviceWatchers,
45 | null,
46 | bootTime);
47 | }
48 |
49 | public static PortBase CreateInstanceForSerial(
50 | bool startDeviceWatchers,
51 | List portExclusionList = null,
52 | int bootTime = 1000)
53 | {
54 | return new PortSerialManager(
55 | startDeviceWatchers,
56 | portExclusionList,
57 | bootTime);
58 | }
59 |
60 | #endregion
61 |
62 | #region creating tcp/ip instances
63 |
64 | public static PortBase CreateInstanceForNetwork(bool startDeviceWatchers)
65 | {
66 | return new PortTcpIpManager(startDeviceWatchers);
67 | }
68 |
69 | public static PortBase CreateInstanceForNetwork(
70 | bool startDeviceWatchers,
71 | int discoveryPort)
72 | {
73 | return new PortTcpIpManager(
74 | startDeviceWatchers,
75 | discoveryPort);
76 | }
77 |
78 | #endregion
79 |
80 | public static PortBase CreateInstanceForComposite(
81 | IEnumerable ports,
82 | bool startDeviceWatchers)
83 | {
84 | return new PortCompositeDeviceManager(
85 | ports,
86 | startDeviceWatchers);
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/USB Test App WPF/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Serial_Test_App_WPF.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Serial_Test_App_WPF.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/WireProtocolRequest.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 | using System.Diagnostics;
9 | using System.Threading;
10 | using System.Threading.Tasks;
11 |
12 | namespace nanoFramework.Tools.Debugger.WireProtocol
13 | {
14 | public class WireProtocolRequest
15 | {
16 | private readonly CommandEventHandler _callback;
17 | private readonly int _timeout;
18 |
19 | public CancellationToken CancellationToken { get; }
20 | public TaskCompletionSource TaskCompletionSource { get; }
21 |
22 | public DateTimeOffset Expires { get; private set; } = DateTimeOffset.MaxValue;
23 |
24 | public DateTime RequestTimestamp { get; private set; }
25 |
26 | public OutgoingMessage OutgoingMessage { get; }
27 |
28 | public bool NeedsReply => OutgoingMessage.NeedsReply;
29 |
30 | public WireProtocolRequest(OutgoingMessage outgoingMessage, int millisecondsTimeout = 5000, CommandEventHandler callback = null)
31 | {
32 | OutgoingMessage = outgoingMessage;
33 | _callback = callback;
34 |
35 | _timeout = millisecondsTimeout;
36 |
37 | // https://blogs.msdn.microsoft.com/pfxteam/2009/06/02/the-nature-of-taskcompletionsourcetresult/
38 | TaskCompletionSource = new TaskCompletionSource(this);
39 | }
40 |
41 | internal bool PerformRequest(IController controller)
42 | {
43 | Debug.WriteLine($"Performing request");
44 |
45 | DebuggerEventSource.Log.WireProtocolTxHeader(OutgoingMessage.Base.Header.CrcHeader
46 | , OutgoingMessage.Base.Header.CrcData
47 | , OutgoingMessage.Base.Header.Cmd
48 | , OutgoingMessage.Base.Header.Flags
49 | , OutgoingMessage.Base.Header.Seq
50 | , OutgoingMessage.Base.Header.SeqReply
51 | , OutgoingMessage.Base.Header.Size);
52 |
53 | if(controller.Send(OutgoingMessage.Raw))
54 | {
55 | // set TTL for the request
56 | Expires = DateTime.UtcNow.AddMilliseconds(_timeout);
57 |
58 | // store start time
59 | RequestTimestamp = DateTime.Now;
60 |
61 | return true;
62 | }
63 |
64 | // store start time
65 | RequestTimestamp = DateTime.Now;
66 |
67 | return false;
68 | }
69 |
70 | internal void RequestAborted()
71 | {
72 | DebuggerEventSource.Log.WireProtocolTimeout(
73 | OutgoingMessage.Base.Header.Cmd,
74 | OutgoingMessage.Base.Header.Seq,
75 | OutgoingMessage.Base.Header.SeqReply,
76 | RequestTimestamp);
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/PortDefinitions/PortBase.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | public abstract partial class PortBase
10 | {
11 | public List PortExclusionList { get; set; } = new List();
12 |
13 | public override bool Equals(object obj)
14 | {
15 | PortBase pd = obj as PortBase; if (pd == null) return false;
16 |
17 | return (pd.UniqueId.Equals(UniqueId));
18 | }
19 |
20 | public override int GetHashCode()
21 | {
22 | return base.GetHashCode();
23 | }
24 |
25 | public string PortName { get; internal set; }
26 |
27 | public virtual object UniqueId
28 | {
29 | get
30 | {
31 | return PortName;
32 | }
33 | }
34 |
35 | public string PersistName
36 | {
37 | get
38 | {
39 | return UniqueId.ToString();
40 | }
41 | }
42 |
43 | ///
44 | /// Event that is raised when enumeration of all nF devices is complete.
45 | ///
46 | public abstract event EventHandler DeviceEnumerationCompleted;
47 |
48 | ///
49 | /// Flag to signal that devices enumeration is complete.
50 | ///
51 | public virtual bool IsDevicesEnumerationComplete { get; internal set; } = false;
52 |
53 | public virtual NanoFrameworkDevices NanoFrameworkDevices { get; }
54 |
55 | ///
56 | /// Adds a new device to list of NanoFrameworkDevices.
57 | ///
58 | /// The unique ID (based on the connection properties) of the device.
59 | /// The device with the unique ID that is added or (if it was already discovered before) retrieved
60 | /// from the list of devices. Returns if no device has been added.
61 | public abstract NanoDeviceBase AddDevice(string deviceId);
62 |
63 | ///
64 | /// Starts the device watchers.
65 | /// If they are already started this operation won't have any effect.
66 | ///
67 | public abstract void StartDeviceWatchers();
68 |
69 | ///
70 | /// Stops the device watchers.
71 | /// If they are already stopped this operation won't have any effect.
72 | ///
73 | public abstract void StopDeviceWatchers();
74 |
75 | ///
76 | /// Performs a re-scan of the connected devices.
77 | /// This operation resets the list of available devices and attempts to validate if a connected device it's a nanoDevice.
78 | ///
79 | public abstract void ReScanDevices();
80 |
81 | ///
82 | /// Disposes a device.
83 | ///
84 | /// Id of the device to dispose.
85 | public abstract void DisposeDevice(string instanceId);
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/.github/workflows/scorecard.yml:
--------------------------------------------------------------------------------
1 | # This workflow uses actions that are not certified by GitHub. They are provided
2 | # by a third-party and are governed by separate terms of service, privacy
3 | # policy, and support documentation.
4 |
5 | name: Scorecard supply-chain security
6 | on:
7 | # For Branch-Protection check. Only the default branch is supported. See
8 | # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
9 | branch_protection_rule:
10 | # To guarantee Maintained check is occasionally updated. See
11 | # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
12 | schedule:
13 | - cron: '40 16 * * 5'
14 | push:
15 | branches: [ "main" ]
16 |
17 | # Declare default permissions as read only.
18 | permissions: read-all
19 |
20 | jobs:
21 | analysis:
22 | name: Scorecard analysis
23 | runs-on: ubuntu-latest
24 | permissions:
25 | # Needed to upload the results to code-scanning dashboard.
26 | security-events: write
27 | # Needed to publish results and get a badge (see publish_results below).
28 | id-token: write
29 | # Uncomment the permissions below if installing in a private repository.
30 | # contents: read
31 | # actions: read
32 |
33 | steps:
34 | - name: "Checkout code"
35 | uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
36 | with:
37 | persist-credentials: false
38 |
39 | - name: "Run analysis"
40 | uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
41 | with:
42 | results_file: results.sarif
43 | results_format: sarif
44 | # (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
45 | # - you want to enable the Branch-Protection check on a *public* repository, or
46 | # - you are installing Scorecard on a *private* repository
47 | # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
48 | # repo_token: ${{ secrets.SCORECARD_TOKEN }}
49 |
50 | # Public repositories:
51 | # - Publish results to OpenSSF REST API for easy access by consumers
52 | # - Allows the repository to include the Scorecard badge.
53 | # - See https://github.com/ossf/scorecard-action#publishing-results.
54 | # For private repositories:
55 | # - `publish_results` will always be set to `false`, regardless
56 | # of the value entered here.
57 | publish_results: true
58 |
59 | # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
60 | # format to the repository Actions tab.
61 | - name: "Upload artifact"
62 | uses: actions/upload-artifact@97a0fba1372883ab732affbe8f94b823f91727db # v3.pre.node20
63 | with:
64 | name: SARIF file
65 | path: results.sarif
66 | retention-days: 5
67 |
68 | # Upload the results to GitHub's code scanning dashboard (optional).
69 | # Commenting out will disable upload of results to your repo's Code Scanning dashboard
70 | - name: "Upload to code-scanning"
71 | uses: github/codeql-action/upload-sarif@v3
72 | with:
73 | sarif_file: results.sarif
74 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Indirect.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | public class RuntimeValue_Indirect : RuntimeValue
12 | {
13 | protected RuntimeValue m_value;
14 |
15 | protected internal RuntimeValue_Indirect(Engine eng, WireProtocol.Commands.Debugging_Value[] array, int pos) : base(eng, array[pos])
16 | {
17 | if (++pos < array.Length)
18 | {
19 | m_value = Convert(eng, array, pos);
20 | }
21 | }
22 |
23 | public override uint ReferenceId
24 | {
25 | get
26 | {
27 | return m_value == null ? 0 : m_value.ReferenceId;
28 | }
29 | }
30 |
31 | public override CorElementType CorElementType
32 | {
33 | get
34 | {
35 | return m_value == null ? CorElementTypeDirect : m_value.CorElementType;
36 | }
37 | }
38 |
39 | public override bool IsBoxed
40 | {
41 | get
42 | {
43 | return base.IsBoxed || (m_value != null && m_value.IsBoxed);
44 | }
45 | }
46 |
47 | public override nanoClrDataType DataType { get { return (m_value == null) ? nanoClrDataType.DATATYPE_FIRST_INVALID : m_value.DataType; } }
48 |
49 | public override bool IsReference { get { return false; } }
50 | public override bool IsNull { get { return m_value == null; } }
51 | public override bool IsPrimitive { get { return (m_value != null && m_value.IsPrimitive); } }
52 | public override bool IsValueType { get { return (m_value != null && m_value.IsValueType); } }
53 | public override bool IsArray { get { return (m_value != null && m_value.IsArray); } }
54 | public override bool IsReflection { get { return false; } }
55 |
56 | public override object Value
57 | {
58 | get
59 | {
60 | if (m_value == null) return null;
61 |
62 | return m_value.Value;
63 | }
64 |
65 | set
66 | {
67 | if (m_value == null) return;
68 |
69 | m_value.Value = value;
70 | }
71 | }
72 |
73 | public override uint NumOfFields { get { return (m_value == null) ? 0 : m_value.NumOfFields; } }
74 | public override uint Length { get { return (m_value == null) ? 0 : m_value.Length; } }
75 | public override uint Depth { get { return (m_value == null) ? 0 : m_value.Depth; } }
76 | public override uint Type { get { return (m_value == null) ? 0 : m_value.Type; } }
77 |
78 | internal override void SetStringValue(string val)
79 | {
80 | if (m_value == null) throw new NotImplementedException();
81 |
82 | m_value.SetStringValue(val);
83 | }
84 |
85 | public override RuntimeValue GetField(uint offset, uint fd)
86 | {
87 | return m_value?.GetField(offset, fd);
88 | }
89 |
90 | public override RuntimeValue GetElement(uint index)
91 | {
92 | return m_value?.GetElement(index);
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/PortComposite/PortCompositeDeviceManager.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Threading.Tasks;
8 |
9 |
10 | namespace nanoFramework.Tools.Debugger.PortComposite
11 | {
12 | public class PortCompositeDeviceManager : PortBase
13 | {
14 | private readonly List _ports = new List();
15 | public override event EventHandler DeviceEnumerationCompleted;
16 | public override event EventHandler LogMessageAvailable;
17 |
18 | public PortCompositeDeviceManager(
19 | IEnumerable ports,
20 | bool startDeviceWatchers = true)
21 | {
22 | _ports.AddRange(ports);
23 |
24 | SubscribeToPortEvents();
25 |
26 |
27 | Task.Factory.StartNew(() =>
28 | {
29 | if (startDeviceWatchers)
30 | {
31 | _ports.ForEach(p => p.StartDeviceWatchers());
32 | }
33 | });
34 | }
35 |
36 | private void SubscribeToPortEvents()
37 | {
38 | _ports.ForEach(p =>
39 | {
40 | p.DeviceEnumerationCompleted += OnPortDeviceEnumerationCompleted;
41 | p.LogMessageAvailable += OnLogMessageAvailable;
42 | });
43 | }
44 |
45 | private void OnLogMessageAvailable(object sender, StringEventArgs e)
46 | {
47 | LogMessageAvailable?.Invoke(this, new StringEventArgs(e.EventText));
48 | }
49 |
50 | private void OnPortDeviceEnumerationCompleted(object sender, EventArgs e)
51 | {
52 | IsDevicesEnumerationComplete = (from p in _ports
53 | where p.IsDevicesEnumerationComplete
54 | select p).Any();
55 | if (IsDevicesEnumerationComplete)
56 | {
57 | DeviceEnumerationCompleted?.Invoke(this, EventArgs.Empty);
58 | }
59 | }
60 |
61 | ///
62 | /// This API is not available in PortCompositeDeviceManager.
63 | public override NanoDeviceBase AddDevice(string deviceId)
64 | {
65 | // None of the Port*Manager has a check whether deviceId matches the ID handled by the manager,
66 | // so we don't know how to add a device here.
67 | throw new NotImplementedException();
68 | }
69 |
70 | public override void StartDeviceWatchers()
71 | {
72 | IsDevicesEnumerationComplete = false;
73 | _ports.ForEach(p => p.StartDeviceWatchers());
74 | }
75 |
76 | public override void StopDeviceWatchers()
77 | {
78 | _ports.ForEach(p => p.StopDeviceWatchers());
79 | }
80 |
81 | public override void ReScanDevices()
82 | {
83 | IsDevicesEnumerationComplete = false;
84 | Task.Run(() =>
85 | {
86 | _ports.ForEach(p => p.ReScanDevices());
87 | });
88 | }
89 |
90 | public override void DisposeDevice(string instanceId)
91 | {
92 | _ports.ForEach(p => p.DisposeDevice(instanceId));
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/NetworkConfigurationBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 |
7 | namespace nanoFramework.Tools.Debugger
8 | {
9 | public class NetworkConfigurationBase
10 | {
11 | ///
12 | /// This is the marker placeholder for this configuration block
13 | /// 4 bytes length.
14 | ///
15 | public byte[] Marker;
16 |
17 | ///
18 | /// MAC address for the network interface
19 | ///
20 | public byte[] MacAddress;
21 |
22 | ///
23 | /// Network IPv4 address as 32-bit unsigned integer
24 | ///
25 | public uint IPv4Address;
26 |
27 | ///
28 | /// Network IPv4 subnet mask as 32-bit unsigned integer
29 | ///
30 | public uint IPv4NetMask;
31 |
32 | ///
33 | /// Network gateway IPv4 address as 32-bit unsigned integer
34 | ///
35 | public uint IPv4GatewayAddress;
36 |
37 | ///
38 | /// DNS server 1 IPv4 address as 32-bit unsigned integer
39 | ///
40 | public uint IPv4DNSAddress1;
41 |
42 | ///
43 | /// DNS server 2 IPv4 address as 32-bit unsigned integer
44 | ///
45 | public uint IPv4DNSAddress2;
46 |
47 | ///
48 | /// Network IPv6 address as an array of 4 32-bit unsigned integers
49 | ///
50 | public uint[] IPv6Address;
51 |
52 | ///
53 | // Network IPv6 subnet mask as an array of 4 32-bit unsigned integers
54 | ///
55 | public uint[] IPv6NetMask;
56 |
57 | ///
58 | /// Network gateway IPv6 address as an array of 4 32-bit unsigned integers
59 | ///
60 | public uint[] IPv6GatewayAddress;
61 |
62 | ///
63 | /// DNS server 1 IPv6 address as an array of 4 32-bit unsigned integers
64 | ///
65 | public uint[] IPv6DNSAddress1;
66 |
67 | ///
68 | /// DNS server 2 IPv6 address as an array of 4 32-bit unsigned integers
69 | ///
70 | public uint[] IPv6DNSAddress2;
71 |
72 | ///
73 | /// Network interface type
74 | ///
75 | public byte InterfaceType;
76 |
77 | ///
78 | /// Specific configuration Id
79 | ///
80 | public uint SpecificConfigId;
81 |
82 | ///
83 | /// Automatic DNS address
84 | ///
85 | public byte AutomaticDNS;
86 |
87 | ///
88 | /// Address mode (static, DHCP or auto IP)
89 | ///
90 | public byte StartupAddressMode;
91 |
92 | public NetworkConfigurationBase()
93 | {
94 | // need to init this here to match the expected size on the struct to be sent to the device
95 | Marker = new byte[4];
96 |
97 | IPv6Address = new uint[] { 0, 0, 0, 0 };
98 | IPv6NetMask = new uint[] { 0, 0, 0, 0 };
99 | IPv6GatewayAddress = new uint[] { 0, 0, 0, 0 };
100 | IPv6DNSAddress1 = new uint[] { 0, 0, 0, 0 };
101 | IPv6DNSAddress2 = new uint[] { 0, 0, 0, 0 };
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Extensions/FlashSectorDataExtensions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using nanoFramework.Tools.Debugger.WireProtocol;
7 | using System;
8 | using System.Collections.Generic;
9 | using static nanoFramework.Tools.Debugger.WireProtocol.Commands.Monitor_FlashSectorMap;
10 |
11 | namespace nanoFramework.Tools.Debugger.Extensions
12 | {
13 | public static class FlashSectorDataExtensions
14 | {
15 | ///
16 | /// Convert a into a
17 | ///
18 | ///
19 | ///
20 | public static DeploymentSector ToDeploymentSector(this FlashSectorData value)
21 | {
22 | // build a DeploymentSector from a FlashSectorData
23 |
24 | List blocks = new List();
25 |
26 | for (int i = 0; i < value.NumBlocks; i++)
27 | {
28 | int programmingAlignment = 0;
29 |
30 | // check alignment requirements
31 | uint blockRegionFlashProgrammingWidth = value.Flags & BlockRegionFlashProgrammingWidth_MASK;
32 | uint blockRegionBitsSet = blockRegionFlashProgrammingWidth;
33 |
34 | // Zero, or 1 bit only allowed to be set for programming width
35 | uint countOfBitsSet = 0;
36 | while (blockRegionBitsSet > 0)
37 | {
38 | countOfBitsSet += blockRegionBitsSet & 1;
39 | blockRegionBitsSet >>= 1;
40 | }
41 | if( countOfBitsSet > 1)
42 | {
43 | throw new NotSupportedException("Multiple selections for Flash Program Width found, only one supported per block");
44 | }
45 |
46 | switch (blockRegionFlashProgrammingWidth)
47 | {
48 | case BlockRegionAttribute_ProgramWidthIs8bits:
49 | // when not specified, default to minimum flash word size
50 | programmingAlignment = 0;
51 | break;
52 |
53 | case BlockRegionAttribute_ProgramWidthIs64bits:
54 | programmingAlignment = 64 / 8;
55 | break;
56 |
57 | case BlockRegionAttribute_ProgramWidthIs128bits:
58 | programmingAlignment = 128 / 8;
59 | break;
60 |
61 | case BlockRegionAttribute_ProgramWidthIs256bits:
62 | programmingAlignment = 256 / 8;
63 | break;
64 |
65 | case BlockRegionAttribute_ProgramWidthIs512bits:
66 | programmingAlignment = 512 / 8;
67 | break;
68 |
69 | case BlockRegionAttribute_ProgramWidthIs1024bits:
70 | programmingAlignment = 1024 / 8;
71 | break;
72 |
73 | case BlockRegionAttribute_ProgramWidthIs2048bits:
74 | programmingAlignment = 2048 / 8;
75 | break;
76 |
77 | default:
78 | throw new NotSupportedException($"The specified Flash Program Width '{blockRegionFlashProgrammingWidth}' is not supported. Please check the native implementation and/or that you have the .NET nanoFramework Visual Studio extension update.");
79 | }
80 |
81 | Console.WriteLine($"The value is {programmingAlignment}");
82 |
83 | blocks.Add(new DeploymentBlock(
84 | (int)value.StartAddress + (i * (int)value.BytesPerBlock),
85 | (int)value.BytesPerBlock,
86 | programmingAlignment));
87 | }
88 |
89 | return new DeploymentSector(blocks);
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/DeviceConfiguration/DeviceConfiguration.NetworkConfigurationProperties.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System.Net;
7 | using System.Text;
8 |
9 | namespace nanoFramework.Tools.Debugger
10 | {
11 | public partial class DeviceConfiguration
12 | {
13 | /////////////////////////////////////////////////////////////
14 |
15 | public partial class NetworkConfigurationProperties : NetworkConfigurationPropertiesBase
16 | {
17 | internal const uint EmptySpecificConfigValue = uint.MaxValue;
18 |
19 | public bool IsUnknown { get; set; }
20 |
21 | public NetworkConfigurationProperties() : base()
22 | {
23 | }
24 |
25 | public NetworkConfigurationProperties(NetworkConfigurationBase value)
26 | {
27 | MacAddress = value.MacAddress;
28 |
29 | IPv4Address = new IPAddress(value.IPv4Address);
30 | IPv4NetMask = new IPAddress(value.IPv4NetMask);
31 | IPv4GatewayAddress = new IPAddress(value.IPv4GatewayAddress);
32 | IPv4DNSAddress1 = new IPAddress(value.IPv4DNSAddress1);
33 | IPv4DNSAddress2 = new IPAddress(value.IPv4DNSAddress2);
34 |
35 | IPv6Address = ToIPv6Address(value.IPv6Address);
36 | IPv6NetMask = ToIPv6Address(value.IPv6NetMask);
37 | IPv6GatewayAddress = ToIPv6Address(value.IPv6GatewayAddress);
38 | IPv6DNSAddress1 = ToIPv6Address(value.IPv6DNSAddress1);
39 | IPv6DNSAddress2 = ToIPv6Address(value.IPv6DNSAddress2);
40 |
41 | InterfaceType = (NetworkInterfaceType)value.InterfaceType;
42 | StartupAddressMode = (AddressMode)value.StartupAddressMode;
43 | AutomaticDNS = value.AutomaticDNS != 0;
44 |
45 | if (value.SpecificConfigId == EmptySpecificConfigValue)
46 | {
47 | SpecificConfigId = null;
48 | }
49 | else
50 | {
51 | SpecificConfigId = value.SpecificConfigId;
52 | }
53 |
54 | // reset unknown flag
55 | IsUnknown = false;
56 | }
57 |
58 | // operator to allow casting a NetworkConfigurationProperties object to NetworkConfigurationBase
59 | public static explicit operator NetworkConfigurationBase(NetworkConfigurationProperties value)
60 | {
61 | var networkConfig = new NetworkConfigurationBase()
62 | {
63 | Marker = Encoding.UTF8.GetBytes(MarkerConfigurationNetwork_v1),
64 |
65 | MacAddress = value.MacAddress,
66 |
67 | IPv4Address = FromIPv4Address(value.IPv4Address),
68 | IPv4NetMask = FromIPv4Address(value.IPv4NetMask),
69 | IPv4GatewayAddress = FromIPv4Address(value.IPv4GatewayAddress),
70 | IPv4DNSAddress1 = FromIPv4Address(value.IPv4DNSAddress1),
71 | IPv4DNSAddress2 = FromIPv4Address(value.IPv4DNSAddress2),
72 |
73 | IPv6Address = FromIPv6Address(value.IPv6Address),
74 | IPv6NetMask = FromIPv6Address(value.IPv6NetMask),
75 | IPv6GatewayAddress = FromIPv6Address(value.IPv6GatewayAddress),
76 | IPv6DNSAddress1 = FromIPv6Address(value.IPv6DNSAddress1),
77 | IPv6DNSAddress2 = FromIPv6Address(value.IPv6DNSAddress2),
78 | InterfaceType = (byte)value.InterfaceType,
79 | StartupAddressMode = (byte)value.StartupAddressMode,
80 | };
81 |
82 | networkConfig.AutomaticDNS = value.AutomaticDNS ? (byte)1 : (byte)0;
83 | networkConfig.SpecificConfigId = value.SpecificConfigId ?? EmptySpecificConfigValue;
84 |
85 | return networkConfig;
86 | }
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Primitive.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using nanoFramework.Tools.Debugger.Extensions;
8 | using System;
9 |
10 | namespace nanoFramework.Tools.Debugger
11 | {
12 | public class RuntimeValue_Primitive : RuntimeValue
13 | {
14 | protected object m_value;
15 |
16 | protected internal RuntimeValue_Primitive(Engine eng, WireProtocol.Commands.Debugging_Value handle) : base(eng, handle)
17 | {
18 | Type t;
19 |
20 | switch ((nanoClrDataType)handle.m_dt)
21 | {
22 | case nanoClrDataType.DATATYPE_BOOLEAN: t = typeof(bool); break;
23 | case nanoClrDataType.DATATYPE_I1: t = typeof(sbyte); break;
24 | case nanoClrDataType.DATATYPE_U1: t = typeof(byte); break;
25 |
26 | case nanoClrDataType.DATATYPE_CHAR: t = typeof(char); break;
27 | case nanoClrDataType.DATATYPE_I2: t = typeof(short); break;
28 | case nanoClrDataType.DATATYPE_U2: t = typeof(ushort); break;
29 |
30 | case nanoClrDataType.DATATYPE_I4: t = typeof(int); break;
31 | case nanoClrDataType.DATATYPE_U4: t = typeof(uint); break;
32 | case nanoClrDataType.DATATYPE_R4: t = typeof(float); break;
33 |
34 | case nanoClrDataType.DATATYPE_I8: t = typeof(long); break;
35 | case nanoClrDataType.DATATYPE_U8: t = typeof(ulong); break;
36 | case nanoClrDataType.DATATYPE_R8: t = typeof(double); break;
37 |
38 | default: throw new ArgumentException(String.Format("Not a primitive: {0}", handle.m_dt));
39 | }
40 |
41 | m_value = Activator.CreateInstance(t);
42 |
43 | m_eng.CreateConverter().Deserialize(m_value, handle.m_builtinValue);
44 | }
45 |
46 | public override bool IsReference { get { return false; } }
47 | public override bool IsNull { get { return false; } }
48 | public override bool IsPrimitive { get { return true; } }
49 | public override bool IsValueType { get { return false; } }
50 | public override bool IsArray { get { return false; } }
51 | public override bool IsReflection { get { return false; } }
52 |
53 | public override object Value
54 | {
55 | get
56 | {
57 | return m_value;
58 | }
59 |
60 | set
61 | {
62 | if (value != null)
63 | {
64 | Type t = value.GetType();
65 |
66 | if (m_value.GetType() == t)
67 | {
68 | object valToSerialize;
69 |
70 | //
71 | // Sign- or zero-extend to at least 32 bits.
72 | //
73 | switch (TypeExtensions.GetTypeCode(t))
74 | {
75 | case TypeExtensions.TypeCode.Boolean: valToSerialize = (bool)value ? 1 : 0; break;
76 | case TypeExtensions.TypeCode.Char: valToSerialize = (uint)(char)value; break;
77 | case TypeExtensions.TypeCode.SByte: valToSerialize = (int)(sbyte)value; break;
78 | case TypeExtensions.TypeCode.Byte: valToSerialize = (uint)(byte)value; break;
79 | case TypeExtensions.TypeCode.Int16: valToSerialize = (int)(short)value; break;
80 | case TypeExtensions.TypeCode.UInt16: valToSerialize = (uint)(ushort)value; break;
81 | default: valToSerialize = value; break;
82 | }
83 |
84 | byte[] data = m_eng.CreateConverter().Serialize(valToSerialize);
85 |
86 | m_value = SetBlock(m_handle.m_dt, data);
87 | }
88 | }
89 | }
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Net/FodyWeavers.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Used to control if the On_PropertyName_Changed feature is enabled.
12 |
13 |
14 |
15 |
16 | Used to control if the Dependent properties feature is enabled.
17 |
18 |
19 |
20 |
21 | Used to control if the IsChanged property feature is enabled.
22 |
23 |
24 |
25 |
26 | Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form.
27 |
28 |
29 |
30 |
31 | Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project.
32 |
33 |
34 |
35 |
36 | Used to control if equality checks should use the Equals method resolved from the base class.
37 |
38 |
39 |
40 |
41 | Used to control if equality checks should use the static Equals method resolved from the base class.
42 |
43 |
44 |
45 |
46 | Used to turn off build warnings from this weaver.
47 |
48 |
49 |
50 |
51 | Used to turn off build warnings about mismatched On_PropertyName_Changed methods.
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.
60 |
61 |
62 |
63 |
64 | A comma-separated list of error codes that can be safely ignored in assembly verification.
65 |
66 |
67 |
68 |
69 | 'false' to turn off automatic generation of the XML Schema file.
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/FifoBuffer.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 | using System.Threading;
9 |
10 | namespace nanoFramework.Tools.Debugger.WireProtocol
11 | {
12 | internal class FifoBuffer
13 | {
14 | byte[] m_buffer;
15 | int m_offset;
16 | int m_count;
17 | readonly ManualResetEvent m_ready;
18 |
19 | // use a timer to trigger the event m_ready only after a specified value is elapsed
20 | // this prevents showing partial messages which would happen if the event handler was called on every spurious char received
21 | readonly Timer timerToTriggerEvent;
22 |
23 | // time (in ms) to wait before actually setting the ready event
24 | const int triggerDelay = 500;
25 |
26 | public FifoBuffer()
27 | {
28 | m_buffer = new byte[1024];
29 | m_offset = 0;
30 | m_count = 0;
31 | m_ready = new ManualResetEvent(false);
32 | timerToTriggerEvent = new Timer((state) =>
33 | {
34 | m_ready.Set();
35 | },
36 | null, Timeout.Infinite, Timeout.Infinite);
37 | }
38 |
39 | public WaitHandle WaitHandle
40 | {
41 | get { return m_ready; }
42 | }
43 |
44 | public int Read(byte[] buf, int offset, int count)
45 | {
46 | int countRequested = count;
47 |
48 | int len = m_buffer.Length;
49 |
50 | while (m_count > 0 && count > 0)
51 | {
52 | int avail = m_count; if (avail + m_offset > len) avail = len - m_offset;
53 |
54 | if (avail > count) avail = count;
55 |
56 | Array.Copy(m_buffer, m_offset, buf, offset, avail);
57 |
58 | m_offset += avail; if (m_offset == len) m_offset = 0;
59 | offset += avail;
60 |
61 | m_count -= avail;
62 | count -= avail;
63 | }
64 |
65 | if (m_count == 0)
66 | {
67 | //
68 | // No pending data, resync to the beginning of the buffer.
69 | //
70 | m_offset = 0;
71 |
72 | m_ready.Reset();
73 | }
74 |
75 | return countRequested - count;
76 | }
77 |
78 | public void Write(byte[] buf, int offset, int count)
79 | {
80 | // stop timer is running?
81 | timerToTriggerEvent.Change(Timeout.Infinite, Timeout.Infinite);
82 |
83 | while (count > 0)
84 | {
85 | int len = m_buffer.Length;
86 | int avail = len - m_count;
87 |
88 | if (avail == 0) // Buffer full. Expand it.
89 | {
90 | byte[] buffer = new byte[len * 2];
91 |
92 | //
93 | // Double the buffer and copy all the data to the left side.
94 | //
95 | Array.Copy(m_buffer, m_offset, buffer, 0, len - m_offset);
96 | Array.Copy(m_buffer, 0, buffer, len - m_offset, m_offset);
97 |
98 | m_buffer = buffer;
99 | m_offset = 0;
100 | len *= 2;
101 | avail = len;
102 | }
103 |
104 | int offsetWrite = m_offset + m_count; if (offsetWrite >= len) offsetWrite -= len;
105 |
106 | if (avail + offsetWrite > len) avail = len - offsetWrite;
107 |
108 | if (avail > count) avail = count;
109 |
110 | Array.Copy(buf, offset, m_buffer, offsetWrite, avail);
111 |
112 | offset += avail;
113 | m_count += avail;
114 | count -= avail;
115 | }
116 |
117 | // start timer to set reset event
118 | timerToTriggerEvent.Change(500, Timeout.Infinite);
119 | }
120 |
121 | public int Available
122 | {
123 | get
124 | {
125 | return m_count;
126 | }
127 | }
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/Extensions/TypeExtensions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // See LICENSE file in the project root for full license information.
4 | //
5 |
6 | using System;
7 | using System.Reflection;
8 |
9 | namespace nanoFramework.Tools.Debugger.Extensions
10 | {
11 | static class TypeExtensions
12 | {
13 | public static Type BaseType(this Type t)
14 | {
15 | return t.GetTypeInfo().BaseType;
16 | }
17 | ///
18 | /// Gets the TypeCode value for a type.
19 | ///
20 | /// Type object.
21 | ///
22 | public static TypeCode GetTypeCode(Type t)
23 | {
24 | TypeCode result = TypeCode.Empty;
25 | if (t.Equals(typeof(bool)))
26 | result = TypeCode.Boolean;
27 | else if (t.Equals(typeof(string)))
28 | result = TypeCode.String;
29 | else if (t.Equals(typeof(byte)))
30 | result = TypeCode.Byte;
31 | else if (t.Equals(typeof(char)))
32 | result = TypeCode.Char;
33 | else if (t.Equals(typeof(DateTime)))
34 | result = TypeCode.DateTime;
35 | else if (t.Equals(typeof(decimal)))
36 | result = TypeCode.Decimal;
37 | else if (t.Equals(typeof(double)))
38 | result = TypeCode.Double;
39 | else if (t.Equals(typeof(Int16)))
40 | result = TypeCode.Int16;
41 | else if (t.Equals(typeof(Int32)))
42 | result = TypeCode.Int32;
43 | else if (t.Equals(typeof(Int64)))
44 | result = TypeCode.Int64;
45 | else if (t.Equals(typeof(UInt16)))
46 | result = TypeCode.UInt16;
47 | else if (t.Equals(typeof(UInt32)))
48 | result = TypeCode.UInt32;
49 | else if (t.Equals(typeof(UInt64)))
50 | result = TypeCode.UInt64;
51 | else if (t.Equals(typeof(sbyte)))
52 | result = TypeCode.SByte;
53 | else if (t.Equals(typeof(Single)))
54 | result = TypeCode.Single;
55 | else if (t.Equals(typeof(UInt64)))
56 | result = TypeCode.UInt64;
57 | else if (t.Equals(typeof(object)))
58 | result = TypeCode.Object;
59 | return result;
60 | }
61 |
62 | ///
63 | /// Type codes
64 | ///
65 | public enum TypeCode
66 | {
67 | ///
68 | /// Empty
69 | ///
70 | Empty,
71 | ///
72 | /// Object
73 | ///
74 | Object,
75 | ///
76 | /// DBNull
77 | ///
78 | DBNull,
79 | ///
80 | /// Boolean
81 | ///
82 | Boolean,
83 | ///
84 | /// Char
85 | ///
86 | Char,
87 | ///
88 | /// SByte
89 | ///
90 | SByte,
91 | ///
92 | /// Byte
93 | ///
94 | Byte,
95 | ///
96 | /// Int16
97 | ///
98 | Int16,
99 | ///
100 | /// UInt16
101 | ///
102 | UInt16,
103 | ///
104 | /// Int32
105 | ///
106 | Int32,
107 | ///
108 | /// UInt32
109 | ///
110 | UInt32,
111 | ///
112 | /// Int64
113 | ///
114 | Int64,
115 | ///
116 | /// UInt64
117 | ///
118 | UInt64,
119 | ///
120 | /// Single
121 | ///
122 | Single,
123 | ///
124 | /// Double
125 | ///
126 | Double,
127 | ///
128 | /// Decimal
129 | ///
130 | Decimal,
131 | ///
132 | /// DateTime
133 | ///
134 | DateTime,
135 | ///
136 | /// String
137 | ///
138 | String
139 | }
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | library
4 | net8.0;net472
5 | anycpu
6 | ../
7 | latest
8 | true
9 | true
10 | true
11 | true
12 | snupkg
13 | True
14 | $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
15 |
16 |
17 |
18 |
19 |
20 | nanoFramework.Tools.Debugger.Net
21 | nanoframework
22 | .NET nanoFramework debug library (.NET)
23 | Copyright (c) .NET Foundation and Contributors
24 | git
25 | images\nf-logo.png
26 | https://github.com/nanoframework/nf-debugger
27 | https://github.com/nanoframework/nf-debugger
28 | This .NET library provides a debug client for .NET nanoFramework devices using USB or Serial connection to a board.
29 | nanoFramework;C#;csharp;netmf;netnf;nanoframework;iot
30 | LICENSE.md
31 | images\nf-logo.png
32 | README.md
33 |
34 |
35 |
36 | True
37 | \
38 |
39 |
40 | True
41 | images
42 |
43 |
44 | True
45 |
46 |
47 |
48 |
49 |
50 | true
51 |
52 |
53 | key.snk
54 | True
55 | True
56 | True
57 | True
58 |
59 |
60 |
61 | false
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | 6.9.1
71 | runtime; build; native; contentfiles; analyzers
72 | all
73 |
74 |
75 | 8.0.0
76 | runtime; build; native; contentfiles; analyzers; buildtransitive
77 | all
78 |
79 |
80 | 3.6.146
81 | runtime; build; native; contentfiles; analyzers
82 | all
83 |
84 |
85 | 6.12.1
86 | runtime; build; native; contentfiles; analyzers; buildtransitive
87 | all
88 |
89 |
90 |
91 | 4.1.0
92 | all
93 |
94 |
95 | 8.0.0
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/ReleaseInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 | using System.Text;
9 |
10 | namespace nanoFramework.Tools.Debugger.WireProtocol
11 | {
12 | public class ReleaseInfo : IConverter
13 | {
14 | // these constants reflect the size of the struct NFReleaseInfo in native code @ nanoHAL_ReleaseInfo.h
15 | private const int c_sizeOfVersion = 8;
16 | private const int c_sizeOfInfo = 128;
17 | private const int c_sizeOfTargetName = 32;
18 | private const int c_sizeOfPlatformName = 32;
19 | private const int c_sizeOfPlatformInfo = 128;
20 |
21 | // these constants below hold the size of the old V0 format and the new one
22 | // they are used to init the byte array with raw data and trying to check if there is enough data for PlatformInfo
23 | private const int TotalSizeOfRawV0 = c_sizeOfVersion + c_sizeOfInfo + c_sizeOfTargetName + c_sizeOfPlatformName;
24 | private const int TotalSizeOfRaw = c_sizeOfVersion + c_sizeOfInfo + c_sizeOfTargetName + c_sizeOfPlatformName + c_sizeOfPlatformInfo;
25 |
26 | private readonly VersionStruct _version;
27 | private byte[] _rawInfo;
28 |
29 | public ReleaseInfo()
30 | {
31 | _version = new VersionStruct();
32 |
33 | InitFields(TotalSizeOfRawV0);
34 | }
35 |
36 | public ReleaseInfo(int dataLength)
37 | {
38 | _version = new VersionStruct();
39 |
40 | InitFields(dataLength);
41 | }
42 |
43 | private void InitFields(int dataLength)
44 | {
45 | if (dataLength == TotalSizeOfRaw)
46 | {
47 | // need to subtract the size of the _version field
48 | _rawInfo = new byte[TotalSizeOfRaw - c_sizeOfVersion];
49 | }
50 | else
51 | {
52 | // need to subtract the size of the _version field
53 | _rawInfo = new byte[TotalSizeOfRawV0 - c_sizeOfVersion];
54 | }
55 | }
56 |
57 | public void PrepareForDeserialize(int size, byte[] data, Converter converter)
58 | {
59 | // need to subtract the size of the _version field
60 | _rawInfo = new byte[data.Length - c_sizeOfVersion];
61 | }
62 |
63 | public Version Version => _version.Version;
64 |
65 | public string Info
66 | {
67 | get
68 | {
69 | var myString = Encoding.UTF8.GetString(_rawInfo, 0, c_sizeOfInfo);
70 | return myString.Substring(0, myString.IndexOf('\0'));
71 | }
72 | }
73 |
74 | public string TargetName
75 | {
76 | get
77 | {
78 | var myString = Encoding.UTF8.GetString(_rawInfo, c_sizeOfInfo, c_sizeOfTargetName);
79 | return myString.Substring(0, myString.IndexOf('\0'));
80 | }
81 | }
82 |
83 | public string PlatformName
84 | {
85 | get
86 | {
87 | var myString = Encoding.UTF8.GetString(_rawInfo, c_sizeOfInfo + c_sizeOfTargetName, c_sizeOfPlatformName);
88 | return myString.Substring(0, myString.IndexOf('\0'));
89 | }
90 | }
91 |
92 | public string PlatformInfo
93 | {
94 | get
95 | {
96 | if (_rawInfo.Length == TotalSizeOfRaw - c_sizeOfVersion)
97 | {
98 | var myString = Encoding.UTF8.GetString(_rawInfo, c_sizeOfInfo + c_sizeOfTargetName + c_sizeOfPlatformName, c_sizeOfPlatformInfo);
99 | return myString.Substring(0, myString.IndexOf('\0'));
100 | }
101 | else
102 | {
103 | // old version format, no PlatformInfo
104 | return "";
105 | }
106 | }
107 | }
108 |
109 | public override string ToString()
110 | {
111 | try
112 | {
113 | StringBuilder output = new StringBuilder();
114 |
115 | output.AppendLine($"HAL build info: {Info?.ToString()}");
116 | output.AppendLine($" Target: {TargetName?.ToString()}");
117 | output.AppendLine($" Platform: {PlatformName?.ToString()}");
118 | output.AppendLine($" Type: {PlatformInfo}");
119 | output.AppendLine();
120 |
121 | return output.ToString();
122 | }
123 | catch
124 | {
125 | // OK to fail. Most likely because of a formatting issue.
126 | }
127 |
128 | return "ReleaseInfo is not valid!";
129 | }
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/TargetInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) .NET Foundation and Contributors
3 | // Portions Copyright (c) Microsoft Corporation. All rights reserved.
4 | // See LICENSE file in the project root for full license information.
5 | //
6 |
7 | using System;
8 | using System.Text;
9 |
10 | namespace nanoFramework.Tools.Debugger.WireProtocol
11 | {
12 | public class TargetInfo : IConverter
13 | {
14 | private const int c_sizeOfVersion = 8;
15 | private const int c_sizeOfInfo = 128;
16 | private const int c_sizeOfTargetName = 32;
17 | private const int c_sizeOfPlatformName = 32;
18 | private const int c_sizeOfPlatformInfo = 128;
19 |
20 | // these constants below hold the size of the current version
21 | // they are used to init the byte array with raw data and trying to check if there is enough data for PlatformInfo
22 | private const int TotalSizeOfRaw = c_sizeOfVersion + c_sizeOfVersion + c_sizeOfInfo + c_sizeOfTargetName + c_sizeOfPlatformName + c_sizeOfPlatformInfo;
23 |
24 | private readonly VersionStruct _booterVersion;
25 | private readonly VersionStruct _clrVersion;
26 | private byte[] _rawInfo;
27 |
28 | public TargetInfo(int dataLength = TotalSizeOfRaw)
29 | {
30 | _booterVersion = new VersionStruct();
31 | _clrVersion = new VersionStruct();
32 |
33 | InitFields(dataLength);
34 | }
35 |
36 | private void InitFields(int dataLength)
37 | {
38 | if (dataLength == TotalSizeOfRaw)
39 | {
40 | // need to subtract the size of both version fields
41 | _rawInfo = new byte[TotalSizeOfRaw - c_sizeOfVersion - c_sizeOfVersion];
42 | }
43 | else
44 | {
45 | // shouldn't be here
46 | throw new ArgumentOutOfRangeException($"{nameof(dataLength)} has an invalid value");
47 | }
48 | }
49 |
50 | public void PrepareForDeserialize(int size, byte[] data, Converter converter)
51 | {
52 | // need to subtract the size of both version fields
53 | _rawInfo = new byte[data.Length - c_sizeOfVersion - c_sizeOfVersion];
54 | }
55 |
56 | public Version BooterVersion => _booterVersion.Version;
57 |
58 | public Version CLRVersion => _clrVersion.Version;
59 |
60 | public string Info
61 | {
62 | get
63 | {
64 | var myString = Encoding.UTF8.GetString(_rawInfo, 0, c_sizeOfInfo);
65 | return myString.Substring(0, myString.IndexOf('\0'));
66 | }
67 | }
68 |
69 | public string TargetName
70 | {
71 | get
72 | {
73 | var myString = Encoding.UTF8.GetString(_rawInfo, c_sizeOfInfo, c_sizeOfTargetName);
74 | return myString.Substring(0, myString.IndexOf('\0'));
75 | }
76 | }
77 |
78 | public string PlatformName
79 | {
80 | get
81 | {
82 | var myString = Encoding.UTF8.GetString(_rawInfo, c_sizeOfInfo + c_sizeOfTargetName, c_sizeOfPlatformName);
83 | return myString.Substring(0, myString.IndexOf('\0'));
84 | }
85 | }
86 |
87 | public string PlatformInfo
88 | {
89 | get
90 | {
91 | if (_rawInfo.Length == TotalSizeOfRaw - c_sizeOfVersion - c_sizeOfVersion)
92 | {
93 | var myString = Encoding.UTF8.GetString(_rawInfo, c_sizeOfInfo + c_sizeOfTargetName + c_sizeOfPlatformName, c_sizeOfPlatformInfo);
94 | return myString.Substring(0, myString.IndexOf('\0'));
95 | }
96 | else
97 | {
98 | // old version format, no PlatformInfo
99 | return "";
100 | }
101 | }
102 | }
103 |
104 | public override string ToString()
105 | {
106 | try
107 | {
108 | StringBuilder output = new StringBuilder();
109 |
110 | output.AppendLine($"HAL build info: {Info?.ToString()}");
111 | output.AppendLine($" Target: {TargetName?.ToString()}");
112 | output.AppendLine($" Platform: {PlatformName?.ToString()}");
113 | output.AppendLine($" nanoBooter: v{BooterVersion}");
114 | output.AppendLine($" nanoCLR: v{CLRVersion}");
115 | output.AppendLine($" Type: {PlatformInfo}");
116 | output.AppendLine();
117 |
118 | return output.ToString();
119 | }
120 | catch
121 | {
122 | // OK to fail. Most likely because of a formatting issue.
123 | }
124 |
125 | return "ReleaseInfo is not valid!";
126 | }
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/nanoFramework.Tools.Debugger.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.1.32228.430
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debug Components", "Debug Components", "{5318C561-62E1-49CB-8A94-D704CFBAEE5B}"
7 | EndProject
8 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "nanoFramework.Tools.DebugLibrary.Shared", "nanoFramework.Tools.DebugLibrary.Shared\nanoFramework.Tools.DebugLibrary.Shared.shproj", "{31472CAE-4B1A-4AB9-9B2A-8F28DBE01BCF}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nanoFramework.Tools.DebugLibrary.Net", "nanoFramework.Tools.DebugLibrary.Net\nanoFramework.Tools.DebugLibrary.Net.csproj", "{101D57AD-D22F-4905-A992-DE15E723F164}"
11 | EndProject
12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test Apps", "Test Apps", "{4BB47DB4-92A3-4DE9-81C0-462373258F49}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serial Test App WPF", "USB Test App WPF\Serial Test App WPF.csproj", "{654CCB72-B942-4FFA-AA2B-17F9F85310EE}"
15 | EndProject
16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C4E43092-51E8-46C3-8C7A-FD05E9A29FE2}"
17 | ProjectSection(SolutionItems) = preProject
18 | ..\azure-pipelines.yml = ..\azure-pipelines.yml
19 | README-BEFORE-UPDATE-REFS.txt = README-BEFORE-UPDATE-REFS.txt
20 | ..\README.md = ..\README.md
21 | version.json = version.json
22 | EndProjectSection
23 | EndProject
24 | Global
25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
26 | Debug|Any CPU = Debug|Any CPU
27 | Debug|ARM = Debug|ARM
28 | Debug|x64 = Debug|x64
29 | Debug|x86 = Debug|x86
30 | Release|Any CPU = Release|Any CPU
31 | Release|ARM = Release|ARM
32 | Release|x64 = Release|x64
33 | Release|x86 = Release|x86
34 | EndGlobalSection
35 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
36 | {101D57AD-D22F-4905-A992-DE15E723F164}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {101D57AD-D22F-4905-A992-DE15E723F164}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {101D57AD-D22F-4905-A992-DE15E723F164}.Debug|ARM.ActiveCfg = Debug|Any CPU
39 | {101D57AD-D22F-4905-A992-DE15E723F164}.Debug|ARM.Build.0 = Debug|Any CPU
40 | {101D57AD-D22F-4905-A992-DE15E723F164}.Debug|x64.ActiveCfg = Debug|Any CPU
41 | {101D57AD-D22F-4905-A992-DE15E723F164}.Debug|x64.Build.0 = Debug|Any CPU
42 | {101D57AD-D22F-4905-A992-DE15E723F164}.Debug|x86.ActiveCfg = Debug|Any CPU
43 | {101D57AD-D22F-4905-A992-DE15E723F164}.Debug|x86.Build.0 = Debug|Any CPU
44 | {101D57AD-D22F-4905-A992-DE15E723F164}.Release|Any CPU.ActiveCfg = Release|Any CPU
45 | {101D57AD-D22F-4905-A992-DE15E723F164}.Release|Any CPU.Build.0 = Release|Any CPU
46 | {101D57AD-D22F-4905-A992-DE15E723F164}.Release|ARM.ActiveCfg = Release|Any CPU
47 | {101D57AD-D22F-4905-A992-DE15E723F164}.Release|ARM.Build.0 = Release|Any CPU
48 | {101D57AD-D22F-4905-A992-DE15E723F164}.Release|x64.ActiveCfg = Release|Any CPU
49 | {101D57AD-D22F-4905-A992-DE15E723F164}.Release|x64.Build.0 = Release|Any CPU
50 | {101D57AD-D22F-4905-A992-DE15E723F164}.Release|x86.ActiveCfg = Release|Any CPU
51 | {101D57AD-D22F-4905-A992-DE15E723F164}.Release|x86.Build.0 = Release|Any CPU
52 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
54 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE}.Debug|ARM.ActiveCfg = Debug|Any CPU
55 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE}.Debug|ARM.Build.0 = Debug|Any CPU
56 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE}.Debug|x64.ActiveCfg = Debug|Any CPU
57 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE}.Debug|x64.Build.0 = Debug|Any CPU
58 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE}.Debug|x86.ActiveCfg = Debug|Any CPU
59 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE}.Debug|x86.Build.0 = Debug|Any CPU
60 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
61 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE}.Release|ARM.ActiveCfg = Release|Any CPU
62 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE}.Release|ARM.Build.0 = Release|Any CPU
63 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE}.Release|x64.ActiveCfg = Release|Any CPU
64 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE}.Release|x86.ActiveCfg = Release|Any CPU
65 | EndGlobalSection
66 | GlobalSection(SolutionProperties) = preSolution
67 | HideSolutionNode = FALSE
68 | EndGlobalSection
69 | GlobalSection(NestedProjects) = preSolution
70 | {31472CAE-4B1A-4AB9-9B2A-8F28DBE01BCF} = {5318C561-62E1-49CB-8A94-D704CFBAEE5B}
71 | {101D57AD-D22F-4905-A992-DE15E723F164} = {5318C561-62E1-49CB-8A94-D704CFBAEE5B}
72 | {654CCB72-B942-4FFA-AA2B-17F9F85310EE} = {4BB47DB4-92A3-4DE9-81C0-462373258F49}
73 | EndGlobalSection
74 | GlobalSection(ExtensibilityGlobals) = postSolution
75 | SolutionGuid = {0E005ECA-A03A-4A11-BB97-0C89AEC45CF3}
76 | EndGlobalSection
77 | GlobalSection(SharedMSBuildProjectFiles) = preSolution
78 | nanoFramework.Tools.DebugLibrary.Shared\nanoFramework.Tools.DebugLibrary.Net.projitems*{101d57ad-d22f-4905-a992-de15e723f164}*SharedItemsImports = 5
79 | nanoFramework.Tools.DebugLibrary.Shared\nanoFramework.Tools.DebugLibrary.Net.projitems*{31472cae-4b1a-4ab9-9b2a-8f28dbe01bcf}*SharedItemsImports = 13
80 | EndGlobalSection
81 | EndGlobal
82 |
--------------------------------------------------------------------------------