Пример #1
0
        internal UsbConfigInfo(MonoUsbDevice usbDevice, MonoUsbConfigDescriptor configDescriptor)
        {
            mUsbDevice = usbDevice;

            mUsbConfigDescriptor = new UsbConfigDescriptor(configDescriptor);

            List <MonoUsbInterface> monoUSBInterfaces = configDescriptor.InterfaceList;

            foreach (MonoUsbInterface usbInterface in monoUSBInterfaces)
            {
                List <MonoUsbAltInterfaceDescriptor> monoUSBAltInterfaces = usbInterface.AltInterfaceList;
                foreach (MonoUsbAltInterfaceDescriptor monoUSBAltInterface in monoUSBAltInterfaces)
                {
                    UsbInterfaceInfo usbInterfaceInfo = new UsbInterfaceInfo(mUsbDevice, monoUSBAltInterface);
                    mInterfaceList.Add(usbInterfaceInfo);
                }
            }
        }
Пример #2
0
        internal UsbConfigInfo(UsbDevice usbDevice, UsbConfigDescriptor descriptor, ref List <byte[]> rawDescriptors)
        {
            mUsbDevice           = usbDevice;
            mUsbConfigDescriptor = descriptor;
            mRawDescriptors      = rawDescriptors;

            UsbInterfaceInfo currentInterface = null;

            for (int iRawDescriptor = 0; iRawDescriptor < rawDescriptors.Count; iRawDescriptor++)
            {
                byte[] bytesRawDescriptor = rawDescriptors[iRawDescriptor];

                switch (bytesRawDescriptor[1])
                {
                case (byte)DescriptorType.Interface:
                    currentInterface = new UsbInterfaceInfo(usbDevice, bytesRawDescriptor);
                    mRawDescriptors.RemoveAt(iRawDescriptor);
                    mInterfaceList.Add(currentInterface);
                    iRawDescriptor--;
                    break;

                case (byte)DescriptorType.Endpoint:
                    if (currentInterface == null)
                    {
                        throw new UsbException(this, "Recieved and endpoint descriptor before receiving an interface descriptor.");
                    }

                    currentInterface.mEndpointInfo.Add(new UsbEndpointInfo(bytesRawDescriptor));
                    mRawDescriptors.RemoveAt(iRawDescriptor);
                    iRawDescriptor--;
                    break;

                default:
                    if (currentInterface != null)
                    {
                        currentInterface.mRawDescriptors.Add(bytesRawDescriptor);
                        mRawDescriptors.RemoveAt(iRawDescriptor);
                        iRawDescriptor--;
                    }
                    break;
                }
            }
        }