Beispiel #1
0
 public Interface(IUSBDevice device,
                  byte identifier,
                  byte subClassCode,
                  byte protocol,
                  string description = null) : base(device, identifier, USBClassCode.MassStorage, subClassCode, protocol, description)
 {
 }
        // this is just a simple wrapper method allowing to register devices from monitor
        public static void Register(this USBIPServer @this, IUSBDevice device, int?port = null)
        {
            if (!port.HasValue)
            {
                port = @this.Children.Any()
                    ? @this.Children.Max(x => x.RegistrationPoint.Address) + 1
                    : 0;
            }

            @this.Register(device, new NumberRegistrationPoint <int>(port.Value));
        }
Beispiel #3
0
        public Interface(IUSBDevice device,
                         byte identifier,
                         byte subClassCode  = (byte)SubclassCode.BootInterfaceSubclass,
                         byte protocol      = (byte)HID.Protocol.None,
                         string description = null,
                         ReportDescriptor reportDescriptor = null) : base(device, identifier, USBClassCode.HumanInterfaceDevice, subClassCode, protocol, description)
        {
            HID_ReportDescriptor = reportDescriptor ?? new ReportDescriptor();
            HID_Descriptor       = new HID.Descriptor(HID_ReportDescriptor);

            RegisterSubdescriptor(HID_Descriptor, 0);
        }
Beispiel #4
0
 public Interface(IUSBDevice device,
                  byte identifier,
                  byte subClassCode,
                  byte protocol,
                  IEnumerable <FunctionalDescriptor> descriptors = null,
                  string description = null) : base(device, identifier, USBClassCode.CommunicationsCDCControl, subClassCode, protocol, description)
 {
     if (descriptors != null)
     {
         var pos = 0;
         foreach (var d in descriptors)
         {
             RegisterSubdescriptor(d, pos++);
         }
     }
 }
        public USBEndpoint(IUSBDevice device,
                           byte identifier,
                           Direction direction,
                           EndpointTransferType transferType,
                           short maximumPacketSize,
                           byte interval) : base(7, (byte)DescriptorType.Endpoint)
        {
            this.device = device;

            Identifier        = identifier;
            Direction         = direction;
            TransferType      = transferType;
            MaximumPacketSize = maximumPacketSize;
            Interval          = interval;

            buffer        = new Queue <IEnumerable <byte> >();
            packetCreator = new PacketCreator(HandlePacket);
        }
        public USBInterface(IUSBDevice device,
                            byte identifier,
                            USBClassCode classCode = USBClassCode.NotSpecified,
                            byte subClassCode      = 0,
                            byte protocol          = 0,
                            string description     = null) : base(9, (byte)DescriptorType.Interface)
        {
            this.device = device;
            endpoints   = new List <USBEndpoint>();

            Identifier  = identifier;
            Class       = classCode;
            SubClass    = subClassCode;
            Protocol    = protocol;
            Description = description;

            RegisterSubdescriptors(endpoints);
        }
        public USBDeviceCore(IUSBDevice device,
                             USBClassCode classCode         = USBClassCode.NotSpecified,
                             byte subClassCode              = 0,
                             byte protocol                  = 0,
                             USBProtocol usbProtocolVersion = USBProtocol.USB_2_0,
                             short deviceReleaseNumber      = 0,
                             PacketSize maximalPacketSize   = PacketSize.Size64,
                             string manufacturerName        = null,
                             string productName             = null,
                             string serialNumber            = null,
                             ushort vendorId                = 0,
                             ushort productId               = 0,
                             Action <SetupPacket, byte[], Action <byte[]> > customSetupPacketHandler = null) : base(18, (byte)DescriptorType.Device)
        {
            if (maximalPacketSize != PacketSize.Size8 &&
                maximalPacketSize != PacketSize.Size16 &&
                maximalPacketSize != PacketSize.Size32 &&
                maximalPacketSize != PacketSize.Size64)
            {
                throw new ConstructionException("Unsupported maximal packet size.");
            }

            this.customSetupPacketHandler = customSetupPacketHandler;
            this.device    = device;
            configurations = new List <USBConfiguration>();

            CompatibleProtocolVersion = usbProtocolVersion;
            Class               = classCode;
            SubClass            = subClassCode;
            Protocol            = protocol;
            DeviceReleaseNumber = deviceReleaseNumber;
            MaximalPacketSize   = maximalPacketSize;
            ManufacturerName    = manufacturerName;
            ProductName         = productName;
            SerialNumber        = serialNumber;
            VendorId            = vendorId;
            ProductId           = productId;

            RegisterSubdescriptors(configurations);
        }
        public USBConfiguration(IUSBDevice device,
                                byte identifier,
                                string description = null,
                                bool selfPowered   = false,
                                bool remoteWakeup  = false,
                                short maximalPower = 0) : base(9, (byte)DescriptorType.Configuration)
        {
            if (maximalPower > 500 || maximalPower < 0)
            {
                throw new ConstructionException("Maximal power should be between 0 and 500 mA");
            }

            this.device = device;

            interfaces = new List <USBInterface>();

            Identifier   = identifier;
            Description  = description;
            MaximalPower = maximalPower;
            SelfPowered  = selfPowered;
            RemoteWakeup = remoteWakeup;

            RegisterSubdescriptors(interfaces);
        }