usb_protocol.types package

Subpackages

Submodules

Module contents

USB types – defines enumerations that describe standard USB types

class usb_protocol.types.DescriptorTypes(value)[source]

Bases: IntEnum

An enumeration.

CONFIGURATION = 2
DEVICE = 1
DEVICE_QUALIFIER = 6
ENDPOINT = 5
HID = 33
INTERFACE = 4
INTERFACE_POWER = 8
OTHER_SPEED_CONFIGURATION = 7
REPORT = 34
STRING = 3
class usb_protocol.types.LanguageIDs(value)[source]

Bases: IntEnum

An enumeration.

AFRIKAANS = 1078
ALBANIAN = 1052
ARABIC_ALGERIA = 5121
ARABIC_BAHRAIN = 15361
ARABIC_EGYPT = 3073
ARABIC_IRAQ = 2049
ARABIC_JORDAN = 11265
ARABIC_KUWAIT = 13313
ARABIC_LEBANON = 12289
ARABIC_LIBYA = 4097
ARABIC_MOROCCO = 6145
ARABIC_OMAN = 8193
ARABIC_QATAR = 16385
ARABIC_SAUDI_ARABIA = 1025
ARABIC_SYRIA = 10241
ARABIC_TUNISIA = 7169
ARABIC_UAE = 14337
ARABIC_YEMEN = 9217
ARMENIAN = 1067
ASSAMESE = 1101
AZERI_CYRILLIC = 2092
AZERI_LATIN = 1068
BASQUE = 1069
BELARUSSIAN = 1059
BENGALI = 1093
BULGARIAN = 1026
BURMESE = 1109
CATALAN = 1027
CHINESE_HONG_KONG = 3076
CHINESE_MACAU_SAR = 5124
CHINESE_PRC = 2052
CHINESE_SINGAPORE = 4100
CHINESE_TAIWAN = 1028
CROATIAN = 1050
CZECH = 1029
DANISH = 1030
DUTCH_BELGIUM = 2067
DUTCH_NETHERLANDS = 1043
ENGLISH_AUSTRALIAN = 3081
ENGLISH_BELIZE = 10249
ENGLISH_CANADIAN = 4105
ENGLISH_CARIBBEAN = 9225
ENGLISH_IRELAND = 6153
ENGLISH_JAMAICA = 8201
ENGLISH_NEW_ZEALAND = 5129
ENGLISH_PHILIPPINES = 13321
ENGLISH_SOUTH_AFRICA = 7177
ENGLISH_TRINIDAD = 11273
ENGLISH_UNITED_KINGDOM = 2057
ENGLISH_US = 1033
ENGLISH_ZIMBABWE = 12297
ESTONIAN = 1061
FAEROESE = 1080
FARSI = 1065
FINNISH = 1035
FRENCH_BELGIAN = 2060
FRENCH_CANADIAN = 3084
FRENCH_LUXEMBOURG = 5132
FRENCH_MONACO = 6156
FRENCH_STANDARD = 1036
FRENCH_SWITZERLAND = 4108
GEORGIAN = 1079
GERMAN_AUSTRIA = 3079
GERMAN_LIECHTENSTEIN = 5127
GERMAN_LUXEMBOURG = 4103
GERMAN_STANDARD = 1031
GERMAN_SWITZERLAND = 2055
GREEK = 1032
GUJARATI = 1095
HEBREW = 1037
HID_USAGE_DATA_DESCRIPTOR = 1279
HID_VENDOR_DEFINED_1 = 61695
HID_VENDOR_DEFINED_2 = 62719
HID_VENDOR_DEFINED_3 = 63743
HID_VENDOR_DEFINED_4 = 64767
HINDI = 1081
HUNGARIAN = 1038
ICELANDIC = 1039
INDONESIAN = 1057
ITALIAN_STANDARD = 1040
ITALIAN_SWITZERLAND = 2064
JAPANESE = 1041
KANNADA = 1099
KASHMIRI_INDIA = 2144
KAZAKH = 1087
KONKANI = 1111
KOREAN = 1042
KOREAN_JOHAB = 2066
LATVIAN = 1062
LITHUANIAN = 1063
LITHUANIAN_CLASSIC = 2087
MACEDONIAN = 1071
MALAYALAM = 1100
MALAY_BRUNEI_DARUSSALAM = 2110
MALAY_MALAYSIAN = 1086
MANIPURI = 1112
MARATHI = 1102
NEPALI_INDIA = 2145
NORWEGIAN_BOKMAL = 1044
NORWEGIAN_NYNORSK = 2068
ORIYA = 1096
POLISH = 1045
PORTUGUESE_BRAZIL = 1046
PORTUGUESE_STANDARD = 2070
PUNJABI = 1094
ROMANIAN = 1048
RUSSIAN = 1049
SANSKRIT = 1103
SERBIAN_CYRILLIC = 3098
SERBIAN_LATIN = 2074
SINDHI = 1113
SLOVAK = 1051
SLOVENIAN = 1060
SPANISH_ARGENTINA = 11274
SPANISH_BOLIVIA = 16394
SPANISH_CHILE = 13322
SPANISH_COLOMBIA = 9226
SPANISH_COSTA_RICA = 5130
SPANISH_DOMINICAN_REPUBLIC = 7178
SPANISH_ECUADOR = 12298
SPANISH_EL_SALVADOR = 17418
SPANISH_GUATEMALA = 4106
SPANISH_HONDURAS = 18442
SPANISH_MEXICAN = 2058
SPANISH_MODERN_SORT = 3082
SPANISH_NICARAGUA = 19466
SPANISH_PANAMA = 6154
SPANISH_PARAGUAY = 15370
SPANISH_PERU = 10250
SPANISH_PUERTO_RICO = 20490
SPANISH_TRADITIONAL_SORT = 1034
SPANISH_URUGUAY = 14346
SPANISH_VENEZUELA = 8202
SUTU = 1072
SWAHILI_KENYA = 1089
SWEDISH = 1053
SWEDISH_FINLAND = 2077
TAMIL = 1097
TATAR_TATARSTAN = 1092
TELUGU = 1098
THAI = 1054
TURKISH = 1055
UKRAINIAN = 1058
URDU_INDIA = 2080
URDU_PAKISTAN = 1056
UZBEK_CYRILLIC = 2115
UZBEK_LATIN = 1091
VIETNAMESE = 1066
class usb_protocol.types.USBDirection(value)[source]

Bases: IntEnum

Class representing USB directions.

IN = 1
OUT = 0
classmethod from_endpoint_address(address)[source]

Helper method that extracts the direction from an endpoint address.

classmethod from_request_type(request_type_int)[source]

Helper method that extracts the direction from a request_type integer.

is_in()[source]
is_out()[source]
classmethod parse(value)[source]

Helper that converts a numeric field into a direction.

reverse()[source]

Returns the reverse of the given direction.

to_endpoint_address(endpoint_number)[source]

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

token()[source]

Generates the token corresponding to the given direction.

class usb_protocol.types.USBPIDCategory(value)[source]

Bases: IntFlag

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

DATA = 3
HANDSHAKE = 2
MASK = 3
SPECIAL = 0
TOKEN = 1
class usb_protocol.types.USBPacketID(value)[source]

Bases: IntFlag

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

ACK = 2
DATA0 = 3
DATA1 = 11
DATA2 = 7
ERR = 12
IN = 9
MDATA = 15
NAK = 10
NYET = 6
OUT = 1
PID_CORE_MASK = 15
PID_INVALID = 16
PING = 4
PRE = 12
SETUP = 13
SOF = 5
SPLIT = 8
STALL = 14
byte()[source]

Return the PID’s value with its upper nibble.

category()[source]

Returns the USBPIDCategory that each given PID belongs to.

direction()[source]

Get a USB direction from a PacketID.

classmethod from_byte(byte, skip_checks=False)[source]

Creates a PID object from a byte.

classmethod from_int(value, skip_checks=True)[source]

Create a PID object from an integer.

classmethod from_name(name)[source]

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

is_data()[source]

Returns true iff the given PID represents a DATA packet.

is_handshake()[source]

Returns true iff the given PID represents a handshake packet.

is_invalid()[source]

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

is_token()[source]

Returns true iff the given PID represents a token packet.

classmethod parse(value)[source]

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

summarize()[source]

Return a summary of the given packet.

class usb_protocol.types.USBRequestRecipient(value)[source]

Bases: IntEnum

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

DEVICE = 0
ENDPOINT = 2
INTERFACE = 1
OTHER = 3
RESERVED = 4
classmethod from_integer(value)[source]

Special factory that correctly handles reserved values.

classmethod from_request_type(request_type_int)[source]

Helper method that extracts the type from a request_type integer.

class usb_protocol.types.USBRequestType(value)[source]

Bases: IntEnum

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

CLASS = 1
RESERVED = 3
STANDARD = 0
VENDOR = 2
classmethod from_request_type(request_type_int)[source]

Helper method that extracts the type from a request_type integer.

class usb_protocol.types.USBStandardRequests(value)[source]

Bases: IntEnum

An enumeration.

CLEAR_FEATURE = 1
GET_CONFIGURATION = 8
GET_DESCRIPTOR = 6
GET_ENCRYPTION = 14
GET_HANDSHAKE = 16
GET_INTERFACE = 10
GET_SECURITY_DATA = 19
GET_STATUS = 0
LOOPBACK_DATA_READ = 22
LOOPBACK_DATA_WRITE = 21
SET_ADDRESS = 5
SET_CONFIGURATION = 9
SET_CONNECTION = 17
SET_DESCRIPTOR = 7
SET_ENCRYPTION = 13
SET_FEATURE = 3
SET_HANDSHAKE = 15
SET_INTERFACE = 11
SET_INTERFACE_DS = 23
SET_ISOCH_DELAY = 49
SET_SECURITY_DATA = 18
SET_SEL = 48
SET_WUSB_DATA = 20
SYNCH_FRAME = 12
class usb_protocol.types.USBSynchronizationType(value)[source]

Bases: IntEnum

An enumeration.

ADAPTIVE = 2
ASYNC = 1
NONE = 0
SYNCHRONOUS = 3
class usb_protocol.types.USBTransferType(value)[source]

Bases: IntEnum

An enumeration.

BULK = 2
CONTROL = 0
INTERRUPT = 3
ISOCHRONOUS = 1
class usb_protocol.types.USBUsageType(value)[source]

Bases: IntEnum

An enumeration.

DATA = 0
FEEDBACK = 1
IMPLICIT_FEEDBACK = 2
usb_protocol.types.endpoint_number_from_address(number)[source]