Skip to content

tylinux/lsusb_darwin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lsusb for macOS

A Swift command-line tool that lists USB devices connected to a Mac, similar to Linux usbutils lsusb.

Features

  • List all connected USB devices in the Linux lsusb one-line format
  • Verbose device information (-v)
  • USB topology tree view (-t)
  • Filter by bus/device number (-s bus:dev)
  • Filter by vendor/product ID (-d vendor:product)
  • No external dependencies beyond Apple's IOKit

Requirements

  • macOS 12.0+
  • Swift 5.5+

Build

cd /Users/tylinux/Developer/Projects/lsusb_darwin
swift build

For a release build:

swift build -c release

Install

Using Make

make install

Install to a custom prefix:

make install PREFIX=$HOME/.local

Manual

cp .build/release/lsusb /usr/local/bin/

Usage

lsusb [options]

Options

Option Description
-v, --version Show version information
-V, --verbose Show detailed device information
-t, --tree Show USB topology tree
-s bus:dev Show only devices on the specified bus and/or device
-d vendor:product Show only devices with the specified vendor and/or product ID
-h, --help Show help message

Examples

# Default listing
lsusb

# Show version
lsusb -v

# Verbose output
lsusb -V

# USB topology tree
lsusb -t

# Filter by vendor and product
lsusb -d 345f:2131

# Filter by bus only
lsusb -s 32:

# Filter by device number only
lsusb -s :3

Example Output

Bus 032 Device 003: ID 0x345f:0x2131 MACROSILICON OZC3-3 Video
Bus 032 Device 004: ID 0x0bda:0x8156 Realtek USB 10_100_1G_2_5G LAN
Bus 032 Device 005: ID 0x0572:0x180a HP HP Dock Audio

How It Works

The tool uses Apple's IOKit framework to iterate the IOUSB registry plane, reads properties from IOUSBHostDevice entries, and formats the results like Linux lsusb.

Key property mappings:

Linux lsusb IOKit Source
Bus Number locationID >> 24
Device Number USB Address
Vendor ID idVendor
Product ID idProduct
Vendor/Product Name USB Vendor Name / USB Product Name
Serial Number USB Serial Number
Speed UsbLinkSpeed / USBSpeed / Device Speed

License

This project is licensed under the MIT License. See LICENSE for details.

About

lsusb for macOS

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors