コード例 #1
0
ファイル: CyUSBBOS.cs プロジェクト: li--paul/usbcam
 unsafe internal CyBOS_CONTAINER_ID(IntPtr handle, USB_BOS_CONTAINER_ID *USB_ContainerID)
 {
     _bLength            = USB_ContainerID->bLength;
     _bDescriptorType    = USB_ContainerID->bDescriptorType;
     _bDevCapabilityType = USB_ContainerID->bDevCapabilityType;
     _ContainerID        = new byte[CyConst.USB_BOS_CAPABILITY_TYPE_CONTAINER_ID_SIZE];
     for (int i = 0; i < CyConst.USB_BOS_CAPABILITY_TYPE_CONTAINER_ID_SIZE; i++)
     {
         _ContainerID[i] = USB_ContainerID->ContainerID[i];
     }
 }
コード例 #2
0
ファイル: CyUSBBOS.cs プロジェクト: li--paul/usbcam
        unsafe internal CyUSBBOS(IntPtr handle, byte[] BosDescrData)
        {
            // initialize to null
            USB20_DeviceExt = null;
            SS_DeviceCap    = null;
            Container_ID    = null;


            // parse the Bos Descriptor data
            fixed(byte *buf = BosDescrData)
            {
                USB_BOS_DESCRIPTOR *BosDesc = (USB_BOS_DESCRIPTOR *)buf;

                _bLength         = BosDesc->bLength;
                _bDescriptorType = BosDesc->bDescriptorType;
                _bNumDeviceCaps  = BosDesc->bNumDeviceCaps;
                _wToatalLength   = BosDesc->wToatalLength;

                int totallen = _wToatalLength;

                totallen -= BosDesc->bLength;

                if (totallen < 0)
                {
                    return;
                }

                byte *DevCap = (byte *)(buf + BosDesc->bLength); // get nex descriptor

                for (int i = 0; i < _bNumDeviceCaps; i++)
                {
                    //check capability type
                    switch (DevCap[2])
                    {
                    case CyConst.USB_BOS_CAPABILITY_TYPE_USB20_EXT:
                    {
                        USB_BOS_USB20_DEVICE_EXTENSION *USB20_ext = (USB_BOS_USB20_DEVICE_EXTENSION *)DevCap;
                        totallen       -= USB20_ext->bLength;
                        DevCap          = (byte *)DevCap + USB20_ext->bLength;
                        USB20_DeviceExt = new CyBOS_USB20_DEVICE_EXT(handle, USB20_ext);
                        break;
                    }

                    case CyConst.USB_BOS_CAPABILITY_TYPE_SUPERSPEED_USB:
                    {
                        USB_BOS_SS_DEVICE_CAPABILITY *SS_Capability = (USB_BOS_SS_DEVICE_CAPABILITY *)DevCap;
                        totallen    -= SS_Capability->bLength;
                        DevCap       = (byte *)DevCap + SS_Capability->bLength;
                        SS_DeviceCap = new CyBOS_SS_DEVICE_CAPABILITY(handle, SS_Capability);
                        break;
                    }

                    case CyConst.USB_BOS_CAPABILITY_TYPE_CONTAINER_ID:
                    {
                        USB_BOS_CONTAINER_ID *USB_ContainerID = (USB_BOS_CONTAINER_ID *)DevCap;
                        totallen    -= USB_ContainerID->bLength;
                        DevCap       = (byte *)DevCap + USB_ContainerID->bLength;
                        Container_ID = new CyBOS_CONTAINER_ID(handle, USB_ContainerID);
                        break;
                    }

                    default:
                    {
                        InvalidDevCap = new InvalidDeviceCapability();
                        break;
                    }
                    }
                    if (totallen < 0)
                    {
                        break;
                    }
                }
            }
        }