Promotic

OpenPort - method of the PmaComm object

Description:
Open the serial/ethernet port of this object.
Syntax:
Boolean OpenPort(String sParam)
Parameters:
sParam(String) Parameters for opening
- for serial link: Only the port name is entered here.
For example "COM1".
- for Ethernet-client: The IP address and/or port number is entered.
Entries are in the KeyVal format, for example "ipaddress:192.168.0.126;port:61682;".
If any of the entries remain empty, then the previously entered value remains valid.
The ipaddress value can be the IPv4 address, IPv6 address, or computer name. See the "Network address" configurator.
Return value:
true -
- for serial link: Port has been successfully opened.
- for Ethernet-client: The parameters has been set and connection will be opened during the next transfer.
false -
- for serial link: Port hasn't been opened. Possible error: Such port is not present on this computer or it is already used.
- for Ethernet-client: Because this method doesn't create a connection, false is return only if for bad parameters of the method.
Note:
This method cannot be used for the PmaComm object that contains PmaCommMsg object of the Slave type.

for serial link: The default setting of the serial communication port is defined in the "Serial port" configurator in parameters of the serial link. If it is necessary to change dynamically the serial link port, then it is possible to enter Not set in its parameters and than by methods OpenPort and ClosePort change the port.
For serial link each PmaComm object must have defined another communication port. For example, if one PmaComm object communicates through COM1, then next PmaComm object can communicate for example through COM2 (COM3, ...) but it mustn't communicate through COM1.
for Ethernet-client: The method only adds new connection parameters into the object. The following transmission will close existing connection and open new connection.
See also:
Example1:
for serial link: Algorithm called after the request for sending 1 message (by the PmaCommMsg object) through COM1 port.
JavaScriptVBScriptSelect and copy to clipboard

if (oComm.OpenPort("COM1"))
{
oCommMsg.Run();
}
Example2:
for Ethernet-client: Sets the IP address and port. The next calling of the Run method will close previous connection and open new connection.
JavaScriptVBScriptSelect and copy to clipboard

oComm.OpenPort("ipaddress:192.168.0.2;port:88;");
oCommMsg.Run();

History:
Pm9.00.25: Fixed bug: Repeated calling of this method, at the moment when the previous connection has not yet ended, caused the communication to stop.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.