diff --git a/Nuspec and stub-generation.md b/Nuspec and stub-generation.md
new file mode 100644
index 0000000..2246f62
--- /dev/null
+++ b/Nuspec and stub-generation.md
@@ -0,0 +1,20 @@
+# Nuspec / NuGet packages
+
+The `nanoFramework.Device.Can` namespace implements the classical CAN (2.0, ISO 11898) protocol. As the CAN protocol only covers the physical and data link layers of the OSI model, additional protocols (e.g., CAN-TP) are required to cover the other layers. The code for those protocols can be based on the device independent class library `nanoFramework.Device.Can.Core` and debugged/tested on any device, including the Virtual nanoDevice. For an application one of the device dependent class libraries like `nanoFramework.Device.Can.Stm32` should be added to connect to a device that is connected to the CAN bus.
+
+Hence the NuGet package for a device dependent class library should include only the assemblies for that library and not the `nanoFramework.Device.Can.Core` files. It should have the `nanoFramework.Device.Can.Core` NuGet package as dependency, with the same version as the device dependent NuGet package (`$version$`). The project for a device dependent class library does not reference the `nanoFramework.Device.Can.Core` NuGet package but references the `nanoFramework.Device.Can.Core.nfproj` instead.
+
+# Stub generation
+
+If a device dependent class library requires part of its implementation to be a native component, it should be configured to generate stubs for the native code. It is very likely that the native code also requires information about classes and enumerations that are part of the `nanoFramework.Device.Can.Core` class library. As that is a pure .NET library, there is (at the time of writing) no way to generate header files from `nanoFramework.Device.Can.Core`.
+
+As a workaround, the `nanoFramework.Device.Can.sln` solution has an extra configuration **GenerateStubs** in addition to *Debug* and *Release*. Select that configuration to generate the stubs. The stubs are placed in, e.g., the `nanoFramework.Device.Can.Esp32\bin\GenerateStubs\Stubs` directory. The stubs in other directories, e.g., `nanoFramework.Device.Can.Esp32\bin\Debug\Stubs`, are not complete.
+
+The *nfproj* project for the device dependent class library has to be prepared for that (see *nanoFramework.Device.Can.Esp32.nfproj* as example):
+
+- Remove the direct reference to `nanoFramework.Device.Can.Core` from the class library's project.
+- Create a copy of `nanoFramework.Device.Can.Esp32.native.props` as, e.g., `nanoFramework.Device.Can.MyDevice.native.props` in the class library's project directory.
+- Modify the *nfproj* file and add `` just before the first ``
+- Change the `NF_GenerateSkeletonProjectName` and `Name` in `nanoFramework.Device.Can.MyDevice.native.props`.
+- Ensure the relevant code files from `nanoFramework.Device.Can.Core` are listed in `nanoFramework.Device.Can.MyDevice.native.props`.
+- Open the `nanoFramework.Device.Can.sln` solution file in Visual Studio, Open the `Configuration Manager` for the solution, select `GenerateStubs` and select for the class library configuration `GenerateStubs` and check that the project is built for this configuration.
diff --git a/Stub-generation.md b/Stub-generation.md
deleted file mode 100644
index 9ff5d27..0000000
--- a/Stub-generation.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Stub generation
-
-The libraries that require a native components generate a stub for the native part on each build. The stub is placed in, e.g., the `nanoFramework.Device.Can.Stm32\bin\Release\Stubs` directory.
-
-The native component will probably require access to the common classes in `nanoFramework.Device.Can.Core`. As that library is pure .NET, no stub is required. To generate the stub, select the **GenerateStub** configuration (instead of *Debug* or *Release*) in the *nanoFramework.Device.Can.sln* solution and build the solution. The stub will be placed in the `nanoFramework.Device.Can.Core\bin'\GenerateStubs\Stubs` directory.
diff --git a/nanoFramework.Device.Can.Core/CanController.cs b/nanoFramework.Device.Can.Core/CanController.cs
index 9706f93..3ae4108 100644
--- a/nanoFramework.Device.Can.Core/CanController.cs
+++ b/nanoFramework.Device.Can.Core/CanController.cs
@@ -1,7 +1,5 @@
-//
-// Copyright (c) .NET Foundation and Contributors
-// See LICENSE file in the project root for full license information.
-//
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.CompilerServices;
@@ -67,10 +65,11 @@ internal CanController(string controller, CanSettings settings)
// call native init to allow HAL/PAL inits related with Can hardware
NativeInit();
+#if !GENERATESTUBS
// add controller to collection, with the ID as key
// ** just the index number ***
CanControllerManager.ControllersCollection.Add(this);
-
+#endif
// add the controller to the event listener in order to receive the callbacks from the native interrupts
s_eventListener.AddCanController(this);
}
@@ -102,6 +101,7 @@ public static CanController FromId(string controllerId, CanSettings settings)
internal static CanController FindController(int index)
{
+#if !GENERATESTUBS
for (int i = 0; i < CanControllerManager.ControllersCollection.Count; i++)
{
if (((CanController)CanControllerManager.ControllersCollection[i])._controllerId == index)
@@ -109,7 +109,7 @@ internal static CanController FindController(int index)
return (CanController)CanControllerManager.ControllersCollection[i];
}
}
-
+#endif
return null;
}
@@ -121,9 +121,10 @@ private void Dispose(bool disposing)
{
if (disposing)
{
+#if !GENERATESTUBS
// remove controller from controller collection
CanControllerManager.ControllersCollection.Remove(this);
-
+#endif
// remove the controller from the event listener
s_eventListener.RemoveCanController(_controllerId);
}
diff --git a/nanoFramework.Device.Can.Core/nanoFramework.Device.Can.Core.nfproj b/nanoFramework.Device.Can.Core/nanoFramework.Device.Can.Core.nfproj
index fbb61ef..c5ad370 100644
--- a/nanoFramework.Device.Can.Core/nanoFramework.Device.Can.Core.nfproj
+++ b/nanoFramework.Device.Can.Core/nanoFramework.Device.Can.Core.nfproj
@@ -1,24 +1,6 @@
-
-
- Debug
- AnyCPU
-
-
- GenerateStubs
- AnyCPU
-
-
- Release
- AnyCPU
-
-
- StubGeneration
- AnyCPU
-
-
$(MSBuildExtensionsPath)\nanoFramework\v1.0\
@@ -48,20 +30,6 @@
false
-
- True
- $(DefineConstants);STUBGENERATION
-
-
- bin\$(Configuration)\Stubs
- nf_device_can_core_native
- nanoFramework.Device.Can.Core
-
-
-
- false
-
-
diff --git a/nanoFramework.Device.Can.Esp32.nuspec b/nanoFramework.Device.Can.Esp32.nuspec
index b384dbf..e3d9e2e 100644
--- a/nanoFramework.Device.Can.Esp32.nuspec
+++ b/nanoFramework.Device.Can.Esp32.nuspec
@@ -21,6 +21,7 @@ This package requires a target with nanoFramework.Device.Can.Esp32 v$nativeVersi
nanoFramework C# csharp netmf netnf canbus can
+
diff --git a/nanoFramework.Device.Can.Esp32/nanoFramework.Device.Can.Esp32.native.props b/nanoFramework.Device.Can.Esp32/nanoFramework.Device.Can.Esp32.native.props
new file mode 100644
index 0000000..2686c1a
--- /dev/null
+++ b/nanoFramework.Device.Can.Esp32/nanoFramework.Device.Can.Esp32.native.props
@@ -0,0 +1,47 @@
+
+
+
+
+ Debug
+ AnyCPU
+
+
+ GenerateStubs
+ AnyCPU
+
+
+ Release
+ AnyCPU
+
+
+
+ True
+
+
+ $(DefineConstants);GENERATESTUBS
+
+
+ bin\$(Configuration)\Stubs
+ nf_device_can_esp32_native
+ nanoFramework.Device.Can.Esp32
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nanoFramework.Device.Can.Esp32/nanoFramework.Device.Can.Esp32.nfproj b/nanoFramework.Device.Can.Esp32/nanoFramework.Device.Can.Esp32.nfproj
index 12fc502..6c7a791 100644
--- a/nanoFramework.Device.Can.Esp32/nanoFramework.Device.Can.Esp32.nfproj
+++ b/nanoFramework.Device.Can.Esp32/nanoFramework.Device.Can.Esp32.nfproj
@@ -1,6 +1,7 @@
+
$(MSBuildExtensionsPath)\nanoFramework\v1.0\
@@ -16,7 +17,6 @@
nanoFramework.Device.Can
nanoFramework.Device.Can.Esp32
v1.0
- True
bin\$(Configuration)\nanoFramework.Device.Can.Esp32.xml
true
true
@@ -31,16 +31,6 @@
false
-
- bin\$(Configuration)\Stubs
- nf_device_can_esp32_native
- nanoFramework.Device.Can.Esp32
-
-
-
- false
-
-
@@ -53,9 +43,12 @@
..\packages\nanoFramework.CoreLibrary.1.16.11\lib\mscorlib.dll
+
+ ..\packages\nanoFramework.Runtime.Events.1.11.29\lib\nanoFramework.Runtime.Events.dll
+
-
+
diff --git a/nanoFramework.Device.Can.Esp32/packages.config b/nanoFramework.Device.Can.Esp32/packages.config
index 63b66bd..2db295a 100644
--- a/nanoFramework.Device.Can.Esp32/packages.config
+++ b/nanoFramework.Device.Can.Esp32/packages.config
@@ -1,5 +1,6 @@
+
\ No newline at end of file
diff --git a/nanoFramework.Device.Can.Esp32/packages.lock.json b/nanoFramework.Device.Can.Esp32/packages.lock.json
index 1f561cc..0ab0f5c 100644
--- a/nanoFramework.Device.Can.Esp32/packages.lock.json
+++ b/nanoFramework.Device.Can.Esp32/packages.lock.json
@@ -8,6 +8,12 @@
"resolved": "1.16.11",
"contentHash": "2XW+Zn0lQ+lOcxDbB1l2ga2rNoj9Jv2IeJwXE4ka1r+swmxn5N/otlMJVEXJgK8trUeD/E8T7+J7dXjU8UReHw=="
},
+ "nanoFramework.Runtime.Events": {
+ "type": "Direct",
+ "requested": "[1.11.29, 1.11.29]",
+ "resolved": "1.11.29",
+ "contentHash": "y3Y0SNfr1afMor4xrsiB1ETldjKvmnzBTcEH5gizFFXw3RNBB/N8npWqkCJn4HZS0TEENlH2vVrib3bWYMx5+Q=="
+ },
"Nerdbank.GitVersioning": {
"type": "Direct",
"requested": "[3.7.115, 3.7.115]",
diff --git a/nanoFramework.Device.Can.Mcp2515/nanoFramework.Device.Can.Mcp2515.nfproj b/nanoFramework.Device.Can.Mcp2515/nanoFramework.Device.Can.Mcp2515.nfproj
index 65eb17d..b9bfe76 100644
--- a/nanoFramework.Device.Can.Mcp2515/nanoFramework.Device.Can.Mcp2515.nfproj
+++ b/nanoFramework.Device.Can.Mcp2515/nanoFramework.Device.Can.Mcp2515.nfproj
@@ -51,6 +51,9 @@
+
+
+
diff --git a/nanoFramework.Device.Can.sln b/nanoFramework.Device.Can.sln
index 902148c..8830ac4 100644
--- a/nanoFramework.Device.Can.sln
+++ b/nanoFramework.Device.Can.sln
@@ -12,7 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packages and stubs", "Packa
nanoFramework.Device.Can.Stm32.nuspec = nanoFramework.Device.Can.Stm32.nuspec
NuGet.Config = NuGet.Config
README.md = README.md
- Stub-generation.md = Stub-generation.md
+ Nuspec and stub-generation.md = Nuspec and stub-generation.md
version.json = version.json
EndProjectSection
EndProject
@@ -32,16 +32,15 @@ Global
{99CA76E4-D76F-42C9-9E62-49C2F499AA02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99CA76E4-D76F-42C9-9E62-49C2F499AA02}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99CA76E4-D76F-42C9-9E62-49C2F499AA02}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {99CA76E4-D76F-42C9-9E62-49C2F499AA02}.GenerateStubs|Any CPU.ActiveCfg = GenerateStubs|Any CPU
- {99CA76E4-D76F-42C9-9E62-49C2F499AA02}.GenerateStubs|Any CPU.Build.0 = GenerateStubs|Any CPU
+ {99CA76E4-D76F-42C9-9E62-49C2F499AA02}.GenerateStubs|Any CPU.ActiveCfg = Debug|Any CPU
{99CA76E4-D76F-42C9-9E62-49C2F499AA02}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99CA76E4-D76F-42C9-9E62-49C2F499AA02}.Release|Any CPU.Build.0 = Release|Any CPU
{99CA76E4-D76F-42C9-9E62-49C2F499AA02}.Release|Any CPU.Deploy.0 = Release|Any CPU
{7CE9A616-F4A4-43EA-B067-526155C823AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CE9A616-F4A4-43EA-B067-526155C823AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CE9A616-F4A4-43EA-B067-526155C823AC}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {7CE9A616-F4A4-43EA-B067-526155C823AC}.GenerateStubs|Any CPU.ActiveCfg = Debug|Any CPU
- {7CE9A616-F4A4-43EA-B067-526155C823AC}.GenerateStubs|Any CPU.Build.0 = Debug|Any CPU
+ {7CE9A616-F4A4-43EA-B067-526155C823AC}.GenerateStubs|Any CPU.ActiveCfg = GenerateStubs|Any CPU
+ {7CE9A616-F4A4-43EA-B067-526155C823AC}.GenerateStubs|Any CPU.Build.0 = GenerateStubs|Any CPU
{7CE9A616-F4A4-43EA-B067-526155C823AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CE9A616-F4A4-43EA-B067-526155C823AC}.Release|Any CPU.Build.0 = Release|Any CPU
{7CE9A616-F4A4-43EA-B067-526155C823AC}.Release|Any CPU.Deploy.0 = Release|Any CPU
@@ -49,7 +48,6 @@ Global
{695177A1-93CE-4AC4-88A2-EEFDDF327D0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{695177A1-93CE-4AC4-88A2-EEFDDF327D0F}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{695177A1-93CE-4AC4-88A2-EEFDDF327D0F}.GenerateStubs|Any CPU.ActiveCfg = Debug|Any CPU
- {695177A1-93CE-4AC4-88A2-EEFDDF327D0F}.GenerateStubs|Any CPU.Build.0 = Debug|Any CPU
{695177A1-93CE-4AC4-88A2-EEFDDF327D0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{695177A1-93CE-4AC4-88A2-EEFDDF327D0F}.Release|Any CPU.Build.0 = Release|Any CPU
{695177A1-93CE-4AC4-88A2-EEFDDF327D0F}.Release|Any CPU.Deploy.0 = Release|Any CPU
diff --git a/spelling_exclusion.dic b/spelling_exclusion.dic
index 8c0e1f8..838e549 100644
--- a/spelling_exclusion.dic
+++ b/spelling_exclusion.dic
@@ -1 +1,3 @@
nano
+nfproj
+Nuspec