コード例 #1
0
ファイル: ScpDevice.cs プロジェクト: zultharion/ScpServer
        public virtual bool Open(string devicePath)
        {
            GetHardwareId(devicePath);

            Path = devicePath.ToUpper();

            if (GetDeviceHandle(Path))
            {
                if (Usb.Initialize(FileHandle, ref _winUsbHandle))
                {
                    if (InitializeDevice())
                    {
                        if (!LibusbKWrapper.Instance.SetPowerPolicyAutoSuspend(_winUsbHandle))
                        {
                            Log.Warn("Couldn't alter power policy");
                        }

                        IsActive = true;
                    }
                    else
                    {
                        Usb.Free(_winUsbHandle);
                        _winUsbHandle = (IntPtr)INVALID_HANDLE_VALUE;
                    }
                }
                else
                {
                    CloseHandle(FileHandle);
                }
            }

            return(IsActive);
        }
コード例 #2
0
ファイル: ScpDevice.cs プロジェクト: trigrab/ScpToolkit
        public virtual bool Open(string devicePath)
        {
            GetHardwareId(devicePath);

            Path = devicePath.ToUpper();

            if (GetDeviceHandle(Path))
            {
                if (WinUsbWrapper.Initialize(FileHandle, ref _winUsbHandle))
                {
                    if (InitializeDevice())
                    {
                        IsActive = true;
                    }
                    else
                    {
                        WinUsbWrapper.Free(_winUsbHandle);
                        _winUsbHandle = (IntPtr)INVALID_HANDLE_VALUE;
                    }
                }
                else
                {
                    CloseHandle(FileHandle);
                }
            }

            return(IsActive);
        }