driver-inspector 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Your Name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: driver-inspector
3
+ Version: 0.1.0
4
+ Summary: Trace hardware -> kernel driver -> device node on Linux. Great for debugging 'why isn't my board detected'.
5
+ Author-email: Maan Jain <maanjain25@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/yourusername/driver-inspector
8
+ Project-URL: Issues, https://github.com/yourusername/driver-inspector/issues
9
+ Keywords: linux,kernel,driver,embedded,usb,serial,sysfs,diagnostics
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: System :: Hardware
17
+ Classifier: Topic :: Utilities
18
+ Requires-Python: >=3.7
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Dynamic: license-file
22
+
23
+ # driver-inspector
24
+
25
+ Trace hardware → kernel driver → device node, on Linux, from the command line.
26
+
27
+ If you've ever plugged in a USB-serial adapter, an Arduino, or a dev board and
28
+ wondered *"why isn't /dev/ttyUSB0 showing up"* or *"which kernel module is
29
+ actually handling this thing"*, this is for you.
30
+
31
+ It reads `/sys/class/tty`, `/sys/class/net`, and USB sysfs entries directly —
32
+ no root required for read-only inspection.
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ pip install driver-inspector
38
+ ```
39
+
40
+ > Linux only — it depends on `/sys` and `/dev`, which don't exist on macOS/Windows.
41
+
42
+ ## Usage
43
+
44
+ List all serial devices and the kernel driver behind each one:
45
+
46
+ ```bash
47
+ driver-inspector list-serial
48
+ ```
49
+
50
+ ```
51
+ device driver
52
+ -------------- ------------
53
+ /dev/ttyUSB0 ftdi_sio
54
+ /dev/ttyACM0 cdc_acm
55
+ ```
56
+
57
+ Inspect one device in detail (kernel driver, sysfs path, USB vendor/product ID):
58
+
59
+ ```bash
60
+ driver-inspector inspect /dev/ttyUSB0
61
+ ```
62
+
63
+ ```
64
+ device_node: /dev/ttyUSB0
65
+ exists: True
66
+ sys_path: /sys/class/tty/ttyUSB0
67
+ driver: ftdi_sio
68
+ usb_vendor_id: 0403
69
+ usb_product_id: 6001
70
+ ```
71
+
72
+ List network interfaces and their drivers:
73
+
74
+ ```bash
75
+ driver-inspector list-net
76
+ ```
77
+
78
+ Show raw `lsusb` output for cross-reference:
79
+
80
+ ```bash
81
+ driver-inspector usb
82
+ ```
83
+
84
+ ## Why
85
+
86
+ Linux's hardware → driver → device-node chain (USB descriptor → kernel module
87
+ via `lsmod`/`modinfo` → `udev` → `/dev/*`) is not obvious to newcomers, and
88
+ even experienced developers reach for a half-remembered chain of `lsusb`,
89
+ `dmesg`, and `readlink` commands. This wraps that chain into one command.
90
+
91
+ ## Development
92
+
93
+ ```bash
94
+ git clone https://github.com/yourusername/driver-inspector
95
+ cd driver-inspector
96
+ pip install -e .
97
+ driver-inspector list-serial
98
+ ```
99
+
100
+ ## Publishing to PyPI
101
+
102
+ ```bash
103
+ pip install build twine
104
+ python -m build
105
+ twine upload dist/*
106
+ ```
107
+
108
+ ## License
109
+
110
+ MIT
@@ -0,0 +1,88 @@
1
+ # driver-inspector
2
+
3
+ Trace hardware → kernel driver → device node, on Linux, from the command line.
4
+
5
+ If you've ever plugged in a USB-serial adapter, an Arduino, or a dev board and
6
+ wondered *"why isn't /dev/ttyUSB0 showing up"* or *"which kernel module is
7
+ actually handling this thing"*, this is for you.
8
+
9
+ It reads `/sys/class/tty`, `/sys/class/net`, and USB sysfs entries directly —
10
+ no root required for read-only inspection.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ pip install driver-inspector
16
+ ```
17
+
18
+ > Linux only — it depends on `/sys` and `/dev`, which don't exist on macOS/Windows.
19
+
20
+ ## Usage
21
+
22
+ List all serial devices and the kernel driver behind each one:
23
+
24
+ ```bash
25
+ driver-inspector list-serial
26
+ ```
27
+
28
+ ```
29
+ device driver
30
+ -------------- ------------
31
+ /dev/ttyUSB0 ftdi_sio
32
+ /dev/ttyACM0 cdc_acm
33
+ ```
34
+
35
+ Inspect one device in detail (kernel driver, sysfs path, USB vendor/product ID):
36
+
37
+ ```bash
38
+ driver-inspector inspect /dev/ttyUSB0
39
+ ```
40
+
41
+ ```
42
+ device_node: /dev/ttyUSB0
43
+ exists: True
44
+ sys_path: /sys/class/tty/ttyUSB0
45
+ driver: ftdi_sio
46
+ usb_vendor_id: 0403
47
+ usb_product_id: 6001
48
+ ```
49
+
50
+ List network interfaces and their drivers:
51
+
52
+ ```bash
53
+ driver-inspector list-net
54
+ ```
55
+
56
+ Show raw `lsusb` output for cross-reference:
57
+
58
+ ```bash
59
+ driver-inspector usb
60
+ ```
61
+
62
+ ## Why
63
+
64
+ Linux's hardware → driver → device-node chain (USB descriptor → kernel module
65
+ via `lsmod`/`modinfo` → `udev` → `/dev/*`) is not obvious to newcomers, and
66
+ even experienced developers reach for a half-remembered chain of `lsusb`,
67
+ `dmesg`, and `readlink` commands. This wraps that chain into one command.
68
+
69
+ ## Development
70
+
71
+ ```bash
72
+ git clone https://github.com/yourusername/driver-inspector
73
+ cd driver-inspector
74
+ pip install -e .
75
+ driver-inspector list-serial
76
+ ```
77
+
78
+ ## Publishing to PyPI
79
+
80
+ ```bash
81
+ pip install build twine
82
+ python -m build
83
+ twine upload dist/*
84
+ ```
85
+
86
+ ## License
87
+
88
+ MIT
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "driver-inspector"
7
+ version = "0.1.0"
8
+ description = "Trace hardware -> kernel driver -> device node on Linux. Great for debugging 'why isn't my board detected'."
9
+ readme = "README.md"
10
+ requires-python = ">=3.7"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Maan Jain", email = "maanjain25@gmail.com" }
14
+ ]
15
+ keywords = ["linux", "kernel", "driver", "embedded", "usb", "serial", "sysfs", "diagnostics"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Operating System :: POSIX :: Linux",
22
+ "Programming Language :: Python :: 3",
23
+ "Topic :: System :: Hardware",
24
+ "Topic :: Utilities",
25
+ ]
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/yourusername/driver-inspector"
29
+ Issues = "https://github.com/yourusername/driver-inspector/issues"
30
+
31
+ [project.scripts]
32
+ driver-inspector = "driver_inspector.cli:main"
33
+
34
+ [tool.setuptools.packages.find]
35
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """driver-inspector — trace hardware -> kernel driver -> device node on Linux."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,174 @@
1
+ """Core logic and CLI entry point for driver-inspector.
2
+
3
+ Reads Linux's /sys and /dev to answer: for a given device, which kernel
4
+ driver claimed it, and what does its sysfs entry look like.
5
+ """
6
+
7
+ import argparse
8
+ import os
9
+ import subprocess
10
+ import sys
11
+
12
+ SYS_TTY = "/sys/class/tty"
13
+ SYS_NET = "/sys/class/net"
14
+
15
+
16
+ def get_driver_for_device(device_dir: str):
17
+ """Given a sysfs device directory, resolve the 'driver' symlink to a name."""
18
+ driver_link = os.path.join(device_dir, "driver")
19
+ if os.path.islink(driver_link):
20
+ target = os.readlink(driver_link)
21
+ return os.path.basename(target)
22
+ return None
23
+
24
+
25
+ def find_usb_ids(start_path: str):
26
+ """Walk up the sysfs tree from a device path looking for idVendor/idProduct."""
27
+ vendor = product = None
28
+ current = start_path
29
+ for _ in range(8):
30
+ vendor_file = os.path.join(current, "idVendor")
31
+ product_file = os.path.join(current, "idProduct")
32
+ if os.path.isfile(vendor_file) and os.path.isfile(product_file):
33
+ with open(vendor_file) as f:
34
+ vendor = f.read().strip()
35
+ with open(product_file) as f:
36
+ product = f.read().strip()
37
+ break
38
+ parent = os.path.dirname(current)
39
+ if parent == current:
40
+ break
41
+ current = parent
42
+ return vendor, product
43
+
44
+
45
+ def list_serial_devices():
46
+ """List every device under /sys/class/tty that has a real backing device."""
47
+ results = []
48
+ if not os.path.isdir(SYS_TTY):
49
+ return results
50
+ for name in sorted(os.listdir(SYS_TTY)):
51
+ device_dir = os.path.join(SYS_TTY, name, "device")
52
+ if os.path.exists(device_dir):
53
+ driver = get_driver_for_device(device_dir)
54
+ results.append({"name": name, "driver": driver})
55
+ return results
56
+
57
+
58
+ def list_network_devices():
59
+ """List every device under /sys/class/net and its driver."""
60
+ results = []
61
+ if not os.path.isdir(SYS_NET):
62
+ return results
63
+ for name in sorted(os.listdir(SYS_NET)):
64
+ device_dir = os.path.join(SYS_NET, name, "device")
65
+ driver = get_driver_for_device(device_dir) if os.path.exists(device_dir) else None
66
+ results.append({"name": name, "driver": driver})
67
+ return results
68
+
69
+
70
+ def inspect_device(path: str):
71
+ """Inspect a /dev/... node: does it exist, what claimed it, what's its USB ID."""
72
+ name = os.path.basename(path)
73
+ info = {"device_node": path, "exists": os.path.exists(path)}
74
+
75
+ candidates = [
76
+ os.path.join(SYS_TTY, name),
77
+ os.path.join(SYS_NET, name),
78
+ f"/sys/class/block/{name}",
79
+ ]
80
+ sys_path = next((c for c in candidates if os.path.isdir(c)), None)
81
+
82
+ if sys_path is None:
83
+ info["error"] = (
84
+ f"No matching entry found under /sys/class for '{name}'. "
85
+ "It may not be a tty/net/block device, or may not exist."
86
+ )
87
+ return info
88
+
89
+ device_dir = os.path.join(sys_path, "device")
90
+ real_device_dir = os.path.realpath(device_dir) if os.path.exists(device_dir) else None
91
+
92
+ info["sys_path"] = os.path.realpath(sys_path)
93
+ info["driver"] = get_driver_for_device(device_dir) if real_device_dir else None
94
+
95
+ if real_device_dir:
96
+ vendor, product = find_usb_ids(real_device_dir)
97
+ info["usb_vendor_id"] = vendor
98
+ info["usb_product_id"] = product
99
+
100
+ return info
101
+
102
+
103
+ def run_lsusb():
104
+ try:
105
+ out = subprocess.run(["lsusb"], capture_output=True, text=True, timeout=5)
106
+ return out.stdout
107
+ except FileNotFoundError:
108
+ return None
109
+
110
+
111
+ def print_table(rows, columns):
112
+ widths = [max(len(str(r.get(c, ""))) for r in rows + [dict(zip(columns, columns))]) for c in columns]
113
+ header = " ".join(c.ljust(w) for c, w in zip(columns, widths))
114
+ print(header)
115
+ print(" ".join("-" * w for w in widths))
116
+ for r in rows:
117
+ print(" ".join(str(r.get(c, "") or "unknown").ljust(w) for c, w in zip(columns, widths)))
118
+
119
+
120
+ def main():
121
+ parser = argparse.ArgumentParser(
122
+ prog="driver-inspector",
123
+ description="Trace hardware -> kernel driver -> device node on Linux.",
124
+ )
125
+ sub = parser.add_subparsers(dest="command")
126
+
127
+ sub.add_parser("list-serial", help="List tty/serial devices and their kernel drivers")
128
+ sub.add_parser("list-net", help="List network interfaces and their kernel drivers")
129
+
130
+ inspect_p = sub.add_parser("inspect", help="Inspect a specific device node")
131
+ inspect_p.add_argument("device", help="Device path, e.g. /dev/ttyUSB0")
132
+
133
+ sub.add_parser("usb", help="Show raw lsusb output")
134
+
135
+ args = parser.parse_args()
136
+
137
+ if sys.platform != "linux":
138
+ print("driver-inspector only supports Linux (it reads /sys and /dev directly).")
139
+ sys.exit(1)
140
+
141
+ if args.command == "list-serial":
142
+ devices = list_serial_devices()
143
+ if not devices:
144
+ print("No tty devices with a backing sysfs device found.")
145
+ return
146
+ print_table(
147
+ [{"device": f"/dev/{d['name']}", "driver": d["driver"]} for d in devices],
148
+ ["device", "driver"],
149
+ )
150
+ elif args.command == "list-net":
151
+ devices = list_network_devices()
152
+ if not devices:
153
+ print("No network devices found.")
154
+ return
155
+ print_table(
156
+ [{"interface": d["name"], "driver": d["driver"]} for d in devices],
157
+ ["interface", "driver"],
158
+ )
159
+ elif args.command == "inspect":
160
+ info = inspect_device(args.device)
161
+ for key, value in info.items():
162
+ print(f"{key}: {value}")
163
+ elif args.command == "usb":
164
+ out = run_lsusb()
165
+ if out:
166
+ print(out, end="")
167
+ else:
168
+ print("lsusb not found. Install usbutils: sudo apt-get install usbutils")
169
+ else:
170
+ parser.print_help()
171
+
172
+
173
+ if __name__ == "__main__":
174
+ main()
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: driver-inspector
3
+ Version: 0.1.0
4
+ Summary: Trace hardware -> kernel driver -> device node on Linux. Great for debugging 'why isn't my board detected'.
5
+ Author-email: Maan Jain <maanjain25@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/yourusername/driver-inspector
8
+ Project-URL: Issues, https://github.com/yourusername/driver-inspector/issues
9
+ Keywords: linux,kernel,driver,embedded,usb,serial,sysfs,diagnostics
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: System :: Hardware
17
+ Classifier: Topic :: Utilities
18
+ Requires-Python: >=3.7
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Dynamic: license-file
22
+
23
+ # driver-inspector
24
+
25
+ Trace hardware → kernel driver → device node, on Linux, from the command line.
26
+
27
+ If you've ever plugged in a USB-serial adapter, an Arduino, or a dev board and
28
+ wondered *"why isn't /dev/ttyUSB0 showing up"* or *"which kernel module is
29
+ actually handling this thing"*, this is for you.
30
+
31
+ It reads `/sys/class/tty`, `/sys/class/net`, and USB sysfs entries directly —
32
+ no root required for read-only inspection.
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ pip install driver-inspector
38
+ ```
39
+
40
+ > Linux only — it depends on `/sys` and `/dev`, which don't exist on macOS/Windows.
41
+
42
+ ## Usage
43
+
44
+ List all serial devices and the kernel driver behind each one:
45
+
46
+ ```bash
47
+ driver-inspector list-serial
48
+ ```
49
+
50
+ ```
51
+ device driver
52
+ -------------- ------------
53
+ /dev/ttyUSB0 ftdi_sio
54
+ /dev/ttyACM0 cdc_acm
55
+ ```
56
+
57
+ Inspect one device in detail (kernel driver, sysfs path, USB vendor/product ID):
58
+
59
+ ```bash
60
+ driver-inspector inspect /dev/ttyUSB0
61
+ ```
62
+
63
+ ```
64
+ device_node: /dev/ttyUSB0
65
+ exists: True
66
+ sys_path: /sys/class/tty/ttyUSB0
67
+ driver: ftdi_sio
68
+ usb_vendor_id: 0403
69
+ usb_product_id: 6001
70
+ ```
71
+
72
+ List network interfaces and their drivers:
73
+
74
+ ```bash
75
+ driver-inspector list-net
76
+ ```
77
+
78
+ Show raw `lsusb` output for cross-reference:
79
+
80
+ ```bash
81
+ driver-inspector usb
82
+ ```
83
+
84
+ ## Why
85
+
86
+ Linux's hardware → driver → device-node chain (USB descriptor → kernel module
87
+ via `lsmod`/`modinfo` → `udev` → `/dev/*`) is not obvious to newcomers, and
88
+ even experienced developers reach for a half-remembered chain of `lsusb`,
89
+ `dmesg`, and `readlink` commands. This wraps that chain into one command.
90
+
91
+ ## Development
92
+
93
+ ```bash
94
+ git clone https://github.com/yourusername/driver-inspector
95
+ cd driver-inspector
96
+ pip install -e .
97
+ driver-inspector list-serial
98
+ ```
99
+
100
+ ## Publishing to PyPI
101
+
102
+ ```bash
103
+ pip install build twine
104
+ python -m build
105
+ twine upload dist/*
106
+ ```
107
+
108
+ ## License
109
+
110
+ MIT
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/driver_inspector/__init__.py
5
+ src/driver_inspector/cli.py
6
+ src/driver_inspector.egg-info/PKG-INFO
7
+ src/driver_inspector.egg-info/SOURCES.txt
8
+ src/driver_inspector.egg-info/dependency_links.txt
9
+ src/driver_inspector.egg-info/entry_points.txt
10
+ src/driver_inspector.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ driver-inspector = driver_inspector.cli:main
@@ -0,0 +1 @@
1
+ driver_inspector