This sounds like what you are asking for...
https://www.chiefdelphi.com/forums/s...5&postcount=10
... although it's not clear what your goal is. It's not typical to have a robot that needs to determine on-the-fly what' s plugged in. More info might yield a better solution.