khuenguyen Posted December 23, 2010 Share Posted December 23, 2010 Hi admin, Can I create a new device from sequence? Link to comment Share on other sites More sharing options...
AzeoTech Posted January 10, 2011 Share Posted January 10, 2011 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 More sharing options...
khuenguyen Posted January 27, 2011 Author Share Posted January 27, 2011 Hi Admin I create new device as below global IPServer global IPDevice IPServer = new(CCommEthernet) IPServer.Address = "192.168.1.101" 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)) endfor 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 More sharing options...
AzeoTech Posted January 27, 2011 Share Posted January 27, 2011 PortObject is the actual object reference, not a string: IPDevice.PortObject = IPServer Link to comment Share on other sites More sharing options...
khuenguyen Posted January 27, 2011 Author Share Posted January 27, 2011 I repair it but it still not work. My Server with IP 192.168.1.101:2009 is running good. If I create device from "Device Configuration", it work normal. Link to comment Share on other sites More sharing options...
AzeoTech Posted January 27, 2011 Share Posted January 27, 2011 Sorry, its just IPDevice.write() not device.IPDevice.write(). IPDevice is a global variable, not a member variable of device. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.