AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Comunicación / Funciones Modbus
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Reads one or more registers from a Modbus slave, starting at a specific address.
Ejemplo
// Create a session and connect to a Modbus server
Session is modbusSession
Session = ModbusConnectTCP("192.168.1.7")

arrResponse is array of 5 2-byte int

// If the connection fails, display the error
IF ErrorOccurred = True THEN
	Trace(ErrorInfo())
ELSE
	// Reads a sequence of 5 registers in read-write mode starting at address 0x42.
	arrResponse = ModbusReadRegister(Session, 0x42, 5, False)
	// Display the error, if any.
	IF ErrorOccurred = True THEN
		Trace(ErrorInfo())
	END
END

// Disconnection
ModbusDisconnect(Session)
Sintaxis

Reading 1 register from a Modbus slave Ocultar los detalles

<Result> = ModbusReadRegister(<Session> , <Address> , <Read-only>)
<Result>: Integer
Value of the register read (16-bit integer).
<Session>: modbusSession variable
Name of the modbusSession variable that corresponds to the communication session with the Modbus slave.
<Address>: Integer
Address of the register in the slave (between 0 and 65,535).
<Read-only>: Boolean
  • True if the registers to be read are part of read-only data (Modbus function code 4 (Read Input Registers)).
  • False if the registers to be read are part of read-write data (Modbus function code 3 (Read Multiple Holding Registers)).

Reading multiple registers from a Modbus slave Ocultar los detalles

<Result> = ModbusReadRegister(<Session> , <Address> , <Number of registers> , <Read-only>)
<Result>: Array
Array of 16-bit integers that contains the values of the registers read.
<Session>: modbusSession variable
Name of the modbusSession variable that corresponds to the communication session with the Modbus slave.
<Address>: Integer
Starting address of the registers in the slave (between 0 and 65,535).
<Number of registers>: Integer
Number of registers to be read.
<Read-only>: Boolean
  • True if the registers to be read are part of read-only data (Modbus function code 4 (Read Input Registers)).
  • False if the registers to be read are part of read-write data (Modbus function code 3 (Read Multiple Holding Registers)).
Observaciones
  • This function blocks the application until the slave responds to the message or until the session timeout is exceeded.
  • After calling ModbusReadRegister, it is recommended to check the ErrorOccurred variable to make sure there are no errors.
Clasificación Lógica de negocio / UI: Código neutro
Componente: wd300com.dll
Versión mínima requerida
  • Versión 26
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 28/03/2025

Señalar un error o enviar una sugerencia | Ayuda local