feat: Add USB and direct-attach device detection#28
Conversation
- Add detect_local_devices() to scan for video, audio, serial devices - Add marvain devices detect CLI command with filtering options - Support table and JSON output formats - Platform-specific detection: AVFoundation/CoreAudio on macOS - Filter by device type (video, audio_input, audio_output, serial) - Filter by connection type (usb, direct) - Add 8 comprehensive tests for device detection
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 052afd87cd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # Check if USB device | ||
| conn_type = "usb" if "usb" in video_path.lower() or os.path.exists( | ||
| f"/sys/class/video4linux/{os.path.basename(video_path)}/device/driver" | ||
| ) else "direct" |
There was a problem hiding this comment.
Use a real USB check for Linux video devices
On Linux, conn_type is set to "usb" whenever /sys/class/video4linux/<device>/device/driver exists. That path exists for essentially every v4l2 device (PCI, platform, virtual, etc.), so non‑USB cameras will still be marked as USB. In practice this makes --connection direct return no results even when direct‑attach devices are present, and mislabels devices in the output. Consider checking the sysfs device ancestry for a USB bus (e.g., via /sys/class/video4linux/<device>/device/subsystem or udevadm) instead of only the driver path.
Useful? React with 👍 / 👎.
Summary
Implements automatic discovery of locally connected devices (USB and direct-attach) on the local machine.
Changes
New CLI Command:
marvain devices detectDevice Detection
Implementation
DetectedDevicedataclass inmarvain_cli/ops.pydetect_local_devices()aggregates all detection methodslist_detected_devices()provides filtering and dict outputTests
tests/test_ops.py::TestDeviceDetectionTesting
Files Changed
marvain_cli/ops.py: Device detection functionsmarvain_cli/typer_app.py:devices detectcommandmarvain_cli/argparse_app.py:devices detectcommand (fallback)tests/test_ops.py: 8 new testsPull Request opened by Augment Code with guidance from the PR author