react-native-modbus-tcp
This is a React Native module to help you process modbus data. This Library is only for android at the moment.
What does Modbus TCP/IP mean?
Modbus TCP/IP is a simple Modbus protocol running on Ethernet over a TCP interface. Modbus is an application protocol that assigns the ways of managing and passing data between various layers without being affected by the protocol used by the next immediate layer.
Modbus TCP/IP is also known as Modbus-TCP.
Getting started
$ npm install react-native-modbus-tcp --save
Mostly automatic installation
$ react-native link react-native-modbus-tcp
if your React Native
version is >=0.60.0 you don't have to use the command above.
Usage
Connect to Modbus TCP Master
; // Connect to Modbus TCP Master (parameters [ip, port]) ModbusTcp;
Read Single Coil
; // Read Coil (parameters [slaveid, start, length]) ModbusTcp;
Read Discrete Input
; // Read Discrete Input (parameters [slaveid, start, length]) ModbusTcp;
Read Holding Registers
; // Read Holding Registers (parameters [slaveid, start, length]) ModbusTcp;
Read input registers
; // Read Input Registers (parameters [slaveid, start, length]) ModbusTcp;
Write single coil
; // Write Coil (parameters [slaveid, offset, value]) ModbusTcp;
Write multiple coils
; // Write Coils (parameters [slaveid, start, values]) ModbusTcp;
Write single holding register
; // Write Register (parameters [slaveid, offset, value]) ModbusTcp;
Write multiple holding registers
; // Write Registers (parameters [slaveid, start, values]) ModbusTcp;
Destroy the connection between the slave and the master
; // Destroy Connection ModbusTcp;
Methods
- connectToModbusMaster
- readCoil
- readDiscreteInput
- readHoldingRegisters
- readInputRegisters
- writeCoil
- writeCoils
- writeRegister
- writeRegisters
- destroyConnection
Addresses are exactly as is in protocol, so if you see a paper talking about address 40001 this usually means first record address of that function so it means address 0.
Contributing
Pull requests welcome with bug fixes, documentation improvements, and enhancements.
When making big changes, please open an issue first to discuss.
License
This project is licensed under the MIT License.