Ejemplo n.º 1
0
        public static UsbSetupPacket CreateSetupPacket(SetupPacketPurpose purpose)
        {
            var vendorControlOutRequestType = new UsbControlRequestType
            {
                ControlTransferType = UsbControlTransferType.Vendor,
                Direction           = UsbTransferDirection.Out,
                Recipient           = UsbControlRecipient.Device
            };

            switch (purpose)
            {
            case SetupPacketPurpose.SetupDeviceForFirmwareUpdate:
                return(new UsbSetupPacket
                {
                    RequestType = vendorControlOutRequestType,
                    Request = 0xC5,
                    Value = 0,
                    Index = 0,
                    Length = 0
                });

            case SetupPacketPurpose.WriteSector:
                /// <summary>
                /// Value, Index, Length must be filled in later with information specifically about the data being transfered
                /// </summary>
                return(new UsbSetupPacket
                {
                    RequestType = vendorControlOutRequestType,
                    Request = 0xC2,
                });

            case SetupPacketPurpose.ResetDevice:
                return(new UsbSetupPacket
                {
                    RequestType = vendorControlOutRequestType,
                    Request = 0xDA,
                    Value = 0,
                    Index = 0,
                    Length = 0
                });
            }

            return(null);
        }
Ejemplo n.º 2
0
        public static UsbSetupPacket CreateSetupPacket(SetupPacketPurpose purpose)
        {
            var vendorControlOutRequestType = new UsbControlRequestType
                {
                    ControlTransferType = UsbControlTransferType.Vendor,
                    Direction = UsbTransferDirection.Out,
                    Recipient = UsbControlRecipient.Device
                };

            switch (purpose)
            {
                case SetupPacketPurpose.SetupDeviceForFirmwareUpdate:
                    return new UsbSetupPacket
                        {
                            RequestType = vendorControlOutRequestType,
                            Request = 0xC5,
                            Value = 0,
                            Index = 0,
                            Length = 0
                        };
                case SetupPacketPurpose.WriteSector:
                    /// <summary>
                    /// Value, Index, Length must be filled in later with information specifically about the data being transfered
                    /// </summary>
                    return new UsbSetupPacket
                        {
                            RequestType = vendorControlOutRequestType,
                            Request = 0xC2,
                        };
                case SetupPacketPurpose.ResetDevice:
                    return new UsbSetupPacket
                        {
                            RequestType = vendorControlOutRequestType,
                            Request = 0xDA,
                            Value = 0,
                            Index = 0,
                            Length = 0
                        };
            }

            return null;
        }