Representing a USB device that can be opened and used by Libusb-1.0.
 /// <summary>
 /// Compares a <see cref="MonoUsbProfile"/> with this one.
 /// </summary>
 /// <param name="other">The other <see cref="MonoUsbProfile"/>.</param>
 /// <returns>True if the <see cref="BusNumber"/> and <see cref="DeviceAddress"/> are equal.</returns>
 public bool Equals(MonoUsbProfile other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other.mBusNumber == mBusNumber && other.mDeviceAddress == mDeviceAddress);
 }
示例#2
0
    private void BeginFreiburgSyncSession()
    {
        if (sessionHandle.IsInvalid)
        {
            throw new ExternalException("Failed to initialize context.");
        }

        MonoUsbApi.SetDebug(sessionHandle, 0);

        profileList = new MonoLibUsb.Profile.MonoUsbProfileList();

        // The list is initially empty.
        // Each time refresh is called the list contents are updated.
        int profileListRefreshResult;

        profileListRefreshResult = profileList.Refresh(sessionHandle);
        if (profileListRefreshResult < 0)
        {
            throw new ExternalException("Failed to retrieve device list.");
        }
        Debug.Log(profileListRefreshResult.ToString() + " device(s) found.");

        // Iterate through the profile list.
        // If we find the device, write 00000000 to its endpoint 2.
        foreach (MonoLibUsb.Profile.MonoUsbProfile profile in profileList)
        {
            if (profile.DeviceDescriptor.ProductID == FREIBURG_SYNCBOX_PRODUCT_ID && profile.DeviceDescriptor.VendorID == FREIBURG_SYNCBOX_VENDOR_ID)
            {
                freiburgSyncboxProfile = profile;
            }
        }

        if (freiburgSyncboxProfile == null)
        {
            throw new ExternalException("None of the connected USB devices were identified as a Freiburg syncbox.");
        }

        freiburgSyncboxDeviceHandle = new MonoUsbDeviceHandle(freiburgSyncboxProfile.ProfileHandle);
        freiburgSyncboxDeviceHandle = freiburgSyncboxProfile.OpenDeviceHandle();

        if (freiburgSyncboxDeviceHandle == null)
        {
            throw new ExternalException("The ftd USB device was found but couldn't be opened");
        }

        StartCoroutine(FreiburgPulse());
    }
 internal AddRemoveEventArgs(MonoUsbProfile monoUSBProfile, AddRemoveType addRemoveType)
 {
     mMonoUSBProfile = monoUSBProfile;
     mAddRemoveType = addRemoveType;
 }
示例#4
0
 // Predicate functions for finding only devices with the specified VendorID & ProductID.
 private static bool MyVidPidPredicate(MonoUsbProfile profile)
 {
     if (profile.DeviceDescriptor.VendorID == 0x04d8 && profile.DeviceDescriptor.ProductID == 0x0053)
         return true;
     return false;
 }
 internal AddRemoveEventArgs(MonoUsbProfile monoUSBProfile, AddRemoveType addRemoveType)
 {
     mMonoUSBProfile = monoUSBProfile;
     mAddRemoveType  = addRemoveType;
 }
示例#6
0
 /// <summary>
 /// Compares a <see cref="MonoUsbProfile"/> with this one.
 /// </summary>
 /// <param name="other">The other <see cref="MonoUsbProfile"/>.</param>
 /// <returns>True if the <see cref="BusNumber"/> and <see cref="DeviceAddress"/> are equal.</returns>
 public bool Equals(MonoUsbProfile other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.mBusNumber == mBusNumber && other.mDeviceAddress == mDeviceAddress;
 }
示例#7
0
 internal MonoUsbDevice(ref MonoUsbProfile monoUSBProfile)
     : base(null, null)
 {
     mMonoUSBProfile = monoUSBProfile;
     mCachedDeviceDescriptor = new UsbDeviceDescriptor(monoUSBProfile.DeviceDescriptor);
 }