maix::comm::modbus
maix.comm.modbus module
This is
maix::comm::modbus
module of MaixCDK.
All of these elements are in namespacemaix::comm::modbus
.For MaixCDK developer: DO NOT edit this doc file manually, this doc is auto generated!
1. Module#
No module
2. Enum#
2.1. Mode#
modbus mode
item | describe |
---|---|
values | RTU: TCP: |
C++ defination code:
2.2. RequestType#
Modbus request types enumeration.\nThis enumeration defines the various Modbus request types,\nincluding functions for reading and writing coils, registers,\nas well as diagnostics and identification.
item | describe |
---|---|
values | READ_COILS: < Read Coils READ_DISCRETE_INPUTS: < Read Discrete Inputs READ_HOLDING_REGISTERS: < Read Holding Registers READ_INPUT_REGISTERS: < Read Input Registers WRITE_SINGLE_COIL: < Write Single Coil WRITE_SINGLE_REGISTER: < Write Single Register DIAGNOSTICS: < Diagnostics (Serial Line only) GET_COMM_EVENT_COUNTER: < Get Comm Event Counter (Serial Line only) WRITE_MULTIPLE_COILS: < Write Multiple Coils WRITE_MULTIPLE_REGISTERS: < Write Multiple Registers REPORT_SERVER_ID: < Report Slave ID (Serial Line only) MASK_WRITE_REGISTER: < Mask Write Register READ_WRITE_MULTIPLE_REGISTERS: < Read/Write Multiple Registers READ_DEVICE_IDENTIFICATION: < Read Device Identification UNKNOWN: < Unknown Request Type |
C++ defination code:
3. Variable#
4. Function#
4.1. set_master_debug#
Set the master debug ON/OFF
item | description |
---|---|
param | debug: True(ON) or False(OFF) |
C++ defination code:
5. Class#
5.1. RegisterInfo#
Structure to hold information about a Modbus register.\nThis structure contains the starting address and size of a Modbus register,\nallowing for easy management of register information.
C++ defination code:
5.2. Registers#
Structure to hold information about multiple Modbus registers.\nThis structure aggregates information for various types of Modbus registers,\nincluding coils, discrete inputs, holding registers, and input registers.
C++ defination code:
5.3. Slave#
Class for modbus Slave
C++ defination code:
5.3.1. __init__#
Modbus Slave constructor.\nThis constructor initializes a Modbus Slave instance. Depending on the mode (RTU or TCP),\nit sets up the necessary parameters for communication and defines the register structure.
item | description |
---|---|
type | func |
param | mode: Specifies the communication mode: RTU or TCP. ip_or_device: The UART device name if using RTU mode. If TCP mode is selected, this parameter is ignored. coils_start: The starting address of the coils register. coils_size: The number of coils to manage. discrete_start: The starting address of the discrete inputs register. discrete_size: The number of discrete inputs to manage. holding_start: The starting address of the holding registers. holding_size: The number of holding registers to manage. input_start: The starting address of the input registers. input_size: The number of input registers to manage. rtu_baud: The baud rate for RTU communication. Supported rates include: 110, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2500000, 3000000, 3500000, 4000000. Default is 115200. Ensure that the selected baud rate is supported by the underlying hardware and libmodbus. rtu_slave: The RTU slave address. Ignored in TCP mode. Default is 1. tcp_port: The port used for TCP communication. Ignored in RTU mode. Default is 502. debug: A boolean flag to enable or disable debug mode. Default is false. |
see | modbus.Mode for valid modes. |
static | False |
C++ defination code:
5.3.2. receive#
Receives a Modbus request\nThis function is used to receive a Modbus request from the client. The behavior of the function\ndepends on the parameter timeout_ms
provided, which dictates how long the function will wait\nfor a request before returning.
item | description |
---|---|
type | func |
note | This function gets and parses the request, it does not manipulate the registers. |
param | timeout_ms: Timeout setting -1 Block indefinitely until a request is received 0 Non-blocking mode; function returns immediately, regardless of whether a request is received >0 Blocking mode; function will wait for the specified number of milliseconds for a request |
return | maix::err::Err type, @see maix::err::Err |
static | False |
C++ defination code:
5.3.3. request_type#
Gets the type of the Modbus request that was successfully received\nThis function can be used to retrieve the type of the request received after a successful\ncall to receive()
. The return value indicates the type of the Modbus request, allowing\nthe user to understand and process the received request appropriately.
item | description |
---|---|
type | func |
return | RequestType The type of the Modbus request that has been received. |
see | modbus.RequestType |
static | False |
C++ defination code:
5.3.4. reply#
Processes the request and returns the corresponding data.\nThis function handles the requests received from the client. It retrieves any data that the client\nneeds to write to the registers and updates the registers accordingly. Additionally, it retrieves\nthe requested data from the registers and sends it back to the client in the response.\nThis function is essential for managing read and write operations in a Modbus Slave context.
item | description |
---|---|
type | func |
note | The function will modify the Slave's internal state based on the data received in the request, and ensure that the appropriate data is returned to the client. |
return | maix::err::Err type, @see maix::err::Err |
static | False |
C++ defination code:
5.3.5. receive_and_reply#
Receives a request from the client and sends a response.\nThis function combines the operations of receiving a request and sending a corresponding\nresponse in a single call. It waits for a specified duration (defined by the timeout_ms
\nparameter) to receive a request from the client. Upon successful receipt of the request,\nit processes the request and prepares the necessary data to be sent back to the client.
item | description |
---|---|
type | func |
param | timeout_ms: The timeout duration for waiting to receive a request. - A value of -1 makes the function block indefinitely until a request is received. - A value of 0 makes it non-blocking, returning immediately without waiting for a request. - A positive value specifies the maximum time (in milliseconds) to wait for a request before timing out. |
return | RequestType The type of the Modbus request that has been received. |
see | modbus.RequestType |
static | False |
C++ defination code:
5.3.6. coils#
Reads from or writes to coils.\nThis function can be used to either read data from coils or write data to them.\nIf the data
parameter is empty, the function performs a read operation.\nIf data
is not empty, the function writes the contents of data
to the coils\nstarting at the specified index.
item | description |
---|---|
type | func |
param | data: A vector of data to be written. If empty, a read operation is performed. If not empty, the data will overwrite the coils from index .index: The starting index for writing data. This parameter is ignored during read operations. |
return | std::vector<uint16_t> When the read operation is successful, return all data in the coils as a list. When the write operation is successful, return a non-empty list; when it fails, return an empty list. |
static | False |
C++ defination code:
5.3.7. discrete_input#
Reads from or writes to discrete input.\nThis function can be used to either read data from discrete input or write data to them.\nIf the data
parameter is empty, the function performs a read operation.\nIf data
is not empty, the function writes the contents of data
to the discrete input\nstarting at the specified index.
item | description |
---|---|
type | func |
param | data: A vector of data to be written. If empty, a read operation is performed. If not empty, the data will overwrite the discrete input from index .index: The starting index for writing data. This parameter is ignored during read operations. |
return | std::vector<uint16_t> When the read operation is successful, return all data in the discrete input as a list. When the write operation is successful, return a non-empty list; when it fails, return an empty list. |
static | False |
C++ defination code:
5.3.8. input_registers#
Reads from or writes to input registers.\nThis function can be used to either read data from input registers or write data to them.\nIf the data
parameter is empty, the function performs a read operation.\nIf data
is not empty, the function writes the contents of data
to the input registers\nstarting at the specified index.
item | description |
---|---|
type | func |
param | data: A vector of data to be written. If empty, a read operation is performed. If not empty, the data will overwrite the input registers from index .index: The starting index for writing data. This parameter is ignored during read operations. |
return | std::vector<uint16_t> When the read operation is successful, return all data in the input registers as a list. When the write operation is successful, return a non-empty list; when it fails, return an empty list. |
static | False |
C++ defination code:
5.3.9. holding_registers#
Reads from or writes to holding registers.\nThis function can be used to either read data from holding registers or write data to them.\nIf the data
parameter is empty, the function performs a read operation.\nIf data
is not empty, the function writes the contents of data
to the holding registers\nstarting at the specified index.
item | description |
---|---|
type | func |
param | data: A vector of data to be written. If empty, a read operation is performed. If not empty, the data will overwrite the holding registers from index .index: The starting index for writing data. This parameter is ignored during read operations. |
return | std::vector<uint16_t> When the read operation is successful, return all data in the holding registers as a list. When the write operation is successful, return a non-empty list; when it fails, return an empty list. |
static | False |
C++ defination code:
5.4. MasterRTU#
Class for modbus MasterRTU
C++ defination code:
5.4.1. __init__#
Construct a new MasterRTU object
item | description |
---|---|
type | func |
param | device: Default uart device. baudrate: Default uart baudrate. |
static | False |
C++ defination code:
5.4.2. read_coils#
Reads coils from the Modbus device.\nThis function reads a specified number of coils starting from a given address.\nIt includes timeout settings to define how long to wait for a response.
item | description |
---|---|
type | func |
param | slave_id: The RTU slave address. addr: The starting address for reading coils. size: The number of coils to read. timeout_ms: The timeout duration for waiting to receive a request. - A value of -1 makes the function block indefinitely until a request is received. - A value of 0 makes it non-blocking, returning immediately without waiting for a request. - A positive value specifies the maximum time (in milliseconds) to wait for a request before timing out. device: The UART device to use. An empty string ("") indicates that the default device from the constructor will be used. baudrate: The UART baud rate. A value of -1 signifies that the default baud rate from the constructor will be applied. |
return | std::vector<uint8_t>/list[int] A vector containing the read coil values. |
static | False |
C++ defination code:
5.4.3. read_coils (overload 1)#
Reads coils from the Modbus device.\nThis function reads a specified number of coils starting from a given address.\nIt includes timeout settings to define how long to wait for a response.
item | description |
---|---|
type | func |
param | device: The UART device to use. baudrate: he UART baud rate. slave_id: The RTU slave address. addr: The starting address for reading coils. size: The number of coils to read. timeout_ms: The timeout duration for waiting to receive a request. - A value of -1 makes the function block indefinitely until a request is received. - A value of 0 makes it non-blocking, returning immediately without waiting for a request. - A positive value specifies the maximum time (in milliseconds) to wait for a request before timing out. |
return | std::vector<uint8_t>/list[int] A vector containing the read coil values. |
static | True |
C++ defination code:
5.4.4. write_coils#
Writes values to coils on the Modbus device.\nThis function writes the specified data to the coils starting from a given address.
item | description |
---|---|
type | func |
param | slave_id: The RTU slave address. data: A vector containing the coil values to write. addr: The starting address for writing coils. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. device: The UART device to use. An empty string ("") indicates that the default device from the constructor will be used. baudrate: The UART baud rate. A value of -1 signifies that the default baud rate from the constructor will be applied. |
return | int Returns the number of bytes written on success, or a value less than 0 on failure. |
static | False |
C++ defination code:
5.4.5. write_coils (overload 1)#
Writes values to coils on the Modbus device.\nThis function writes the specified data to the coils starting from a given address.
item | description |
---|---|
type | func |
param | device: The UART device to use. baudrate: The UART baud rate. slave_id: The RTU slave address. data: A vector containing the coil values to write. addr: The starting address for writing coils. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. |
return | int Returns the number of bytes written on success, or a value less than 0 on failure. |
static | True |
C++ defination code:
5.4.6. read_discrete_input#
Reads discrete inputs from the Modbus device.\nThis function reads a specified number of discrete inputs starting from a given address.
item | description |
---|---|
type | func |
param | slave_id: The RTU slave address. addr: The starting address for reading discrete inputs. size: The number of discrete inputs to read. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. device: The UART device to use. An empty string ("") indicates that the default device from the constructor will be used. baudrate: The UART baud rate. A value of -1 signifies that the default baud rate from the constructor will be applied. |
return | std::vector<uint8_t>/list[int] A vector containing the read discrete input values. |
static | False |
C++ defination code:
5.4.7. read_discrete_input (overload 1)#
Reads discrete inputs from the Modbus device.\nThis function reads a specified number of discrete inputs starting from a given address.
item | description |
---|---|
type | func |
param | device: The UART device to use. baudrate: The UART baud rate. slave_id: The RTU slave address. addr: The starting address for reading discrete inputs. size: The number of discrete inputs to read. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. |
return | std::vector<uint8_t>/list[int] A vector containing the read discrete input values. |
static | True |
C++ defination code:
5.4.8. read_input_registers#
Reads input registers from the Modbus device.\nThis function reads a specified number of input registers starting from a given address.
item | description |
---|---|
type | func |
param | slave_id: The RTU slave address. addr: The starting address for reading input registers. size: The number of input registers to read. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. device: The UART device to use. An empty string ("") indicates that the default device from the constructor will be used. baudrate: The UART baud rate. A value of -1 signifies that the default baud rate from the constructor will be applied. |
return | std::vector<uint16_t>/list[int] A vector containing the read input register values. |
static | False |
C++ defination code:
5.4.9. read_input_registers (overload 1)#
Reads input registers from the Modbus device.\nThis function reads a specified number of input registers starting from a given address.
item | description |
---|---|
type | func |
param | device: The UART device to use. baudrate: The UART baud rate. slave_id: The RTU slave address. addr: The starting address for reading input registers. size: The number of input registers to read. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. |
return | std::vector<uint16_t>/list[int] A vector containing the read input register values. |
static | True |
C++ defination code:
5.4.10. read_holding_registers#
Reads holding registers from the Modbus device.\nThis function reads a specified number of holding registers starting from a given address.
item | description |
---|---|
type | func |
param | slave_id: The RTU slave address. addr: The starting address for reading holding registers. size: The number of holding registers to read. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. device: The UART device to use. An empty string ("") indicates that the default device from the constructor will be used. baudrate: The UART baud rate. A value of -1 signifies that the default baud rate from the constructor will be applied. |
return | std::vector<uint16_t>/list[int] A vector containing the read holding register values. |
static | False |
C++ defination code:
5.4.11. read_holding_registers (overload 1)#
Reads holding registers from the Modbus device.\nThis function reads a specified number of holding registers starting from a given address.
item | description |
---|---|
type | func |
param | device: The UART device to use. baudrate: The UART baud rate. slave_id: The RTU slave address. addr: The starting address for reading holding registers. size: The number of holding registers to read. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. |
return | std::vector<uint16_t>/list[int] A vector containing the read holding register values. |
static | True |
C++ defination code:
5.4.12. write_holding_registers#
Writes values to holding registers on the Modbus device.\nThis function writes the specified data to the holding registers starting from a given address.
item | description |
---|---|
type | func |
param | slave_id: The RTU slave address. data: A vector containing the values to write to holding registers. addr: The starting address for writing holding registers. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. device: The UART device to use. An empty string ("") indicates that the default device from the constructor will be used. baudrate: The UART baud rate. A value of -1 signifies that the default baud rate from the constructor will be applied. |
return | int Returns the number of bytes written on success, or a value less than 0 on failure. |
static | False |
C++ defination code:
5.4.13. write_holding_registers (overload 1)#
Writes values to holding registers on the Modbus device.\nThis function writes the specified data to the holding registers starting from a given address.
item | description |
---|---|
type | func |
param | device: The UART device to use. baudrate: The UART baud rate. slave_id: The RTU slave address. data: A vector containing the values to write to holding registers. addr: The starting address for writing holding registers. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. |
return | int Returns the number of bytes written on success, or a value less than 0 on failure. |
static | True |
C++ defination code:
5.5. MasterTCP#
Class for modbus Master
C++ defination code:
5.5.1. __init__#
Construct a new MasterTCP object
item | description |
---|---|
type | func |
param | port: Device tcp port. |
static | False |
C++ defination code:
5.5.2. read_coils#
Reads coils from the Modbus device.\nThis function reads a specified number of coils starting from a given address.\nIt includes timeout settings to define how long to wait for a response.
item | description |
---|---|
type | func |
param | ip: The TCP IP address. addr: The starting address for reading coils. size: The number of coils to read. timeout_ms: The timeout duration for waiting to receive a request. - A value of -1 makes the function block indefinitely until a request is received. - A value of 0 makes it non-blocking, returning immediately without waiting for a request. - A positive value specifies the maximum time (in milliseconds) to wait for a request before timing out. port: The TCP port. A value of -1 signifies that the default port from the constructor will be applied. |
return | std::vector<uint8_t>/list[int] A vector containing the read coil values. |
static | False |
C++ defination code:
5.5.3. read_coils (overload 1)#
Reads coils from the Modbus device.\nThis function reads a specified number of coils starting from a given address.\nIt includes timeout settings to define how long to wait for a response.
item | description |
---|---|
type | func |
param | ip: The TCP IP address. port: The TCP port. addr: The starting address for reading coils. size: The number of coils to read. timeout_ms: The timeout duration for waiting to receive a request. - A value of -1 makes the function block indefinitely until a request is received. - A value of 0 makes it non-blocking, returning immediately without waiting for a request. - A positive value specifies the maximum time (in milliseconds) to wait for a request before timing out. |
return | std::vector<uint8_t>/list[int] A vector containing the read coil values. |
static | True |
C++ defination code:
5.5.4. write_coils#
Writes values to coils on the Modbus device.\nThis function writes the specified data to the coils starting from a given address.
item | description |
---|---|
type | func |
param | ip: The TCP IP address. data: A vector containing the coil values to write. addr: The starting address for writing coils. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. port: The TCP port. A value of -1 signifies that the default port from the constructor will be applied. |
return | int Returns the number of bytes written on success, or a value less than 0 on failure. |
static | False |
C++ defination code:
5.5.5. write_coils (overload 1)#
Writes values to coils on the Modbus device.\nThis function writes the specified data to the coils starting from a given address.
item | description |
---|---|
type | func |
param | ip: The TCP IP address. port: The TCP port. data: A vector containing the coil values to write. addr: The starting address for writing coils. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. |
return | int Returns the number of bytes written on success, or a value less than 0 on failure. |
static | True |
C++ defination code:
5.5.6. read_discrete_input#
Reads discrete inputs from the Modbus device.\nThis function reads a specified number of discrete inputs starting from a given address.
item | description |
---|---|
type | func |
param | ip: The TCP IP address. addr: The starting address for reading discrete inputs. size: The number of discrete inputs to read. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. port: The TCP port. A value of -1 signifies that the default port from the constructor will be applied. |
return | std::vector<uint8_t>/list[int] A vector containing the read discrete input values. |
static | False |
C++ defination code:
5.5.7. read_discrete_input (overload 1)#
Reads discrete inputs from the Modbus device.\nThis function reads a specified number of discrete inputs starting from a given address.
item | description |
---|---|
type | func |
param | ip: The TCP IP address. port: The TCP port. addr: The starting address for reading discrete inputs. size: The number of discrete inputs to read. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. |
return | std::vector<uint8_t>/list[int] A vector containing the read discrete input values. |
static | True |
C++ defination code:
5.5.8. read_input_registers#
Reads input registers from the Modbus device.\nThis function reads a specified number of input registers starting from a given address.
item | description |
---|---|
type | func |
param | ip: The TCP IP address. addr: The starting address for reading input registers. size: The number of input registers to read. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. port: The TCP port. A value of -1 signifies that the default port from the constructor will be applied. |
return | std::vector<uint16_t>/list[int] A vector containing the read input register values. |
static | False |
C++ defination code:
5.5.9. read_input_registers (overload 1)#
Reads input registers from the Modbus device.\nThis function reads a specified number of input registers starting from a given address.
item | description |
---|---|
type | func |
param | ip: The TCP IP address. port: The TCP port. addr: The starting address for reading input registers. size: The number of input registers to read. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. |
return | std::vector<uint16_t>/list[int] A vector containing the read input register values. |
static | True |
C++ defination code:
5.5.10. read_holding_registers#
Reads holding registers from the Modbus device.\nThis function reads a specified number of holding registers starting from a given address.
item | description |
---|---|
type | func |
param | ip: The TCP IP address. addr: The starting address for reading holding registers. size: The number of holding registers to read. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. port: The TCP port. A value of -1 signifies that the default port from the constructor will be applied. |
return | std::vector<uint16_t>/list[int] A vector containing the read holding register values. |
static | False |
C++ defination code:
5.5.11. read_holding_registers (overload 1)#
Reads holding registers from the Modbus device.\nThis function reads a specified number of holding registers starting from a given address.
item | description |
---|---|
type | func |
param | ip: The TCP IP address. port: The TCP port. addr: The starting address for reading holding registers. size: The number of holding registers to read. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. |
return | std::vector<uint16_t>/list[int] A vector containing the read holding register values. |
static | True |
C++ defination code:
5.5.12. write_holding_registers#
Writes values to holding registers on the Modbus device.\nThis function writes the specified data to the holding registers starting from a given address.
item | description |
---|---|
type | func |
param | ip: The TCP IP address. data: A vector containing the values to write to holding registers. addr: The starting address for writing holding registers. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. port: The TCP port. A value of -1 signifies that the default port from the constructor will be applied. |
return | int Returns the number of bytes written on success, or a value less than 0 on failure. |
static | False |
C++ defination code:
5.5.13. write_holding_registers (overload 1)#
Writes values to holding registers on the Modbus device.\nThis function writes the specified data to the holding registers starting from a given address.
item | description |
---|---|
type | func |
param | ip: The TCP IP address. port: The TCP port. data: A vector containing the values to write to holding registers. addr: The starting address for writing holding registers. timeout_ms: The timeout duration for the write operation. - A value of -1 makes the function block until the write is complete. - A value of 0 makes it non-blocking. - A positive value specifies the maximum time (in milliseconds) to wait. |
return | int Returns the number of bytes written on success, or a value less than 0 on failure. |
static | True |
C++ defination code: