I coded this as an exercise https://apps.apple.com/app/cable-detective/id6765963737?mt=1... - reads everything it can about the plugged in cables and devices, feeds it to Apples internal AI.
In the latest version it even doesn't crash the computer anymore after rapid plug/unplugging action.