The 9870 and 9871 modules do not support direct interaction with the I/O pins via FPGA I/O Nodes due to the RS-232 and RS-485/422 protocols. Because of this, they cannot be selected in an I/O constant or I/O control. The nodes can be configured for the 9870/9871 ports, by right-click the node, and choose the module or port from the Select Items menu. However this doesn't help if you want to change ports on the fly in your program.
One way around this is to use a case structure with each port read explicitly selected in each case as in the following code snippet.
This can also be implemented similarly for the Write Byte method.