GithubHelp home page GithubHelp logo

parallelbgls / modbus.net Goto Github PK

View Code? Open in Web Editor NEW
371.0 29.0 136.0 43.47 MB

A high extensible hardware communication platform using C#

License: MIT License

C# 100.00%
extensible modbus c-sharp tcp com siemens communication opc platform protocol

modbus.net's Introduction

Modbus.Net Overview

Overview

Modbus.Net is an open hardware communication platform.

You can focus on the protocol itself and the platform can automatically create a full asynchronous or synchronous communication library.

Important

You need to copy appsettings.default.json file in Modbus.Net to your own project, and don't forget to change settings of file to copy content and copy when newer, otherwise Modbus.Net will not work.

Why is it called Modbus.Net

Modbus.Net was open sourced in 2019 when I graduated. The first target of this project was to implement remote PLC communication using Modbus TCP. Half a year later the company decide to use a IoT hardware, then a more universal architecture was required. The main platform changed to a universal communication platform. Despite all these changes the name "Modbus.Net" stuck.

The real Modbus Implementation has been moved to Modbus.Net.Modbus. If you want a real Modbus C# implementation, please download Modbus.Net and Modbus.Net.Modbus at the same time.

There is also Modbus.Net.Siemens that can communicate with Siemens S7-200, S7-200 Smart, S7-300, S7-400, S7-1200 and S7-1500 using PPI or TCP/IP.

Modbus.Net.Opc Implements OPC DA and OPC UA protocol.

Supported Platforms

  • Visual Studio 2022
  • .NET 6.0

Thanks

  • Quartz - Job Scheduler
  • Serilog - Logging
  • DotNetty - Network Transporting
  • h-opc & Technosoftware.DaAeHdaSolution & OPCFoundation.NetStandard - OPC Trasporting

modbus.net's People

Contributors

parallelbgls avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modbus.net's Issues

Tutorial is missing example how to connect to simple Modbus Device.

Simple Modbus libraries usually offer very simple methods offering TCP communication with reading and writing coils i.e. :
void setCoils(int offset, bool [] data);
bool [] readCoils(int offset, int number) ;

How to achieve this with your library. This is somethig what is definetely missing in your Tutorial.

西门子的modbus和其他modbus有什么区别么?

我看到wiki里面

Modbus.Net是框架的主体。
Modbus.Net.Standard是框架主体的.NET Standard实现。
Modbus.Net.Modbus是Modbus.Net的Modbus协议实现。
Modbus.Net.Siemens是Modbus.Net的西门子协议实现。
Modbus.Net.OPC是Modbus.Net的OPC实现。

这是不是说明西门子的modbus和其他的modbus不太一样?

Does it support modbus-tcp

Any info ,this library supports modbus tcp? All the functionality? Some documentation or maybe a readme file would be helpful.

s7 300连接读取数据失败,无任何反应。

` _siemensTcpMachine = new SiemensMachine(SiemensType.Tcp, "192.168.10.228", SiemensMachineModel.S7_300, null, true, 2, 0);

var addresses = new List
{
new AddressUnit
{
Id = "0",
Area = "M",
Address = 0,
SubAddress = 0,
CommunicationTag = "A1",
DataType = typeof(bool)
}
};

        _siemensTcpMachine.GetAddresses = addresses;

var ans = await _siemensTcpMachine.GetDatasAsync(MachineGetDataType.Address);

`
读取数据一直长时间无响应。用sharp7是可以的。

.Net Core

It seems the samples provided for .net framework are not working for .Net Core. Is there any example for it where I can test serial and TCP communication and poll data. Thanks in advance

Connect to the ModBus.Slave simulator

I need some help to understand how your library works. I'm in the following condition I've to connect to a Modbus.Slave (which has been given to me) with a config file and need to read those data (I think in polling). When one parameter changes I need to perform some action but that's a later point and there's no need right now to specify further.

So consider I've the Modbus.Slave running on localhost port 504 , how do I set my code to read data from it? I've tried to understand your sources but with no luck

Here's my snippet of code

private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
if (machine == null)
{
machine = new ModbusMachine(ModbusType.Tcp, "127.0.0.1:504", new List()
{

                new AddressUnit()
                {
                    Id = "1",
                    Area = "4X",
                    Address = 1,
                    CommunicationTag = "Add1",
                    DataType = typeof(ushort),
                    Zoom = 1,
                    DecimalPos = 0
                }
            }, 2, 0);


        }

        
        machine.KeepConnect = true;
        machine.Connect();
        var resultFormat = (await machine.GetDatasAsync(MachineGetDataType.CommunicationTag))
            .MapGetValuesToSetValues();
    }

I got null and IsConnected is set to false.
Any suggestion?
Thanks

Full asyncronize communication system

Currently, Modbus.Net using await after sending messages. But this is a bug in fact.
Problem is caused by error packages or passive messages that will caused message shifting.

So it is required to seperate send and receive thread.

Introducing Controller, a message sending control interface.

  1. CanSend. Some boardcasting packages acquire lock to block messages from other devices, especially in multi-master tropy system.
  2. Send. Send messages, and there is no receive in controller when send.
  3. Receive thread. Open a new thread to receive messages.
  4. Receive dispatching. Dispatch message to a message in send list or new in passive return list, and return it to connector, await in connector will be remained.
  5. Passive message event. Directly trig message to event when server send a message to client.

Custom Modbus function

Hello, It would be nice if you provide a guide in order to explain how to develop custom Modbus functions. Could it be possible?

Thanks in advance.

联系方式

你好,可否留联系方式?QQ或微信都可以的。

Custom functions calling in higher level discussing

So Modbus.Net is used for x86 and ARM Embended system for windows and linux.
The memory are always less then 2GB, so DI or Reflection are not quite suitable for this platform.

But acturally calling custom functions should use reflection.

Discussing: Should I implement custom functions calling in Machine and Job layer.

ModbusType.Rtu question

my code
var comPort = GetComPort(); //COM5
var slaveAddress = GetSlaveAddress(); //3
//var registerAddresses = GetRegisterAddresses();

var _utility = new ModbusUtility(ModbusType.Rtu, comPort, slaveAddress, 0, Endian.BigEndianLsb);
await _utility.ConnectAsync();

while (true)
{
object[] receivedBytes = (await _utility.GetDatasAsync("4X 0", new KeyValuePair<Type, int>(typeof(ushort), 2))).Datas;

}

question
receivedBytes is always null and I am sure I get this data by serialPort
10 00 00 00 02 04 04 80 00 00 F8 CF

What am i doing wrong?

Mark: 1.4.1 Guide. This issue will be closed when doc complete

  1. Do not use any api except IMachineMethodDatas and IUtilityMethodDatas. Those apis are not tested. If you want to use, download source code and reference project.
  2. When using 1.4.1, you need to copy appsettings.default.json in Modbus.Net to your project and let it to copy content and update when new. Otherwise Modbus.Net will not work.
  3. You should first look MachineJob in samples before 1.4.1 doc complete.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.