OpenPort - method of object PmComm
Open the serial/ethernet communication port of this object.
OpenPort(sParam As String) As Boolean
b = oComm.OpenPort(sParam)
|sParam||(String) Parameters for opening |
for serial link: Only the port name is entered here. For example "COM1".
for Ethernet: The IP address and/or port number is entered. For example "ipaddress:192.168.0.126;port:61682;". If any of the entries remain empty, the previously entered value remains valid.
for serial link: Port has been successfully opened.
for Ethernet: The parameters has been set and connection will be opened during the next transfer.
for serial link: Port hasn't been opened. Possible fault: Such port is not present on this computer or it is already used.
for Ethernet: Because this method doesn't create a connection, false is return only for bad input parameters.
This method CANNOT be used for PmComm
object that contains PmCommMsg
messages of the Slave
for serial link
: The default setting of the serial communication port is defined in Serial port
configurator in parameters of the serial link. If it is necessary to change dynamically the serial link port, it is possible to set Not set
in its parameters and than by the OpenPort
methods change the port.
For serial link each PmComm object must have defined another communication port. For example, when one PmComm object communicates through COM1, then next PmComm object can communicate for example through COM2 (COM3,..) but it mustn't communicate through COM1.
for Ethernet: The method only adds new connection parameters into the object. The following transfer will close existing connection and open new connection.
for serial link: Algorithm called after the request for sending 1 message (by PmCommMsg
object) through COM1
If oComm.OpenPort("COM1") Then
for Ethernet: The IP address and port is set. The next calling of Run
method will close previous connection and open new connection.