示例#1
0
        public DolphiimoteDll(string path)
        {
            nativeDll = new NativeDll(path);

            if (Marshal.SizeOf(typeof(DolphiimoteCallbacks)) != 24)
            {
                throw new InvalidOperationException("DolphiimoteCallbacks wrong size. Expected: 24, got:" + Marshal.SizeOf(typeof(DolphiimoteCallbacks)));
            }

            if (Marshal.SizeOf(typeof(DolphiimoteData)) != 128)
            {
                throw new InvalidOperationException("DolphiimoteData wrong size. Expected: 128, got:" + Marshal.SizeOf(typeof(DolphiimoteData)));
            }

            if (Marshal.SizeOf(typeof(DolphiimoteCapabilities)) != 16)
            {
                throw new InvalidOperationException("DolphiimoteCapabilities wrong size.");
            }

            dolphiimoteInit               = nativeDll.GetDelegateFromFunction <DolphiimoteInit>("dolphiimote_init");
            dolphiimoteUpdate             = nativeDll.GetDelegateFromFunction <DolphiimoteUpdate>("dolphiimote_update");
            dolphiimoteSetReportingMode   = nativeDll.GetDelegateFromFunction <DolphiimoteSetReportingMode>("dolphiimote_set_reporting_mode");
            dolphiimoteShutdown           = nativeDll.GetDelegateFromFunction <DolphiimoteShutdown>("dolphiimote_shutdown");
            dolphiimoteEnableCapabilities = nativeDll.GetDelegateFromFunction <DolphiimoteEnableCapabilities>("dolphiimote_enable_capabilities");
            dolphiimoteSetRumble          = nativeDll.GetDelegateFromFunction <DolphiimoteSetRumble>("dolphiimote_set_rumble");
            dolphiimoteRequestStatus      = nativeDll.GetDelegateFromFunction <DolphiimoteRequestStatus>("dolphiimote_request_status");
            dolphiimoteSetLedState        = nativeDll.GetDelegateFromFunction <DolphiimoteSetLedState>("dolphiimote_set_leds");
        }
示例#2
0
        public DolphiimoteDll(string path)
        {
            nativeDll = new NativeDll(path);

            if (Marshal.SizeOf(typeof(DolphiimoteCallbacks)) != 20)
            {
                throw new InvalidOperationException("DolphiimoteCallbacks wrong size.");
            }

            if (Marshal.SizeOf(typeof(DolphiimoteData)) != 32)
            {
                throw new InvalidOperationException("DolphiimoteData wrong size.");
            }

            if (Marshal.SizeOf(typeof(DolphiimoteCapabilities)) != 16)
            {
                throw new InvalidOperationException("DolphiimoteCapabilities wrong size.");
            }

            dolphiimoteInit = nativeDll.GetDelegateFromFunction <DolphiimoteInit>("dolphiimote_init");
            dolphiimoteDetermineCapabilities = nativeDll.GetDelegateFromFunction <DolphiimoteDetermineCapabilities>("dolphiimote_determine_capabilities");
            dolphiimoteUpdate             = nativeDll.GetDelegateFromFunction <DolphiimoteUpdate>("dolphiimote_update");
            dolphiimoteSetReportingMode   = nativeDll.GetDelegateFromFunction <DolphiimoteSetReportingMode>("dolphiimote_set_reporting_mode");
            dolphiimoteShutdown           = nativeDll.GetDelegateFromFunction <DolphiimoteShutdown>("dolphiimote_shutdown");
            dolphiimoteEnableCapabilities = nativeDll.GetDelegateFromFunction <DolphiimoteEnableCapabilities>("dolphiimote_enable_capabilities");
        }