class Program {
public static void Main() {
const byte SlaveID = 32;
using (IModbus modbus = ModbusFactory.Create("localhost", 502)) {
// read coil status
byte[] coils = modbus.ReadCoils(SlaveID, address: 0, quantity: 10);
modbus.WriteCoils(SlaveID, address: 0, quantity: 10, new byte[] { 0x02, 0x77 });
// read/write holding registers
byte[] holdingValues = modbus.ReadHoldingRegisters(SlaveID, address: 0, quantity: 10);
modbus.WriteHoldingRegisters(SlaveID, address: 0, new byte[] { 0x08, 0x09, 0x0A, 0x0B });
// read discrete inputs
byte[] data = modbus.ReadDiscreteInputs(SlaveID, address: 0, quantity: 10);
// read input registers
byte[] inputValues = modbus.ReadInputRegisters(SlaveID, address: 0, quantity: 10);
}
}
}
-
Notifications
You must be signed in to change notification settings - Fork 0
A simple modbus library
License
xiaokangz88/ModbusTookit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A simple modbus library
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published