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
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
ModbusConnectRTU (Function)
In french: ModbusConnecteRTU
Connects a client to a Modbus slave via a serial port.
Example
// Crée une session et connexion à l'esclave Modbus sur le port série COM4
Session is modbusSession
Session = ModbusConnectRTU("COM4",1)

// Si la connexion échoue, affiche l'erreur.
IF ErrorOccurred = True THEN
	Trace(ErrorInfo())
ELSE
	// Ecrit une valeur dans le registre 0x42 de l'esclave.
	ModbusWriteRegister(Session, 0x42,0xCAFE)
END

// Libère le port série
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:
0No parity
1Even parity
2Odd 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
11.5 stop bits
22 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
Component: wd300com.dll
Versión mínima requerida
  • Versión 26
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

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