ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / Modbus functions
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
ModbusSendRawFrame (Function)
In french: ModbusEnvoieTrameBrute
Sends a raw frame to a Modbus slave. This enables communication with devices that do not strictly comply with the Modbus standard.
New in version 2024
WEBDEV - Server codeWindows This function is now available for WEBDEV websites in Windows.
WEBDEV - Server codeLinux This function is now available for WEBDEV websites in Linux.
Example
// Connect to the Modbus slave
mb is modbusSession = ModbusConnectTCP("localhost",502)
IF ErrorOccurred THEN
Error(ErrorInfo(errFullDetails))
RETURN
END

// Slave ID: 0x01
mb.SlaveID = 0x01
// Raw query with the function code and the data
// Here, ask slave 0x01 the value of the 16-bit register at address 0x01
buff is Buffer = [0x03, 0x00, 0x01, 0x00, 0x01]

// Send frame and receive response
// The response contains: 
// - The transaction ID (2 bytes)
// - The protocol ID (2 bytes)
// - The message length in bytes (2 bytes)
// - The slave address (1 byte)
// - The function code (1 byte)
// - The data (n bytes)
buffReponse is Buffer = ModbusSendRawFrame(mb, buff)
IF ErrorOccurred THEN
Error(ErrorInfo(errFullDetails))
RETURN
END
Syntax
<Result> = ModbusSendRawFrame(<Session> , <Frame>)
<Result>: Buffer
Raw response from the slave.
<Session>: modbusSession variable
Name of the modbusSession variable that corresponds to the communication session with the Modbus slave.
<Frame>: Buffer
Frame to send to the slave. This frame must contain the function code and the data. The slave ID is specified via the SlaveID property of the modbusSession variable.
WINDEV automatically adds the other elements of the Modbus frame (for example, the CRC or the transaction ID).
Remarks
You can use the ErrorOccurred variable after the call to this function to determine if an error has occurred.
Component: wd290com.dll
Minimum version required
  • Version 28
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 12/13/2023

Send a report | Local help