Description of Descriptor.
Exemplo n.º 1
0
 /// <summary>Procura pelo dispositivo USB e o inicializa para comunicação.
 /// Retorna True se o dispositivo foi encontrado e inicializado, caso contrário, retorna False.
 /// </summary>
 /// <param name="produto">String com o nome do produto retornado pelo Dipositivo USB.</param>
 /// <param name="fabricante">String com o nome do fabricante retornado pelo Dipositivo USB.</param>
 public bool Inicializar(string produto, string fabricante)
 {
     foreach (Bus bus in Bus.Busses)
     {
         foreach (Descriptor descriptor in bus.Descriptors)
         {
             Device device = descriptor.OpenDevice();
             if (device.Product == produto && device.Manufacturer == fabricante)
             {
                 ProdutoId = produto;
                 FabricanteId = fabricante;
                 barramento = bus;
                 descritor = descriptor;
                 dispositivo = device;
                 dispositivo_aberto = true;
                 return true;
             }
         }
     }
     return false;
 }
Exemplo n.º 2
0
        internal Device(Descriptor descriptor)
        {
            this.descriptor   = descriptor;

            this.deviceHandle = NativeMethods.usb_open(descriptor.NativeDevice);
            if (this.deviceHandle == IntPtr.Zero) {
                throw new UsbException("Can't open device.");
            }
            /*
            int rc = NativeMethods.usb_set_configuration(deviceHandle, 1);
            if (rc < 0) {
                throw new MethodCallUsbException("usb_set_configuration", rc);
            }
            rc = NativeMethods.usb_claim_interface(deviceHandle, 0);
            if (rc < 0) {
                throw new MethodCallUsbException("usb_claim_interface", rc);
            }

            rc = NativeMethods.usb_set_altinterface(deviceHandle, 0);
            if (rc < 0) {
                throw new MethodCallUsbException("usb_set_altinterface", rc);
            }*/
        }
 /// <summary>
 ///   Copies the elements of an array to the end of the <see cref='DescriptorCollection'/>.
 /// </summary>
 /// <param name='val'>
 ///    An array of type <see cref='Descriptor'/> containing the objects to add to the collection.
 /// </param>
 /// <seealso cref='DescriptorCollection.Add'/>
 public void AddRange(Descriptor[] val)
 {
     for (int i = 0; i < val.Length; i++) {
         this.Add(val[i]);
     }
 }
 /// <summary>
 ///   Adds a <see cref='Descriptor'/> with the specified value to the 
 ///   <see cref='DescriptorCollection'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Descriptor'/> to add.</param>
 /// <returns>The index at which the new element was inserted.</returns>
 /// <seealso cref='DescriptorCollection.AddRange'/>
 public int Add(Descriptor val)
 {
     return List.Add(val);
 }
 /// <summary>
 ///   Initializes a new instance of <see cref='DescriptorCollection'/> containing any array of <see cref='Descriptor'/> objects.
 /// </summary>
 /// <param name='val'>
 ///       A array of <see cref='Descriptor'/> objects with which to intialize the collection
 /// </param>
 public DescriptorCollection(Descriptor[] val)
 {
     this.AddRange(val);
 }
 /// <summary>
 ///   Removes a specific <see cref='Descriptor'/> from the <see cref='DescriptorCollection'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Descriptor'/> to remove from the <see cref='DescriptorCollection'/>.</param>
 /// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
 public void Remove(Descriptor val)
 {
     List.Remove(val);
 }
 /// <summary>
 ///   Inserts a <see cref='Descriptor'/> into the <see cref='DescriptorCollection'/> at the specified index.
 /// </summary>
 /// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param>
 /// <param name='val'>The <see cref='Descriptor'/> to insert.</param>
 /// <seealso cref='DescriptorCollection.Add'/>
 public void Insert(int index, Descriptor val)
 {
     List.Insert(index, val);
 }
 /// <summary>
 ///    Returns the index of a <see cref='Descriptor'/> in 
 ///       the <see cref='DescriptorCollection'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Descriptor'/> to locate.</param>
 /// <returns>
 ///   The index of the <see cref='Descriptor'/> of <paramref name='val'/> in the 
 ///   <see cref='DescriptorCollection'/>, if found; otherwise, -1.
 /// </returns>
 /// <seealso cref='DescriptorCollection.Contains'/>
 public int IndexOf(Descriptor val)
 {
     return List.IndexOf(val);
 }
 /// <summary>
 ///   Copies the <see cref='DescriptorCollection'/> values to a one-dimensional <see cref='Array'/> instance at the 
 ///    specified index.
 /// </summary>
 /// <param name='array'>The one-dimensional <see cref='Array'/> that is the destination of the values copied from <see cref='DescriptorCollection'/>.</param>
 /// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
 /// <exception cref='ArgumentException'>
 ///   <para><paramref name='array'/> is multidimensional.</para>
 ///   <para>-or-</para>
 ///   <para>The number of elements in the <see cref='DescriptorCollection'/> is greater than
 ///         the available space between <paramref name='arrayIndex'/> and the end of
 ///         <paramref name='array'/>.</para>
 /// </exception>
 /// <exception cref='ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
 /// <exception cref='ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
 /// <seealso cref='Array'/>
 public void CopyTo(Descriptor[] array, int index)
 {
     List.CopyTo(array, index);
 }
Exemplo n.º 10
0
 /// <summary>
 ///   Gets a value indicating whether the 
 ///    <see cref='DescriptorCollection'/> contains the specified <see cref='Descriptor'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Descriptor'/> to locate.</param>
 /// <returns>
 /// <see langword='true'/> if the <see cref='Descriptor'/> is contained in the collection; 
 ///   otherwise, <see langword='false'/>.
 /// </returns>
 /// <seealso cref='DescriptorCollection.IndexOf'/>
 public bool Contains(Descriptor val)
 {
     return List.Contains(val);
 }