StrError() private method

private StrError ( int errcode ) : IntPtr
errcode int
return System.IntPtr
コード例 #1
0
 /// <summary>
 /// Creates and initialize a <a href="http://libusb.sourceforge.net/api-1.0/index.html">Libusb-1.0</a> USB session handle.
 /// </summary>
 /// <remarks>
 /// <para>A <see cref="MonoUsbSessionHandle"/> instance must be created before calling any other <a href="http://libusb.sourceforge.net/api-1.0/index.html">Libusb-1.0 API</a> function.</para>
 /// </remarks>
 public MonoUsbSessionHandle() : base(IntPtr.Zero, true)
 {
     lock (sessionLOCK)
     {
         IntPtr pNewSession = IntPtr.Zero;
         try
         {
             mLastReturnCode = (MonoUsbError)MonoUsbApi.Init(ref pNewSession);
         }
         catch (DllNotFoundException dllNotFound)
         {
             if (LHelper.IsLinux)
             {
                 throw new DllNotFoundException(DLL_NOT_FOUND_LINUX, dllNotFound);
             }
             else
             {
                 throw new DllNotFoundException(DLL_NOT_FOUND_WINDOWS, dllNotFound);
             }
         }
         if ((int)mLastReturnCode < 0)
         {
             mLastReturnString = MonoUsbApi.StrError(mLastReturnCode);
             SetHandleAsInvalid();
         }
         else
         {
             SetHandle(pNewSession);
             mSessionCount++;
         }
     }
 }
コード例 #2
0
        internal static UsbError Error(ErrorCode errorCode, int ret, string description, object sender)
        {
            string win32Error = String.Empty;

            if (errorCode == ErrorCode.MonoApiError)
            {
                win32Error = ((Error)ret) + ":" + MonoUsbApi.StrError((Error)ret);
            }

            UsbError err = new UsbError(errorCode, ret, win32Error, description, sender);

            return(err);
        }
コード例 #3
0
        /// <summary>Open a device handle from <paramref name="profileHandle"/>.</summary>
        /// <remarks>
        /// <para>A handle allows you to perform I/O on the device in question.</para>
        /// <para>To close a device handle call its <see cref="SafeHandle.Close"/> method.</para>
        /// <para>This is a non-blocking function; no requests are sent over the bus.</para>
        /// <note title="Libusb-1.0 API Note:" type="cpp">The <see cref="MonoUsbDeviceHandle(MonoUsbProfileHandle)"/> constructor is roughly equivalent to <a href="http://libusb.sourceforge.net/api-1.0/group__dev.html#ga8163100afdf933fabed0db7fa81c89d1">libusb_open()</a>.</note>
        /// </remarks>
        /// <param name="profileHandle">A device profile handle.</param>
        public MonoUsbDeviceHandle(MonoUsbProfileHandle profileHandle)
            : base(IntPtr.Zero)
        {
            IntPtr pDeviceHandle = IntPtr.Zero;
            int    ret           = MonoUsbApi.Open(profileHandle, ref pDeviceHandle);

            if (ret < 0 || pDeviceHandle == IntPtr.Zero)
            {
                lock (handleLOCK)
                {
                    mLastReturnCode   = (MonoUsbError)ret;
                    mLastReturnString = MonoUsbApi.StrError(mLastReturnCode);
                }
                SetHandleAsInvalid();
            }
            else
            {
                SetHandle(pDeviceHandle);
            }
        }