I try to use the code example with Sharpdevelop. But i don't find how to install the easymodbus.dll on my system to be recognize, i have try to install it on windows/system32 with "regsvr32 easymodbus.dll" but don't work.
The example code :
/
* Modbus Client Example /
using System;
using EasyModbus;
namespace ModbusClientApplication
{
class Program
{
public static void Main(string[] args)
{
ModbusClient modbusClient = new ModbusClient("190.201.100.100", 502);
//Connect to Server
modbusClient.Connect();
//Write Coils starting with Addres 5
modbusClient.WriteMultipleCoils(4, new bool[] {true, true, true, true, true, true, true, true, true, true});
//Read 10 Coils from Server, starting with address 10
bool[] readCoils = modbusClient.ReadCoils(9,10);
//Read 10 Holding Registers from Server, starting with Address 1
int[] readHoldingRegisters = modbusClient.ReadHoldingRegisters(0,10);
// Console Output
for (int i = 0; i < readCoils.Length; i++)
Console.WriteLine("Value of Coil " + (9 + i + 1) + " " + readCoils[i].ToString());
for (int i = 0; i < readHoldingRegisters.Length; i++)
Console.WriteLine("Value of HoldingRegister " + (i + 1) + " "+ readHoldingRegisters[i].ToString());
//Disconnect from Server
modbusClient.Disconnect();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I try to use the code example with Sharpdevelop. But i don't find how to install the easymodbus.dll on my system to be recognize, i have try to install it on windows/system32 with "regsvr32 easymodbus.dll" but don't work.
The example code :
/
* Modbus Client Example
/
using System;
using EasyModbus;
namespace ModbusClientApplication
{
class Program
{
public static void Main(string[] args)
{
ModbusClient modbusClient = new ModbusClient("190.201.100.100", 502);
//Connect to Server
modbusClient.Connect();
//Write Coils starting with Addres 5
modbusClient.WriteMultipleCoils(4, new bool[] {true, true, true, true, true, true, true, true, true, true});
//Read 10 Coils from Server, starting with address 10
bool[] readCoils = modbusClient.ReadCoils(9,10);
//Read 10 Holding Registers from Server, starting with Address 1
int[] readHoldingRegisters = modbusClient.ReadHoldingRegisters(0,10);
}
You just have to add the easymodbus.dll as new reference. But if you use the example, and keep the folders, there is no need to install the dll.