|
|
|
|
|
ModbusConnectRTU (Function) In french: ModbusConnecteRTU Connects a client to a Modbus slave via a serial port.
Session is modbusSession
Session = ModbusConnectRTU("COM4",1)
IF ErrorOccurred = True THEN
Trace(ErrorInfo())
ELSE
ModbusWriteRegister(Session, 0x42,0xCAFE)
END
ModbusDisconnect(Session)
Syntax
<Session> = ModbusConnecteRTU(<Serial port> [, <Slave ID> [, <Rate> [, <Parity> [, <Nb data Bits> [, <Nb stop Bits>]]]]])
<Session>: modbusSession variable modbusSession variable used to communicate with the Modbus slave. <Serial port>: Character string Name of serial port to be used: COM1, COM2, COM3, ... COM256. <Slave ID>: Optional integer Slave identifier, between 0 and 255. By default, this parameter is set to 0 (broadcast address).
Note: The value 0 can also be specified if the slave identifier is to be specified later via the IDEsclave property of variable type modbusSession. <Rate>: Optional integer Data transfer rate (expressed in baud or bits per second) to be used for serial connection. By default, this parameter is set to 9600 baud. <Parity>: Optional integer Transfer parity on the port:
| | 0 | No parity | 1 | Even parity | 2 | Odd parity | Note: There is no default parity. <Nb data Bits>: Optional integer Number of data bits on serial port: 5, 6, 7 or 8. <Nb stop Bits>: Optional integer Number of stop bits on the serial port:
| | 0 (Default value) | 1 stop bit | 1 | 1.5 stop bits | 2 | 2 stop bits |
Remarks - After calling ModbusConnectRTU, it is recommended to check the ErrorOccurred variable to make sure there are no errors.
- The slave identifier is in the modbusSession variable. If an operation is to be performed on several different slaves, you can change the slave identifier in the modbusSession variable to avoid reopening the session.
Business / UI classification: Business Logic
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|