NUnitID: Identification number of a serial sub-network device. NTCPPort: Port number of the target device. If (!master.SIPAddr: Is a string containing the IP address of the target device. available responses, call master.available() function often. blocking, so you can continue the program while the Modbus functions work. IMPORTANT: all read and write functions start a Modbus transmission, but they are not It requests for 6 registers starting at address 0 ![]() Send a Read Input Registers request to the slave with address 31 Send a request every 1000ms if connected to slave In this case the connection is opened once The ethernet connection is managed by the application, not by the library NOTE: it is not necessary to start the modbus master object Ethernet client object used to connect to the slave You should have received a copy of the GNU Lesser General Public License GNU Lesser General Public License for more details. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program is distributed in the hope that it will be useful,īut WITHOUT ANY WARRANTY without even the implied warranty of The Free Software Foundation, either version 3 of the License, or It under the terms of the GNU Lesser General Public License as published by This program is free software: you can redistribute it and/or modify PLC Modbus TCP Master Input registers reader codeĬopyright (c) 2018 Boot&Work Corp., S.L.The ModbusResponse implements some functions to get the response information: There is a available() function to check for responses from the slave. If there is a pending Modbus request or the client is not connected, they return false. They return true or false depending on the current module state. It is important to notice that these functions are non-blocking, so they do not return the read value. On a multiple write function, the values argument is an array of values to write. On a multiple read/write function, the address argument is the first element addressed. A coil is represented by a bool value and a holding register is represented by a uint16_t value. Depending on the function, the data type changes. value is the given value of the coil or holding registers on a write operation.quantity is the number of coils, digital inputs, holding registers or input registers to read/write.Usually, this address is the coil, digital input, holding register or input register number minus 1: the holding register number 40009 has the address 8. address is the coil, digital input, holding register or input register address. ![]() ![]()
0 Comments
Leave a Reply. |