Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 15 commits
  • 12 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jan 05, 2016
@ThadHouse ThadHouse Bumps version number to 2016.0.1
ba30a0c
Commits on Jan 15, 2016
@ThadHouse ThadHouse Fixes potential race conditions in static NetworkTables methods
Possible for them to be called at multiple times.
d942de3
@ThadHouse ThadHouse GetTable does not prepend slash if key starts with it
GetTable("/foo") and GetTable("foo") are now equal.
1d54164
Commits on Jan 16, 2016
@ThadHouse ThadHouse Should properly enable ArmHF running wihtout anything else needed.
08ac214
Commits on Jan 18, 2016
@ThadHouse ThadHouse Fixes extracting of libstdc++.so
Extracts properly. However there is no way to set LD_LIBRARY_PATH
progammatically. Which mean the user will have to set it manually. I
need to write a readme on how to do this.
31632da
Commits on Jan 19, 2016
@ThadHouse ThadHouse Clears CoreMethods callback dictionaries on shutdown
Partial fix for #19.  Would still invalidate any NetworkTable objects,
but there might not be an easy way around that.
23af27a
Commits on Jan 21, 2016
@ThadHouse ThadHouse Fixes native libstdc++.so.6 extraction.
Give a better error message too if somebody wants to fix it.
08f512d
@ThadHouse ThadHouse Gives a warning message if somebody trys to run on Pi 1.
0d74aec
Commits on Feb 02, 2016
@ThadHouse ThadHouse Extracts native library to a unique location if the original extracti…
…on fails

Should fix #20. Needs testing.
d63ba94
Commits on Feb 03, 2016
@ThadHouse ThadHouse First Part of OnUnload Changes
Unloads the library on App Domain close or Process exit.
0eca370
@ThadHouse ThadHouse OnUnload Changes Part 2
If not the RoboRIO, delete the temp file. All other systems have fast
extraction.
1f7980a
@ThadHouse ThadHouse Always uses a unique temp file
The reason I originally implemented keeping the same file was that the
original ntcore library was over 7mb. Its now down to 500kb, so its
quicker to just extract a new copy. So reverted to just always using a
unique temp file for the library. With the hooks to delete the file on
unload, this should be fine.
f754890
Commits on Feb 06, 2016
@jkoritzinsky jkoritzinsky Merge pull request #21 from robotdotnet/OnUnloadChanges
On unload changes
6d9772c
@ThadHouse ThadHouse Updates IRemote to return the ConnectionInfo of the connected remote
Also added a delegate listener, to match the table listener changes.
Fixes #22
27f7c68
Commits on Feb 07, 2016
@ThadHouse ThadHouse Merge pull request #23 from robotdotnet/RemoteChanges
Updates IRemote to return the ConnectionInfo of the connected remote
70db749
@@ -27,12 +27,12 @@ internal class MockConnectionListener : IRemoteConnectionListener
public IRemote ConnectedRemote = null;
public IRemote DisconnectedRemote = null;
- public void Connected(IRemote remote)
+ public void Connected(IRemote remote, ConnectionInfo info)
{
ConnectedRemote = remote;
}
- public void Disconnected(IRemote remote)
+ public void Disconnected(IRemote remote, ConnectionInfo info)
{
DisconnectedRemote = remote;
}
@@ -525,13 +525,19 @@ internal static void StopClient()
StopRpcServer();
StopNotifier();
Interop.NT_StopClient();
+ //Clear callback dictionaries
+ s_entryCallbacks.Clear();
+ s_connectionCallbacks.Clear();
}
internal static void StopServer()
{
StopRpcServer();
StopNotifier();
Interop.NT_StopServer();
+ //Clear callback dictionaries
+ s_entryCallbacks.Clear();
+ s_connectionCallbacks.Clear();
}
internal static void StopNotifier()
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// ReSharper disable InconsistentNaming
@@ -20,6 +21,9 @@ internal class Interop
// ReSharper disable PrivateFieldCanBeConvertedToLocalVariable
private static readonly IntPtr s_library;
private static readonly ILibraryLoader s_loader;
+ private static readonly OsType s_osType;
+ private static string s_libraryLocation = null;
+ private static bool s_useCommandLineFile = false;
// ReSharper restore PrivateFieldCanBeConvertedToLocalVariable
static Interop()
@@ -28,8 +32,6 @@ static Interop()
{
try
{
- bool useCommandLineFile = false;
- string extractedLocation = null;
string[] commandArgs = Environment.GetCommandLineArgs();
foreach (var commandArg in commandArgs)
@@ -44,33 +46,56 @@ static Interop()
//If the file exists, just return it so dlopen can load it.
if (File.Exists(file))
{
- extractedLocation = file;
- useCommandLineFile = true;
+ s_libraryLocation = file;
+ s_useCommandLineFile = true;
}
}
}
- OsType type = LoaderUtilities.GetOsType();
+ s_osType = LoaderUtilities.GetOsType();
- if (!useCommandLineFile)
+ if (!s_useCommandLineFile)
{
-
- if (!LoaderUtilities.CheckOsValid(type))
+
+ if (!LoaderUtilities.CheckOsValid(s_osType))
throw new InvalidOperationException("OS Not Supported");
string embeddedResourceLocation;
- LoaderUtilities.GetLibraryName(type, out embeddedResourceLocation, out extractedLocation);
+ LoaderUtilities.GetLibraryName(s_osType, out embeddedResourceLocation, out s_libraryLocation);
bool successfullyExtracted = LoaderUtilities.ExtractLibrary(embeddedResourceLocation,
- extractedLocation);
+ ref s_libraryLocation);
if (!successfullyExtracted)
throw new FileNotFoundException(
"Library file could not be found in the resorces. Please contact RobotDotNet for support for this issue");
}
- s_library = LoaderUtilities.LoadLibrary(extractedLocation, type, out s_loader);
+ if (s_osType == OsType.Armv7HardFloat)
+ {
+ //Make sure the proper libstdc++.so.6 gets extracted.
+ string resourceLocation = "NetworkTables.NativeLibraries.armv7.libstdc++.so";
+ string extractLoc = "libstdc++.so.6";
+ LoaderUtilities.ExtractLibrary(resourceLocation, ref extractLoc);
+ }
- if (s_library == IntPtr.Zero) throw new BadImageFormatException($"Library file {extractedLocation} could not be loaded successfully.");
+ s_library = LoaderUtilities.LoadLibrary(s_libraryLocation, s_osType, out s_loader);
+
+ if (s_library == IntPtr.Zero)
+ {
+ if (s_osType == OsType.Armv7HardFloat)
+ {
+ //We are arm v7. We might need the special libstdc++.so.6;
+ Console.WriteLine("You are on an Arm V7 device. On most of these devices, a "
+ + "special library needs to be loaded. This library has been extracted" +
+ " to the current directory. Please prepend your run command with\n" +
+ "env LD_LIBRARY_PATH=.:LD_LIBRARY_PATH yourcommand\nand run again.");
+ throw new InvalidOperationException("Follow the instructions printed above to solve this error.");
+ }
+ else
+ {
+ throw new BadImageFormatException($"Library file {s_libraryLocation} could not be loaded successfully.");
+ }
+ }
InitializeDelegates(s_library, s_loader);
}
@@ -82,8 +107,10 @@ static Interop()
}
s_libraryLoaded = true;
- //Adds our unload code.
+ //Adds our unload code. OK to set both as only 1
+ //Will ever get called.
AppDomain.CurrentDomain.ProcessExit += OnProcessExit;
+ AppDomain.CurrentDomain.DomainUnload += OnProcessExit;
}
}
@@ -96,6 +123,22 @@ private static void OnProcessExit(object sender, EventArgs e)
NT_StopServer();
NT_StopRpcServer();
NT_StopNotifier();
+
+ s_loader.UnloadLibrary(s_library);
+
+ try
+ {
+ //Don't delete file if we are using a specified file.
+ if (!s_useCommandLineFile && File.Exists(s_libraryLocation))
+ {
+ File.Delete(s_libraryLocation);
+ }
+ }
+ catch
+ {
+ //Any errors just ignore.
+ }
+
}
private static void InitializeDelegates(IntPtr library, ILibraryLoader loader)
@@ -7,6 +7,8 @@ internal interface ILibraryLoader
{
IntPtr LoadLibrary(string filename);
IntPtr GetProcAddress(IntPtr dllHandle, string name);
+
+ void UnloadLibrary(IntPtr handle);
}
[ExcludeFromCodeCoverage]
@@ -28,11 +30,19 @@ IntPtr ILibraryLoader.GetProcAddress(IntPtr dllHandle, string name)
return addr;
}
+ void ILibraryLoader.UnloadLibrary(IntPtr handle)
+ {
+ FreeLibrary(handle);
+ }
+
[DllImport("kernel32")]
private static extern IntPtr LoadLibrary(string fileName);
[DllImport("kernel32.dll")]
private static extern IntPtr GetProcAddress(IntPtr handle, string procedureName);
+
+ [DllImport("kernel32")]
+ private static extern bool FreeLibrary(IntPtr handle);
}
[ExcludeFromCodeCoverage]
@@ -62,6 +72,11 @@ IntPtr ILibraryLoader.GetProcAddress(IntPtr dllHandle, string name)
return result;
}
+ void ILibraryLoader.UnloadLibrary(IntPtr handle)
+ {
+ dlclose(handle);
+ }
+
[DllImport("libdl.so")]
private static extern IntPtr dlopen(string fileName, int flags);
@@ -70,6 +85,9 @@ IntPtr ILibraryLoader.GetProcAddress(IntPtr dllHandle, string name)
[DllImport("libdl.so")]
private static extern IntPtr dlerror();
+
+ [DllImport("libdl.so")]
+ private static extern int dlclose(IntPtr handle);
}
@@ -100,6 +118,11 @@ IntPtr ILibraryLoader.GetProcAddress(IntPtr dllHandle, string name)
return result;
}
+ void ILibraryLoader.UnloadLibrary(IntPtr handle)
+ {
+ dlclose(handle);
+ }
+
[DllImport("dl")]
private static extern IntPtr dlopen(string fileName, int flags);
@@ -108,6 +131,9 @@ IntPtr ILibraryLoader.GetProcAddress(IntPtr dllHandle, string name)
[DllImport("dl")]
private static extern IntPtr dlerror();
+
+ [DllImport("dl")]
+ private static extern int dlclose(IntPtr handle);
}
@@ -138,6 +164,11 @@ IntPtr ILibraryLoader.GetProcAddress(IntPtr dllHandle, string name)
return result;
}
+ void ILibraryLoader.UnloadLibrary(IntPtr handle)
+ {
+ dlclose(handle);
+ }
+
[DllImport("dl")]
private static extern IntPtr dlopen(string fileName, int flags);
@@ -146,6 +177,9 @@ IntPtr ILibraryLoader.GetProcAddress(IntPtr dllHandle, string name)
[DllImport("dl")]
private static extern IntPtr dlerror();
+
+ [DllImport("dl")]
+ private static extern int dlclose(IntPtr handle);
}
[ExcludeFromCodeCoverage]
@@ -175,6 +209,11 @@ IntPtr ILibraryLoader.GetProcAddress(IntPtr dllHandle, string name)
return result;
}
+ void ILibraryLoader.UnloadLibrary(IntPtr handle)
+ {
+ dlclose(handle);
+ }
+
[DllImport("libdl-2.20.so")]
private static extern IntPtr dlopen(string fileName, int flags);
@@ -183,5 +222,8 @@ IntPtr ILibraryLoader.GetProcAddress(IntPtr dllHandle, string name)
[DllImport("libdl-2.20.so")]
private static extern IntPtr dlerror();
+
+ [DllImport("libdl-2.20.so")]
+ private static extern int dlclose(IntPtr handle);
}
}
Oops, something went wrong.

No commit comments for this range