Select RTU or TCP/IP


Recommended Posts


Is there  a way where I can have a user select whether they want to connect to a single device using either RTU or TCP/IP.

Currently I have a Button Component with the sequence


However, this only allows the user to configure the device using the protocol that I preconfigure. I would want them to select whether they want to connect using a serial or ethernet connection.

Link to comment
Share on other sites

There are a couple ways to do it, but the easiest is simply to preconfigure a serial and an ethernet port, giving them unique names.  Then you can just do:

device.myDevice.PortName = "mySerialPort"


device.myDevice.PortName = "myEthernetPort"

You will probably have to do initcomm() after switching.

Note you can also do this with the ProtocolName variable to switch protocols.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.