Browse Source

Merge pull request #8 from Qyriad/fixes/audio-endpoint-descriptor

types.descriptors: handle Audio 1.0 endpoint descriptors
main
Kate Temkin 4 years ago
committed by GitHub
parent
commit
bf678266e3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      usb_protocol/types/descriptors/standard.py

+ 10
- 1
usb_protocol/types/descriptors/standard.py View File

@@ -91,12 +91,21 @@ InterfaceDescriptor = DescriptorFormat(


EndpointDescriptor = DescriptorFormat(
"bLength" / construct.Const(7, construct.Int8ul),

# [USB2.0: 9.6; USB Audio Device Class Definition 1.0: 4.6.1.1, 4.6.2.1]
# Interfaces of the Audio 1.0 class extend their subordinate endpoint descriptors with
# 2 additional bytes (extending it from 7 to 9 bytes). Thankfully, this is the only extension that
# changes the length of a standard descriptor type, but we do have to handle this case in Construct.
"bLength" / construct.OneOf(construct.Int8ul, [7, 9]),
"bDescriptorType" / DescriptorNumber(StandardDescriptorNumbers.ENDPOINT),
"bEndpointAddress" / DescriptorField("Endpoint Address"),
"bmAttributes" / DescriptorField("Attributes", default=2),
"wMaxPacketSize" / DescriptorField("Maximum Packet Size", default=64),
"bInterval" / DescriptorField("Polling interval", default=255),

# 2 bytes that are only present on endpoint descriptors for Audio 1.0 class interfaces.
("bRefresh" / construct.Optional(construct.Int8ul)) * "Refresh Rate",
("bSynchAddress" / construct.Optional(construct.Int8ul)) * "Synch Endpoint Address",
)




Loading…
Cancel
Save