Normally a modbus device is connected using serial line like RS232 or RS485 but ethernet is used also.
List of devices that support modbus protocol is very very long and you can find:
- remote I/O interface
- power meter
- inverter
- ....
Here you can find the result and below I present a first usage example where the fist 16 register are read from R/W modbus resgister:
using System; using libmodbussharp; namespace modbussharptutorial { class MainClass { public static void Main (string[] args) { string modbusAddress = "127.0.0.1"; int port = 1502; int sizeMapping = 512; bool debug = true; // Modbus Initialization ModbusCore modbus = new ModbusCore(modbusAddress, port); modbus.Debug=debug; modbus.SetSlave (1); modbus.Connect(); if (modbus.MappingNew(sizeMapping,sizeMapping,sizeMapping,sizeMapping)) { Console.WriteLine("Failed to allocate the mapping."); return; } // Ask for first 16 read/write registers modbus.RegistersRWRead (0, 16); // Print result to console for (int i=0; i < 16; ++i) { Console.WriteLine ("{0:X2} - {1:D}", i, modbus.RegisterRWUnsigned [i]); } } } }