Core Types

USB types – defines enumerations that describe standard USB types

class usb_construct.types.USBDirection(value)

Class representing USB directions.

classmethod parse(value) USBDirection

Helper that converts a numeric field into a direction.

classmethod from_request_type(request_type_int: int) USBDirection

Helper method that extracts the direction from a request_type integer.

classmethod from_endpoint_address(address: int) USBDirection

Helper method that extracts the direction from an endpoint address.

token() USBPacketID

Generates the token corresponding to the given direction.

reverse() Literal[0, 1]

Returns the reverse of the given direction.

to_endpoint_address(endpoint_number: int) int

Helper method that converts and endpoint_number to an address, given direction.

class usb_construct.types.USBPIDCategory(value)

Category constants for each of the groups that PIDs can fall under.

class usb_construct.types.USBPacketID(value)

Enumeration specifying all of the valid USB PIDs we can handle.

classmethod from_byte(byte: Iterable[SupportsIndex] | SupportsBytes, skip_checks: bool = False) USBPacketID

Creates a PID object from a byte.

classmethod from_int(value: int, skip_checks: bool = True) USBPacketID

Create a PID object from an integer.

classmethod from_name(name: str) USBPacketID

Create a PID object from a string representation of its name.

classmethod parse(value: bytes | str | int) USBPacketID

Attempt to create a PID object from a number, byte, or string.

category() USBPIDCategory

Returns the USBPIDCategory that each given PID belongs to.

is_data() bool

Returns true iff the given PID represents a DATA packet.

is_token() bool

Returns true iff the given PID represents a token packet.

is_handshake() bool

Returns true iff the given PID represents a handshake packet.

is_invalid() bool

Returns true if this object is an attempt to encapsulate an invalid PID.

direction() Literal[USBDirection.IN, USBDirection.OUT] | None

Get a USB direction from a PacketID.

summarize() str | None

Return a summary of the given packet.

byte() int

Return the PID’s value with its upper nibble.

class usb_construct.types.USBRequestRecipient(value)

Enumeration that describes each ‘recipient’ of a USB request field.

classmethod from_integer(value: int) USBRequestRecipient

Special factory that correctly handles reserved values.

classmethod from_request_type(request_type_int: int) USBRequestRecipient

Helper method that extracts the type from a request_type integer.

class usb_construct.types.USBRequestType(value)

Enumeration that describes each possible Type field for a USB request.

classmethod from_request_type(request_type_int: int) USBRequestType

Helper method that extracts the type from a request_type integer.

class usb_construct.types.USBTransferType(value)

An enumeration.

class usb_construct.types.LanguageIDs(value)

An enumeration.

class usb_construct.types.DescriptorTypes(value)

An enumeration.

class usb_construct.types.USBSynchronizationType(value)

An enumeration.

class usb_construct.types.USBUsageType(value)

An enumeration.

class usb_construct.types.USBStandardRequests(value)

An enumeration.