Exemplo n.º 1
0
 unsafe internal CyBOS_SS_DEVICE_CAPABILITY(IntPtr handle, USB_BOS_SS_DEVICE_CAPABILITY *USB_SuperSpeedUsb)
 {
     _bLength                = USB_SuperSpeedUsb->bLength;
     _bDescriptorType        = USB_SuperSpeedUsb->bDescriptorType;
     _bDevCapabilityType     = USB_SuperSpeedUsb->bDevCapabilityType;
     _bFunctionalitySupporte = USB_SuperSpeedUsb->bFunctionalitySupporte;
     _bmAttribute            = USB_SuperSpeedUsb->bmAttribute;
     _bU1DevExitLat          = USB_SuperSpeedUsb->bU1DevExitLat;
     _bU2DevExitLat          = USB_SuperSpeedUsb->bU2DevExitLat;
 }
Exemplo n.º 2
0
        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;
                    }
                }
            }
        }