2021-10-23 11:56:12 -07:00
|
|
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
2022-01-25 17:07:47 -08:00
|
|
|
<a id="jc.parsers.lsusb"></a>
|
2021-10-23 11:56:12 -07:00
|
|
|
|
|
|
|
# jc.parsers.lsusb
|
2022-01-25 17:07:47 -08:00
|
|
|
|
2021-10-23 11:56:12 -07:00
|
|
|
jc - JSON CLI output utility `lsusb` command output parser
|
|
|
|
|
|
|
|
Supports the `-v` option or no options.
|
|
|
|
|
|
|
|
Usage (cli):
|
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
$ lsusb -v | jc --lsusb
|
2021-10-23 11:56:12 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
or
|
2021-10-23 11:56:12 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
$ jc lsusb -v
|
2021-10-23 11:56:12 -07:00
|
|
|
|
|
|
|
Usage (module):
|
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
import jc
|
|
|
|
result = jc.parse('lsusb', lsusb_command_output)
|
2022-01-18 15:38:03 -08:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
or
|
2022-01-18 15:38:03 -08:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
import jc.parsers.lsusb
|
|
|
|
result = jc.parsers.lsusb.parse(lsusb_command_output)
|
2021-10-23 11:56:12 -07:00
|
|
|
|
|
|
|
Schema:
|
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
Note: <item> object keynames are assigned directly from the lsusb
|
|
|
|
output. If there are duplicate <item> names in a section, only the
|
|
|
|
last one is converted.
|
|
|
|
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"bus": string,
|
|
|
|
"device": string,
|
|
|
|
"id": string,
|
|
|
|
"description": string,
|
|
|
|
"device_descriptor": {
|
|
|
|
"<item>": {
|
|
|
|
"value": string,
|
|
|
|
"description": string,
|
|
|
|
"attributes": [
|
|
|
|
string
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"configuration_descriptor": {
|
|
|
|
"<item>": {
|
|
|
|
"value": string,
|
|
|
|
"description": string,
|
|
|
|
"attributes": [
|
|
|
|
string
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"interface_association": {
|
|
|
|
"<item>": {
|
|
|
|
"value": string,
|
|
|
|
"description": string,
|
|
|
|
"attributes": [
|
|
|
|
string
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"interface_descriptors": [
|
|
|
|
{
|
|
|
|
"<item>": {
|
|
|
|
"value": string,
|
|
|
|
"description": string,
|
|
|
|
"attributes": [
|
|
|
|
string
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"cdc_header": {
|
|
|
|
"<item>": {
|
|
|
|
"value": string,
|
|
|
|
"description": string,
|
|
|
|
"attributes": [
|
|
|
|
string
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"cdc_call_management": {
|
|
|
|
"<item>": {
|
|
|
|
"value": string,
|
|
|
|
"description": string,
|
|
|
|
"attributes": [
|
|
|
|
string
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"cdc_acm": {
|
|
|
|
"<item>": {
|
|
|
|
"value": string,
|
|
|
|
"description": string,
|
|
|
|
"attributes": [
|
|
|
|
string
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"cdc_union": {
|
|
|
|
"<item>": {
|
|
|
|
"value": string,
|
|
|
|
"description": string,
|
|
|
|
"attributes": [
|
|
|
|
string
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"endpoint_descriptors": [
|
|
|
|
{
|
|
|
|
"<item>": {
|
|
|
|
"value": string,
|
|
|
|
"description": string,
|
|
|
|
"attributes": [
|
|
|
|
string
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"hub_descriptor": {
|
|
|
|
"<item>": {
|
|
|
|
"value": string,
|
|
|
|
"description": string,
|
|
|
|
"attributes": [
|
|
|
|
string,
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"hub_port_status": {
|
|
|
|
"<item>": {
|
|
|
|
"value": string,
|
|
|
|
"attributes": [
|
|
|
|
string
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"device_status": {
|
|
|
|
"value": string,
|
|
|
|
"description": string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2021-10-23 11:56:12 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
**Examples**:
|
2021-10-23 11:56:12 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
|
|
|
|
$ lsusb -v | jc --lsusb -p
|
|
|
|
[
|
|
|
|
{
|
|
|
|
- `"bus"` - "002",
|
|
|
|
- `"device"` - "001",
|
|
|
|
- `"id"` - "1d6b:0001",
|
|
|
|
- `"description"` - "Linux Foundation 1.1 root hub",
|
|
|
|
- `"device_descriptor"` - {
|
|
|
|
- `"bLength"` - {
|
|
|
|
- `"value"` - "18"
|
|
|
|
},
|
|
|
|
- `"bDescriptorType"` - {
|
|
|
|
- `"value"` - "1"
|
|
|
|
},
|
|
|
|
- `"bcdUSB"` - {
|
|
|
|
- `"value"` - "1.10"
|
|
|
|
},
|
|
|
|
...
|
|
|
|
- `"bNumConfigurations"` - {
|
|
|
|
- `"value"` - "1"
|
|
|
|
},
|
|
|
|
- `"configuration_descriptor"` - {
|
|
|
|
- `"bLength"` - {
|
|
|
|
- `"value"` - "9"
|
|
|
|
},
|
|
|
|
...
|
|
|
|
- `"iConfiguration"` - {
|
|
|
|
- `"value"` - "0"
|
|
|
|
},
|
|
|
|
- `"bmAttributes"` - {
|
|
|
|
- `"value"` - "0xe0",
|
|
|
|
- `"attributes"` - [
|
|
|
|
"Self Powered",
|
|
|
|
"Remote Wakeup"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
- `"MaxPower"` - {
|
|
|
|
- `"description"` - "0mA"
|
|
|
|
},
|
|
|
|
- `"interface_descriptors"` - [
|
|
|
|
{
|
|
|
|
- `"bLength"` - {
|
|
|
|
- `"value"` - "9"
|
|
|
|
},
|
|
|
|
...
|
|
|
|
- `"bInterfaceProtocol"` - {
|
|
|
|
- `"value"` - "0",
|
|
|
|
- `"description"` - "Full speed (or root) hub"
|
|
|
|
},
|
|
|
|
- `"iInterface"` - {
|
|
|
|
- `"value"` - "0"
|
|
|
|
},
|
|
|
|
- `"endpoint_descriptors"` - [
|
|
|
|
{
|
|
|
|
- `"bLength"` - {
|
|
|
|
- `"value"` - "7"
|
|
|
|
},
|
|
|
|
...
|
|
|
|
- `"bmAttributes"` - {
|
|
|
|
- `"value"` - "3",
|
|
|
|
- `"attributes"` - [
|
|
|
|
"Transfer Type Interrupt",
|
|
|
|
"Synch Type None",
|
|
|
|
"Usage Type Data"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
- `"wMaxPacketSize"` - {
|
|
|
|
- `"value"` - "0x0002",
|
|
|
|
- `"description"` - "1x 2 bytes"
|
|
|
|
},
|
|
|
|
- `"bInterval"` - {
|
|
|
|
- `"value"` - "255"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
- `"hub_descriptor"` - {
|
|
|
|
- `"bLength"` - {
|
|
|
|
- `"value"` - "9"
|
|
|
|
},
|
|
|
|
...
|
|
|
|
- `"wHubCharacteristic"` - {
|
|
|
|
- `"value"` - "0x000a",
|
|
|
|
- `"attributes"` - [
|
|
|
|
"No power switching (usb 1.0)",
|
|
|
|
"Per-port overcurrent protection"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
...
|
|
|
|
- `"hub_port_status"` - {
|
|
|
|
"Port 1": {
|
|
|
|
- `"value"` - "0000.0103",
|
|
|
|
- `"attributes"` - [
|
|
|
|
"power",
|
|
|
|
"enable",
|
|
|
|
"connect"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"Port 2": {
|
|
|
|
- `"value"` - "0000.0103",
|
|
|
|
- `"attributes"` - [
|
|
|
|
"power",
|
|
|
|
"enable",
|
|
|
|
"connect"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
- `"device_status"` - {
|
|
|
|
- `"value"` - "0x0001",
|
|
|
|
- `"description"` - "Self Powered"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2021-10-23 11:56:12 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
<a id="jc.parsers.lsusb.info"></a>
|
2021-10-23 11:56:12 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
## info Objects
|
2021-10-23 11:56:12 -07:00
|
|
|
|
|
|
|
```python
|
2022-01-25 17:07:47 -08:00
|
|
|
class info()
|
2021-10-23 11:56:12 -07:00
|
|
|
```
|
2022-01-25 17:07:47 -08:00
|
|
|
|
2021-10-23 11:56:12 -07:00
|
|
|
Provides parser metadata (version, author, etc.)
|
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
<a id="jc.parsers.lsusb.parse"></a>
|
|
|
|
|
|
|
|
#### parse
|
|
|
|
|
2021-10-23 11:56:12 -07:00
|
|
|
```python
|
2022-01-25 17:07:47 -08:00
|
|
|
def parse(data, raw=False, quiet=False)
|
2021-10-23 11:56:12 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
Main text parsing function
|
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
**Arguments**:
|
2021-10-23 11:56:12 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
|
|
|
|
- `data` - (string) text data to parse
|
|
|
|
- `raw` - (boolean) unprocessed output if True
|
|
|
|
- `quiet` - (boolean) suppress warning messages if True
|
|
|
|
|
2021-10-23 11:56:12 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
**Returns**:
|
2021-10-23 11:56:12 -07:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
|
|
|
|
List of Dictionaries. Raw or processed structured data.
|
2021-10-23 11:56:12 -07:00
|
|
|
|
|
|
|
## Parser Information
|
|
|
|
Compatibility: linux
|
|
|
|
|
2021-12-01 16:12:51 -08:00
|
|
|
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|