Ejemplo n.º 1
0
 public static APIVersion GetAPIVersion()
 {
     lock (lockObject)
     {
         if (driver == null)
         {
             driver = new CANSparkMaxDriverNative(NativeLibraryLoader.LoadNativeLibrary("CANSparkMaxDriver") !);
         }
     }
     return(driver.c_SparkMax_GetAPIVersion());
 }
Ejemplo n.º 2
0
 public static void *Create_Inplace(int deviceId)
 {
     lock (lockObject)
     {
         if (driver == null)
         {
             driver = new CANSparkMaxDriverNative(NativeLibraryLoader.LoadNativeLibrary("CANSparkMaxDriver") !);
         }
     }
     return(driver.c_SparkMax_Create_Inplace(deviceId));
 }
Ejemplo n.º 3
0
        static LibraryLoaderHolder()
        {
            if (!s_libraryLoaded)
            {
                try
                {
                    finalizeLibraryLoader.Ping();
                    string[] commandArgs = Environment.GetCommandLineArgs();
                    foreach (var commandArg in commandArgs)
                    {
                        //search for a line with the prefix "-wpilib:"
                        if (commandArg.ToLower().Contains("-wpilib:"))
                        {
                            //Split line to get the library.
                            int    splitLoc = commandArg.IndexOf(':');
                            string file     = commandArg.Substring(splitLoc + 1);

                            //If the file exists, just return it so dlopen can load it.
                            if (File.Exists(file))
                            {
                                s_libraryLocation    = file;
                                s_useCommandLineFile = true;
                            }
                        }
                    }

                    const string resourceRoot = "FRC.HAL.DesktopLibraries.Libraries.";

#if FALSE
                    s_useCommandLineFile = true;
                    s_libraryLocation    = IntPtr.Size == 8 ?
                                           @"C:\Users\thadh\Documents\GitHub\ThadHouse\MockHalTesting\native\build\binaries\mockhalSharedLibrary\x64\mockhal.dll" :
                                           @"C:\Users\thadh\Documents\GitHub\ThadHouse\MockHalTesting\native\build\binaries\mockhalSharedLibrary\x86\mockhal.dll";
#endif

                    s_nativeLoader = new NativeLibraryLoader();
                    s_nativeLoader.AddLibraryLocation(OsType.Windows32,
                                                      resourceRoot + "x86.mockhal.dll");
                    s_nativeLoader.AddLibraryLocation(OsType.Windows64,
                                                      resourceRoot + "amd64.mockhal.dll");
                    s_nativeLoader.AddLibraryLocation(OsType.roboRIO, "libHALAthena.so");

                    /*
                     * NativeLoader.AddLibraryLocation(OsType.Linux32,
                     * resourceRoot + "x86.libcscore.so");
                     * NativeLoader.AddLibraryLocation(OsType.Linux64,
                     * resourceRoot + "amd64.libcscore.so");
                     * NativeLoader.AddLibraryLocation(OsType.MacOs32,
                     * resourceRoot + "x86.libcscore.dylib");
                     * NativeLoader.AddLibraryLocation(OsType.MacOs64,
                     * resourceRoot + "amd64.libcscore.dylib");
                     */

                    if (s_useCommandLineFile)
                    {
                        s_nativeLoader.LoadNativeLibrary <LibraryLoaderHolder>(s_libraryLocation, true);
                    }
                    else
                    {
                        s_nativeLoader.LoadNativeLibraryFromReflectedAssembly("FRC.HAL.DesktopLibraries");
                        s_libraryLocation = s_nativeLoader.LibraryLocation;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
                    Environment.Exit(1);
                }
                s_runFinalizer  = true;
                s_libraryLoaded = true;
            }
        }
Ejemplo n.º 4
0
        static Interop()
        {
            if (!s_libraryLoaded)
            {
                try
                {
                    finalizeInterop.Ping();
                    string[] commandArgs = Environment.GetCommandLineArgs();
                    foreach (var commandArg in commandArgs)
                    {
                        //search for a line with the prefix "-ntcore:"
                        if (commandArg.ToLower().Contains("-ntcore:"))
                        {
                            //Split line to get the library.
                            int    splitLoc = commandArg.IndexOf(':');
                            string file     = commandArg.Substring(splitLoc + 1);

                            //If the file exists, just return it so dlopen can load it.
                            if (File.Exists(file))
                            {
                                s_libraryLocation    = file;
                                s_useCommandLineFile = true;
                            }
                        }
                    }

                    const string resourceRoot = "FRC.NetworkTables.Core.DesktopLibraries.Libraries.";

                    NativeLoader = new NativeLibraryLoader();
                    NativeLoader.AddLibraryLocation(OsType.Windows32,
                                                    resourceRoot + "Windows.x86.ntcore.dll");
                    NativeLoader.AddLibraryLocation(OsType.Windows64,
                                                    resourceRoot + "Windows.amd64.ntcore.dll");
                    NativeLoader.AddLibraryLocation(OsType.Linux32,
                                                    resourceRoot + "Linux.x86.libntcore.so");
                    NativeLoader.AddLibraryLocation(OsType.Linux64,
                                                    resourceRoot + "Linux.amd64.libntcore.so");
                    NativeLoader.AddLibraryLocation(OsType.MacOs32,
                                                    resourceRoot + "Mac_OS_X.x86.libntcore.dylib");
                    NativeLoader.AddLibraryLocation(OsType.MacOs64,
                                                    resourceRoot + "Mac_OS_X.x86_64.libntcore.dylib");
                    NativeLoader.AddLibraryLocation(OsType.roboRIO, "libntcore.so");

                    if (s_useCommandLineFile)
                    {
                        NativeLoader.LoadNativeLibrary <Interop>(s_libraryLocation, true);
                    }
                    else
                    {
                        NativeLoader.LoadNativeLibraryFromReflectedAssembly("FRC.NetworkTables.Core.DesktopLibraries");
                        s_libraryLocation = NativeLoader.LibraryLocation;
                    }

                    NativeDelegateInitializer.SetupNativeDelegates <Interop>(NativeLoader);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
                    Environment.Exit(1);
                }
                s_runFinalizer  = true;
                s_libraryLoaded = true;
            }
        }