Menu

Home

Rossmann Engineering

Welcome to the EasyModbusTCP Library!

This is a Modbus-TCP (UDP) library (.dll) for .NET and (.JAR) for JAVA implementations.
Supports Read and Write operations.
Float values can be written or read.
Values can be published to a Mqtt-Broker

A simple example of a Modbus-TCP client is available in download area. (Written in Visual Studio 2012)

The following function Codes are supported:

  • Read Coils (FC1)
  • Read Discrete Inputs (FC2)
  • Read Holding Registers (FC3)
  • Read Input Registers (FC4)
  • Write Single Coil (FC5)
  • Write Single Register (FC6)
  • Write Multiple Coils (FC15)
  • Write Multiple Registers (FC16)
  • Read/Write Multipe Registers (FC23)

Name of Server-Class: ModbusServer
Name of Client-Class: ModbusClient
Name of Namespace: EasyModbus

Methods Client: [Methods ModbusClient]
Properties Client: [Properties ModbusClient]

Methods Server: [Methods ModbusServer]
Properties Server: [Properties ModbusServer]
Events Server: [Events ModbusServer]

Project Admins:


Related

Wiki: Events ModbusServer
Wiki: Methods ModbusClient
Wiki: Methods ModbusServer
Wiki: Properties ModbusClient
Wiki: Properties ModbusServer

Discussion

  • Rodrigo Bernardes

    Hi, I could use easymodbus function to read values from modsim in my computer over tcp. But now I need to comunicate with a device, over tcp also, and it requires a device adress, beyond the Ip adress I need to pass this device adress, but the methods in easymodbus only require Ip adress, port number, start adress and length.
    I saw that this is a feature in the modbus protocol that some devices implement, like to divide their memory area.
    Can someonme help me?

     
  • Shwetha

    Shwetha - 2018-04-11

    Hello:
    Can I please get the source code for the DLL?

     
  • Rodrigo Bernardes

    Hi Shwetha!

    Thank you for your atention.
    This is a peace of code that I made for testing purposes and worked fine simulating with modsim32

    class Program
    {
    static void Main(string[] args)
    {
    ModbusClient modbusClient = new ModbusClient("192.168.0.33", 502);
    modbusClient.Connect();
    int[] readHoldingRegisters = modbusClient.ReadHoldingRegisters(200, 1);

            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);
        }
    }
    

    But if I change the modsim32 field "Device Id" to any number diferent of 1, see the image attached, the program fails.
    The problem is not commom because almost all devices using modbus tcp protocol uses a standard "device Id = 1", but there´s someones that don´t.

    After many days searching I could find another DLL called ModbusTCP that have this parameter in it´s methods. But I´d like to try it with easymodbus because it´s really easiest rsrsrs

    Thanks again.

     
  • Shwetha

    Shwetha - 2018-04-12

    Yes, that is correct. I had the same issue. I think default device ID is set to 1 in the library. Need to change the library source code to take the device as input.

     
  • Shwetha

    Shwetha - 2018-04-12

    I found the source code of DLL in the "External Link".

     
  • Rossmann Engineering

    Hi, the device ID can be changed using the property "UnitIdentifier"

     
  • Rodrigo Bernardes

    Hi Rossmann, I don´t remember to see "UnitIdentifier" parameter in the tcp methods. Only for rtu. But I´ll double check.
    Now I´m having another problem, I need a library that works in .net core (UWP application for raspberry Pi 3) Do you know if easymodbus works in .net core? When I create an UWP application and try to reference the DLL it gives me an error.

     
  • Nick S

    Nick S - 2018-05-12

    Hello. I would like to ask, how do we know that the Write operations succeed? They are SUBS and do not return a status code (for example, 0 for success or >0 for the error code).

    Thanks!

     
  • murat gündüz

    murat gündüz - 2019-05-14

    hey,
    i tried this easymodbus dll with modbusTCP. i connected to server is ok but i cant read or wirte anything from the rtu plc. i despite using "UnitIdentifier=3", but it wont read. how to set unit id with this ? i can use modbusPool as same way succesfully. i cant read the plc by changing 3 to other also. so something wrong here. what s your idea. illuminating: im using "modbus tcp to rtu converter" with ststic ip by gprs. but it works fine with modbuspool.

     
    • Rodrigo Bernardes

      Hi

      I´m not using easymodbus neither c# anymore. Now I´m involved with python
      and pymodbus.
      Sorry, but I´m can´t help you with it.

      Rodrigo Bernardes
      Eng. Automação / Instrumentação
      (31)98722-7041
      (11)98611-7220

      Em ter, 14 de mai de 2019 às 10:25, "murat gündüz" muratguenduez@users.sourceforge.net escreveu:

      hey,
      i tried this easymodbus dll with modbusTCP. i connected to server is ok
      but i cant read or wirte anything from the rtu plc. i despite using
      "UnitIdentifier=3", but it wont read. how to set unit id with this ? i can
      use modbusPool as same way succesfully. i cant read the plc by changing 3
      to other also. so something wrong here. what s your idea. illuminating: im
      using "modbus tcp to rtu converter" with ststic ip by gprs. but it works
      fine with modbuspool.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/easymodbustcp/wiki/Home/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • Nikoloz Qvrivishvili

    Cheers to everybody,
    In order to make some kind of homebrewed software to communicate via Modbus TCP Iskra MC devices, using Visual C.net or VB.net, I was suggested to download "Easy Modbus TCP.NET Package v 5.5".
    It includes archives: 1. Easy Modbus Server Simulator(.NET version) 2. Easy Modbus Client (.NET version) 3. Easy Modbus Library for .NET(DLL).

    Can anyone kindly tell me, which of them do I need to install?

    Best wishes.

     
    • olddebris

      olddebris - 2021-11-16

      You need to install the number 3. The library.

       
  • olddebris

    olddebris - 2021-11-16

    I have tried using the EasyModbus library to build a TCP Modbus client. I added the .dll in the dependencies of my project and I can use the library and compile my solution but when I try to run my manual test I get an error telling me that the loader can't find a library : System.IO.Ports version 4.0.3.3. Here is the detailed error message:

    System.IO.FileNotFoundException
    HResult=0x80070002
    Message=Could not load file or assembly 'System.IO.Ports, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
    Source=PHCertLabel
    StackTrace:
    at PHCertLabel.ModbusAccessor.TryOpen(String ip, Int32 port) in D:\data\PHtestJig\PHCertLabel\PHCertLabel\ModbusAccessor.vb:line 45
    at PHManualModbusTest.Program.Main(String[] args) in D:\data\PHtestJig\PHCertLabel\PHManualModbusTest\Program.vb:line 10

    I have installed the package by running Nuget install System.IO.Ports but I think it is not the correct version and if I try to install the specific version (4.0.3.0) the package manager does not find it.
    I am an experienced C/C++ developper but I do not have much experience with .NET
    I suspect that this is an easy one but I can't figure out how to fix this dependency issue.
    Can anyone help with this ?

     
    • Michele Amati

      Michele Amati - 2024-08-01

      You need to install the System.IO.Ports Nudget in the project. In this way I solved the problem.

       
  • Jeff Hunter

    Jeff Hunter - 2024-09-24

    Quick question. Is there a way to read a specific address? I am seeing an address of 10001, 10002, 10003, etc. Can I check one of those specific addresses for a value by address? Sorry, I am new to programming and PLCs.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.