public USBInterface WithEndpoint(Direction direction, EndpointTransferType transferType, short maximumPacketSize, byte interval, out USBEndpoint createdEndpoint) { if (endpoints.Count == byte.MaxValue) { throw new ConstructionException("The maximal number of endpoints reached"); } createdEndpoint = new USBEndpoint(device, (byte)(endpoints.Count + 1), direction, transferType, maximumPacketSize, interval); endpoints.Add(createdEndpoint); return(this); }
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 WithEndpoint(Direction direction, EndpointTransferType transferType, short maximumPacketSize, byte interval, out USBEndpoint createdEndpoint, byte?id = null) { if (!id.HasValue && endpoints.Count == byte.MaxValue) { throw new ConstructionException("The maximal number of endpoints reached"); } var localId = id ?? (byte)(endpoints.Count + 1); if (endpoints.Any(x => x.Identifier == localId && x.Direction == direction)) { throw new ConstructionException($"Endpoint with id {localId} in direction {direction} already definied"); } createdEndpoint = new USBEndpoint(device, localId, direction, transferType, maximumPacketSize, interval); endpoints.Add(createdEndpoint); return(this); }