internal MonoUsbProfile(MonoUsbProfileHandle monoUSBProfileHandle) { mMonoUSBProfileHandle = monoUSBProfileHandle; mBusNumber = MonoUsbApi.GetBusNumber(mMonoUSBProfileHandle); mDeviceAddress = MonoUsbApi.GetDeviceAddress(mMonoUSBProfileHandle); GetDeviceDescriptor(out mMonoUsbDeviceDescriptor); //#if DEBUG // Console.WriteLine("Vid:{0:X4} Pid:{1:X4} BusNumber:{2} DeviceAddress:{3}", // mMonoUsbDeviceDescriptor.VendorID, // mMonoUsbDeviceDescriptor.ProductID, // mBusNumber, // mDeviceAddress); //#endif }
internal MonoUsbProfile(MonoUsbProfileHandle monoUSBProfileHandle) { mMonoUSBProfileHandle = monoUSBProfileHandle; mBusNumber = MonoUsbApi.GetBusNumber(mMonoUSBProfileHandle); mDeviceAddress = MonoUsbApi.GetDeviceAddress(mMonoUSBProfileHandle); GetDeviceDescriptor(out mMonoUsbDeviceDescriptor); //#if DEBUG // Console.WriteLine("Vid:{0:X4} Pid:{1:X4} BusNumber:{2} DeviceAddress:{3}", // mMonoUsbDeviceDescriptor.VendorID, // mMonoUsbDeviceDescriptor.ProductID, // mBusNumber, // mDeviceAddress); //#endif }
/// <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); } }
internal static internal_windows_device_priv GetWindowsPriv(MonoUsbProfileHandle profileHandle) { internal_windows_device_priv priv = new internal_windows_device_priv(); IntPtr pPriv = new IntPtr(profileHandle.DangerousGetHandle().ToInt64() + Marshal.SizeOf(typeof(internal_libusb_device))); Marshal.PtrToStructure(pPriv, priv); return priv; }