The two are using different protocols. It could work as long as they don't misinterpret command meant for the other device but it is hard to guarantee until you test it.
A better way is to use an external relay to switch the rS485 pair from one device to another device. That ensure that only the correct device receive the intended commands.