create new device


Recommended Posts

  • 3 weeks later...

Yes. You do it with objects. First you have to create comm ports. For example:

CommPort = new(CCommEthernet)

CommPort.Address = Address

CommPort.Port = Port

or for serial:

CommPort = new(CCommSerial)

CommPort.Port = Port

Then to create a device:

CommDevice = new(CCommDevice)

CommDevice.PortObject = CommPort

CommDevice.ProtocolName = "ModbusRTU"

CommPort and CommDevice are global variables. If they go out of scope or are assigned something else, the device or port is destroyed. The port / device probably won't show up in the quick device configuration. You have to use the variables for all comms.

Link to comment
Share on other sites

  • 3 weeks later...

Hi Admin

I create new device as below

global IPServer
global IPDevice

IPServer = new(CCommEthernet)
IPServer.Address = ""
IPServer.Port = 2009
IPDevice = new(CCommDevice)
IPDevice.PortObject = "IPServer"
IPDevice.ProtocolName = "NULL Protocol"

private i
for (i = 0, i < 10, i++)
   Device.IPDevice.Write("abcdefghijklmnopq" + Chr(13))

I don't see any error alarm but it not work. I can not send any thing via IPDevice.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.