mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-08 22:36:48 +02:00
add interface_association section
This commit is contained in:
@ -119,6 +119,7 @@ def parse(data, raw=False, quiet=False):
|
|||||||
section = ''
|
section = ''
|
||||||
device_descriptor_list = []
|
device_descriptor_list = []
|
||||||
configuration_descriptor_list = []
|
configuration_descriptor_list = []
|
||||||
|
interface_association_list = []
|
||||||
interface_descriptor_list = []
|
interface_descriptor_list = []
|
||||||
cdc_header_list = []
|
cdc_header_list = []
|
||||||
cdc_call_management_list = []
|
cdc_call_management_list = []
|
||||||
@ -147,6 +148,7 @@ def parse(data, raw=False, quiet=False):
|
|||||||
output_line = {}
|
output_line = {}
|
||||||
device_descriptor_list = []
|
device_descriptor_list = []
|
||||||
configuration_descriptor_list = []
|
configuration_descriptor_list = []
|
||||||
|
interface_association_list = []
|
||||||
interface_descriptor_list = []
|
interface_descriptor_list = []
|
||||||
cdc_header_list = []
|
cdc_header_list = []
|
||||||
cdc_call_management_list = []
|
cdc_call_management_list = []
|
||||||
@ -168,6 +170,7 @@ def parse(data, raw=False, quiet=False):
|
|||||||
output_line = {}
|
output_line = {}
|
||||||
device_descriptor_list = []
|
device_descriptor_list = []
|
||||||
configuration_descriptor_list = []
|
configuration_descriptor_list = []
|
||||||
|
interface_association_list = []
|
||||||
interface_descriptor_list = []
|
interface_descriptor_list = []
|
||||||
cdc_header_list = []
|
cdc_header_list = []
|
||||||
cdc_call_management_list = []
|
cdc_call_management_list = []
|
||||||
@ -195,6 +198,7 @@ def parse(data, raw=False, quiet=False):
|
|||||||
section = 'device_descriptor'
|
section = 'device_descriptor'
|
||||||
device_descriptor_list = []
|
device_descriptor_list = []
|
||||||
configuration_descriptor_list = []
|
configuration_descriptor_list = []
|
||||||
|
interface_association_list = []
|
||||||
interface_descriptor_list = []
|
interface_descriptor_list = []
|
||||||
cdc_header_list = []
|
cdc_header_list = []
|
||||||
cdc_call_management_list = []
|
cdc_call_management_list = []
|
||||||
@ -213,6 +217,11 @@ def parse(data, raw=False, quiet=False):
|
|||||||
interface_descriptor_list = []
|
interface_descriptor_list = []
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if line.startswith(' Interface Association:'):
|
||||||
|
section = 'interface_association'
|
||||||
|
interface_association_list = []
|
||||||
|
continue
|
||||||
|
|
||||||
if line.startswith(' Interface Descriptor:'):
|
if line.startswith(' Interface Descriptor:'):
|
||||||
section = 'interface_descriptor'
|
section = 'interface_descriptor'
|
||||||
|
|
||||||
@ -319,35 +328,23 @@ def parse(data, raw=False, quiet=False):
|
|||||||
output_line['device_descriptor']['configuration_descriptor']['attributes'] = configuration_descriptor_list
|
output_line['device_descriptor']['configuration_descriptor']['attributes'] = configuration_descriptor_list
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if section == 'interface_descriptor' and line.startswith(' '):
|
if section == 'interface_association' and line.startswith(' '):
|
||||||
interface_descriptor_list.append(_add_attributes(line))
|
interface_association_list.append(_add_attributes(line))
|
||||||
|
if 'interface_association' not in output_line['device_descriptor']['configuration_descriptor']:
|
||||||
|
output_line['device_descriptor']['configuration_descriptor']['interface_association'] = {}
|
||||||
|
output_line['device_descriptor']['configuration_descriptor']['interface_association']['attributes'] = interface_association_list
|
||||||
|
continue
|
||||||
|
|
||||||
if cdc_header_list:
|
if section == 'report_descriptors' and line.startswith(' '):
|
||||||
interface_descriptor_list.append({'cdc_header': cdc_header_list})
|
report_descriptors_list.append(_add_attributes(line))
|
||||||
|
continue
|
||||||
|
|
||||||
if cdc_call_management_list:
|
if section == 'hid_device_descriptor' and line.startswith(' '):
|
||||||
interface_descriptor_list.append({'cdc_call_management': cdc_call_management_list})
|
if report_descriptors_list:
|
||||||
|
hid_device_descriptor_list.append({'report_descriptors': report_descriptors_list})
|
||||||
if cdc_acm_list:
|
|
||||||
interface_descriptor_list.append({'cdc_acm': cdc_acm_list})
|
|
||||||
|
|
||||||
if cdc_union_list:
|
|
||||||
interface_descriptor_list.append({'cdc_union': cdc_union_list})
|
|
||||||
|
|
||||||
if endpoint_descriptor_list:
|
|
||||||
interface_descriptor_list.append({'endpoint_descriptor': endpoint_descriptor_list})
|
|
||||||
|
|
||||||
if interface_descriptor_list:
|
|
||||||
if 'interface_descriptor_list' not in output_line['device_descriptor']['configuration_descriptor']:
|
|
||||||
output_line['device_descriptor']['configuration_descriptor']['interface_descriptor'] = []
|
|
||||||
output_line['device_descriptor']['configuration_descriptor']['interface_descriptor'].append(interface_descriptor_list)
|
|
||||||
|
|
||||||
cdc_header_list = []
|
|
||||||
cdc_call_management_list = []
|
|
||||||
cdc_acm_list = []
|
|
||||||
cdc_union_list = []
|
|
||||||
endpoint_descriptor_list = []
|
|
||||||
|
|
||||||
|
report_descriptors_list = []
|
||||||
|
hid_device_descriptor_list.append(_add_attributes(line))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if section == 'cdc_header' and line.startswith(' '):
|
if section == 'cdc_header' and line.startswith(' '):
|
||||||
@ -374,16 +371,34 @@ def parse(data, raw=False, quiet=False):
|
|||||||
endpoint_descriptor_list.append(_add_attributes(line))
|
endpoint_descriptor_list.append(_add_attributes(line))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if section == 'hid_device_descriptor' and line.startswith(' '):
|
if section == 'interface_descriptor' and line.startswith(' '):
|
||||||
if report_descriptors_list:
|
interface_descriptor_list.append(_add_attributes(line))
|
||||||
hid_device_descriptor_list.append({'report_descriptors': report_descriptors_list})
|
|
||||||
|
|
||||||
report_descriptors_list = []
|
if cdc_header_list:
|
||||||
hid_device_descriptor_list.append(_add_attributes(line))
|
interface_descriptor_list.append({'cdc_header': cdc_header_list})
|
||||||
continue
|
|
||||||
|
|
||||||
if section == 'report_descriptors' and line.startswith(' '):
|
if cdc_call_management_list:
|
||||||
report_descriptors_list.append(_add_attributes(line))
|
interface_descriptor_list.append({'cdc_call_management': cdc_call_management_list})
|
||||||
|
|
||||||
|
if cdc_acm_list:
|
||||||
|
interface_descriptor_list.append({'cdc_acm': cdc_acm_list})
|
||||||
|
|
||||||
|
if cdc_union_list:
|
||||||
|
interface_descriptor_list.append({'cdc_union': cdc_union_list})
|
||||||
|
|
||||||
|
if endpoint_descriptor_list:
|
||||||
|
interface_descriptor_list.append({'endpoint_descriptor': endpoint_descriptor_list})
|
||||||
|
|
||||||
|
if interface_descriptor_list:
|
||||||
|
if 'interface_descriptor_list' not in output_line['device_descriptor']['configuration_descriptor']:
|
||||||
|
output_line['device_descriptor']['configuration_descriptor']['interface_descriptor'] = []
|
||||||
|
output_line['device_descriptor']['configuration_descriptor']['interface_descriptor'].append(interface_descriptor_list)
|
||||||
|
|
||||||
|
cdc_header_list = []
|
||||||
|
cdc_call_management_list = []
|
||||||
|
cdc_acm_list = []
|
||||||
|
cdc_union_list = []
|
||||||
|
endpoint_descriptor_list = []
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if section == 'hub_descriptor' and line.startswith(' '):
|
if section == 'hub_descriptor' and line.startswith(' '):
|
||||||
@ -398,6 +413,27 @@ def parse(data, raw=False, quiet=False):
|
|||||||
output_line['hub_descriptor']['hub_port_status'] = hub_port_status_list
|
output_line['hub_descriptor']['hub_port_status'] = hub_port_status_list
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# get final list entries
|
||||||
|
if cdc_header_list:
|
||||||
|
interface_descriptor_list.append({'cdc_header': cdc_header_list})
|
||||||
|
|
||||||
|
if cdc_call_management_list:
|
||||||
|
interface_descriptor_list.append({'cdc_call_management': cdc_call_management_list})
|
||||||
|
|
||||||
|
if cdc_acm_list:
|
||||||
|
interface_descriptor_list.append({'cdc_acm': cdc_acm_list})
|
||||||
|
|
||||||
|
if cdc_union_list:
|
||||||
|
interface_descriptor_list.append({'cdc_union': cdc_union_list})
|
||||||
|
|
||||||
|
if endpoint_descriptor_list:
|
||||||
|
interface_descriptor_list.append({'endpoint_descriptor': endpoint_descriptor_list})
|
||||||
|
|
||||||
|
if interface_descriptor_list:
|
||||||
|
if 'interface_descriptor_list' not in output_line['device_descriptor']['configuration_descriptor']:
|
||||||
|
output_line['device_descriptor']['configuration_descriptor']['interface_descriptor'] = []
|
||||||
|
output_line['device_descriptor']['configuration_descriptor']['interface_descriptor'].append(interface_descriptor_list)
|
||||||
|
|
||||||
if output_line:
|
if output_line:
|
||||||
raw_output.append(output_line)
|
raw_output.append(output_line)
|
||||||
|
|
||||||
|
100
tests/fixtures/centos-7.7/lsusb-v-single.out
vendored
Normal file
100
tests/fixtures/centos-7.7/lsusb-v-single.out
vendored
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
Bus 003 Device 090: ID 1915:521a Nordic Semiconductor ASA nRF52 USB CDC BLE Demo
|
||||||
|
Couldn't open device, some information will be missing
|
||||||
|
Device Descriptor:
|
||||||
|
bLength 18
|
||||||
|
bDescriptorType 1
|
||||||
|
bcdUSB 2.00
|
||||||
|
bDeviceClass 0
|
||||||
|
bDeviceSubClass 0
|
||||||
|
bDeviceProtocol 0
|
||||||
|
bMaxPacketSize0 64
|
||||||
|
idVendor 0x1915 Nordic Semiconductor ASA
|
||||||
|
idProduct 0x521a
|
||||||
|
bcdDevice 1.00
|
||||||
|
iManufacturer 1 Nordic Semiconductor
|
||||||
|
iProduct 2 nRF52 USB CDC BLE Demo
|
||||||
|
iSerial 3 F42DE60BE261
|
||||||
|
bNumConfigurations 1
|
||||||
|
Configuration Descriptor:
|
||||||
|
bLength 9
|
||||||
|
bDescriptorType 2
|
||||||
|
wTotalLength 0x004b
|
||||||
|
bNumInterfaces 2
|
||||||
|
bConfigurationValue 1
|
||||||
|
iConfiguration 4
|
||||||
|
bmAttributes 0xc0
|
||||||
|
Self Powered
|
||||||
|
MaxPower 100mA
|
||||||
|
Interface Association:
|
||||||
|
bLength 8
|
||||||
|
bDescriptorType 11
|
||||||
|
bFirstInterface 0
|
||||||
|
bInterfaceCount 2
|
||||||
|
bFunctionClass 2 Communications
|
||||||
|
bFunctionSubClass 2 Abstract (modem)
|
||||||
|
bFunctionProtocol 1 AT-commands (v.25ter)
|
||||||
|
iFunction 0
|
||||||
|
Interface Descriptor:
|
||||||
|
bLength 9
|
||||||
|
bDescriptorType 4
|
||||||
|
bInterfaceNumber 0
|
||||||
|
bAlternateSetting 0
|
||||||
|
bNumEndpoints 1
|
||||||
|
bInterfaceClass 2 Communications
|
||||||
|
bInterfaceSubClass 2 Abstract (modem)
|
||||||
|
bInterfaceProtocol 1 AT-commands (v.25ter)
|
||||||
|
iInterface 0
|
||||||
|
CDC Header:
|
||||||
|
bcdCDC 1.10
|
||||||
|
CDC Call Management:
|
||||||
|
bmCapabilities 0x03
|
||||||
|
call management
|
||||||
|
use DataInterface
|
||||||
|
bDataInterface 1
|
||||||
|
CDC ACM:
|
||||||
|
bmCapabilities 0x02
|
||||||
|
line coding and serial state
|
||||||
|
CDC Union:
|
||||||
|
bMasterInterface 0
|
||||||
|
bSlaveInterface 1
|
||||||
|
Endpoint Descriptor:
|
||||||
|
bLength 7
|
||||||
|
bDescriptorType 5
|
||||||
|
bEndpointAddress 0x82 EP 2 IN
|
||||||
|
bmAttributes 3
|
||||||
|
Transfer Type Interrupt
|
||||||
|
Synch Type None
|
||||||
|
Usage Type Data
|
||||||
|
wMaxPacketSize 0x0040 1x 64 bytes
|
||||||
|
bInterval 16
|
||||||
|
Interface Descriptor:
|
||||||
|
bLength 9
|
||||||
|
bDescriptorType 4
|
||||||
|
bInterfaceNumber 1
|
||||||
|
bAlternateSetting 0
|
||||||
|
bNumEndpoints 2
|
||||||
|
bInterfaceClass 10 CDC Data
|
||||||
|
bInterfaceSubClass 0
|
||||||
|
bInterfaceProtocol 0
|
||||||
|
iInterface 0
|
||||||
|
Endpoint Descriptor:
|
||||||
|
bLength 7
|
||||||
|
bDescriptorType 5
|
||||||
|
bEndpointAddress 0x81 EP 1 IN
|
||||||
|
bmAttributes 2
|
||||||
|
Transfer Type Bulk
|
||||||
|
Synch Type None
|
||||||
|
Usage Type Data
|
||||||
|
wMaxPacketSize 0x0040 1x 64 bytes
|
||||||
|
bInterval 0
|
||||||
|
Endpoint Descriptor:
|
||||||
|
bLength 7
|
||||||
|
bDescriptorType 5
|
||||||
|
bEndpointAddress 0x01 EP 1 OUT
|
||||||
|
bmAttributes 2
|
||||||
|
Transfer Type Bulk
|
||||||
|
Synch Type None
|
||||||
|
Usage Type Data
|
||||||
|
wMaxPacketSize 0x0040 1x 64 bytes
|
||||||
|
bInterval 0
|
||||||
|
|
Reference in New Issue
Block a user