Assuming your controller operates at 5V, when Device A is selected, apply 5V to DTR, and when Device B is selected, apply 5V to RTS - read each with input pins on your controller. If one or the other is always selected, you can save a pin - making DTR high for Device A and low for Device B.