예제 #1
0
        public static bool VLFD_AppFIFOReadData(int iBoard, Span <ushort> Buffer)
        {
            var p = Marshal.AllocHGlobal(Marshal.SizeOf <ushort>() * Buffer.Length);
            var r = NativeExtension.Get().NativeMethods.VLFD_AppFIFOReadData_init(iBoard, p, (uint)Buffer.Length);

            unsafe
            {
                var buf = new Span <ushort>(p.ToPointer(), Buffer.Length);
                buf.CopyTo(Buffer);
            }
            Marshal.FreeHGlobal(p);
            return(r);
        }
예제 #2
0
 /// <summary>
 /// Gets singleton instance of this class.
 /// The native extension is loaded when called for the first time.
 /// </summary>
 public static NativeExtension Get()
 {
     if (instance == null)
     {
         lock (staticLock)
         {
             if (instance == null)
             {
                 instance = new NativeExtension();
             }
         }
     }
     return(instance);
 }
예제 #3
0
        public static bool VLFD_IO_WriteReadData(int iBoard, Span <ushort> WriteBuffer, Span <ushort> ReadBuffer)
        {
            var writebufpointer = Marshal.AllocHGlobal(Marshal.SizeOf <ushort>() * WriteBuffer.Length);
            var readbufpointer  = Marshal.AllocHGlobal(Marshal.SizeOf <ushort>() * ReadBuffer.Length);

            unsafe
            {
                var writebuf = new Span <ushort>(writebufpointer.ToPointer(), WriteBuffer.Length);
                WriteBuffer.CopyTo(writebuf);

                var readbuf = new Span <ushort>(readbufpointer.ToPointer(), ReadBuffer.Length);
                var r       = NativeExtension.Get().NativeMethods.VLFD_IO_WriteReadData_init(iBoard, writebufpointer, readbufpointer, (uint)ReadBuffer.Length);

                readbuf.CopyTo(ReadBuffer);

                Marshal.FreeHGlobal(writebufpointer);
                Marshal.FreeHGlobal(readbufpointer);

                return(r);
            }
        }
예제 #4
0
        // Signatures of native methods are generated from a template
        // and can be found in NativeMethods.Generated.cs

        /// <summary>
        /// Gets singleton instance of this class.
        /// </summary>
        public static NativeMethods Get()
        {
            return(NativeExtension.Get().NativeMethods);
        }
예제 #5
0
        public static string VLFD_GetLastErrorMsg(int iBoard)
        {
            var p = NativeExtension.Get().NativeMethods.VLFD_GetLastErrorMsg_init(iBoard);

            return(Marshal.PtrToStringAnsi(p));
        }
예제 #6
0
 public static bool VLFD_IO_Close(int iBoard) => NativeExtension.Get().NativeMethods.VLFD_IO_Close_init(iBoard);
예제 #7
0
 public static bool VLFD_AppChannelSelector(int iBoard, byte channel) => NativeExtension.Get().NativeMethods.VLFD_AppChannelSelector_init(iBoard, channel);
예제 #8
0
 public static bool VLFD_IO_Open(int iBoard, string SerialNO) => NativeExtension.Get().NativeMethods.VLFD_IO_Open_init(iBoard, SerialNO);
예제 #9
0
 public static bool VLFD_ProgramFPGA(int iBoard, string BitFile) => NativeExtension.Get().NativeMethods.VLFD_ProgramFPGA_init(iBoard, BitFile);