ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / Modbus functions
  • Properties specific to modbusSession variables
  • WLanguage functions that use modbusSession variables
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
modbusSession (Variable type)
In french: modbusSession
The modbusSession type is used to identify a connection to a Modbus server.
Remark: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Example
// Create a session and connect to the Modbus server at address 192.168.1.18 on port 3275.
Session is modbusSession
Session = ModbusConnectTCP("192.168.1.18",3275)

// If the connection fails, display the error
IF ErrorOccurred = True THEN
Trace(ErrorInfo())
ELSE
// Write a value to register 0x42 on the server.
ModbusWriteRegister(Session, 0x42,0xCAFE)
END

// Disconnect server
ModbusDisconnect(Session)
Remarks

Properties specific to modbusSession variables

The following properties can be used to handle Modbus sessions:
Property nameType usedEffect
ResponseTimeoutIntegerMaximum timeout for a Modbus server response.
SlaveIDIntegerSlave ID. Used to change the slave ID without having to open a session again.

WLanguage functions that use modbusSession variables

modbusSession variables can be handled using the following WLanguage functions:
ModbusConnectRTUConnects a client to a Modbus slave via a serial port.
ModbusConnectTCPConnects a client to a Modbus server via transmission control protocol (TCP).
ModbusDisconnectCloses the Modbus session.
ModbusReadBitReads one or more bits from a Modbus slave, starting at a specific address.
ModbusReadFloatReads one or more single-precision floats from a Modbus slave, starting at a specific address.
ModbusReadRegisterReads one or more registers from a Modbus slave, starting at a specific address.
ModbusWriteBitWrites one or multiple bits to a specific address in a Modbus slave.
ModbusWriteFloatWrites one or more single-precision floats to a Modbus slave, starting at a specific address.
ModbusWriteRegisterWrites one or more registers (16-bit values) to a Modbus slave, starting at a specific address.
See also
Minimum version required
  • Version 26
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/05/2024

Send a report | Local help