Skip to content
TF
All projects
Case study2026

USB Cable ID

Plug in an unlabeled cable and the port map tells you what it actually is, instead of guessing from the connector.

PythonIORegistryUSB Power DeliveryHTML

USB-C connectors say nothing about what is behind them. A cable in a drawer could be charge only, USB 2.0, 3.2 Gen 2, or Thunderbolt, and they are physically identical, so a 240 W Thunderbolt cable and a freebie that carries no data look the same. The only reliable way to tell them apart is to plug one in and read what the machine negotiated.

This reads the IORegistry and draws the result as a top-down picture of the machine, with a callout from every socket. Plug in three cables and each line fills in with that cable's verdict, which also teaches you which physical socket is which logical port, a thing no label on the case tells you.

The real work is underneath. When a cable carries an e-marker chip, macOS publishes the raw Power Delivery Discover Identity response in the IORegistry as Vendor Defined Objects, and those are just words of bits. Decoding them against the USB PD 3.1 spec turns them into the cable's own declared specs: its speed tier, its current limit, whether it is passive or active or optical, and who actually made it. When there is no chip, the page says inferred and gives you the floor the link came up at rather than inventing a ceiling.

It is three Python files and two HTML files, standard library only. No build step, no packages, and it reads nothing but the device tree, so it needs no special permissions.

Details worth knowing

  • 01Decodes USB Power Delivery Vendor Defined Objects against the PD 3.1 spec rather than reading a summary field, which is what makes it able to distinguish the cable's own e-marker from the identity of whatever is plugged into the far end.
  • 02Says inferred out loud when there is no e-marker, and treats the negotiated link as a floor rather than a ceiling, because a confident wrong number is worse than an honest range.
  • 03Standard library Python only, no packages and no build step, reading the IORegistry rather than anything privileged.
  • 04One instance per machine, and this is not a limitation to work around: a browser cannot read the hardware of the machine viewing the page. Opening the mini's address from the laptop shows the laptop, because the page asks the viewer's own copy first.
  • 05Exports a label CSV the Brother P-touch software imports directly, which is the actual end of the job: a cable with its speed and wattage printed on it.