Coder Social home page Coder Social logo

modbustcp-dotnet's People

Contributors

fabrizioc avatar stephan1827 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

modbustcp-dotnet's Issues

Transaction Identifier

Good morning,

Am I not understanding the code the right way, or is the transaction identifier in the frame the master sends, the function code, and not a unique number that identifies the transaction?

Sorry for the trouble, and thank you very much for your help

Hi Some Parallel For Issue

Dear stephan
I am from Taiwan. Thanks for this source code, It is very helpful for me to study C#.
By the way, I have some question after I use Threading.Task . Is it possible to do Parallel.For to connect multi-IP to get register values.? I do not know how to design local variable. I hope you can give some suggestion.
Here is my code

public partial class Form1 : Form
{
 bool Trigflag = false;  
 int[] stor = new int[1];

private void timer1_Tick(object sender, EventArgs e)
{
Parallel.For(0, IP.Length, (j, state) =>
{ MBmaster = new Master(IP[j], 502, true);
MBmaster.OnResponseData += new ModbusTCP.Master.ResponseData(MBmaster_OnResponseData);
MBmaster.OnException += new ModbusTCP.Master.ExceptionData(MBmaster_OnException);
MBmaster.ReadHoldingRegister(3, 0, 0, 100);
while(!TrigFlag)
{
Console.Writeline("waiting for response");
Thread.Sleep(50);
}
TrigFlag = false;
for (int ll = 0; ll < stor.Length; ll++)
{ Console.Writeline(stor[ll]);}
});
}
private void MBmaster_OnResponseData(ushort ID, byte unit, byte function, byte[] values)
{
// ------------------------------------------------------------------
// Seperate calling threads
if (this.InvokeRequired)
{
this.BeginInvoke(new Master.ResponseData(MBmaster_OnResponseData), new object[] { ID, unit, function, values });
data = values;
ShowAs(null, null);
Trigflag = true;
return;
}
}
private void ShowAs(object sender, System.EventArgs e)
{
bool[] bits = new bool[1];
int[] word = new int[1];
if (data.Length < 2) return;
int length = data.Length / 2 + Convert.ToInt16(data.Length % 2 > 0);
word = new int[length];
for (int x = 0; x < length; x += 1)
{
word[x] = data[x * 2] * 256 + data[x * 2 + 1];
}
}
stor =word;
}

This code can be use in for loop. But in the multi-Thread Parallel.For function, it exist local var and global var problem.
I do not know how to fix it, Can you give some suggestion?

Modbus FC16 not working

Hello,

I was wondering if you tried to work with FC16 (async). I get no response from the MB device, no matter how i read it, even if i isolate it in a separate project.
I'm opening the connection, I'm sending fc16, but getting no response. The reading functions work, this is the only issue I've encountered, and I'll look into it further. I was just wondering if it's a known bug.

Continuous communication problem

I'm communicating with the plc using the library you shared. I have to constantly read and write data from plc. But when the connection is open for a long time, it breaks.

Readme says the following description;
Remember that a lot of Modbus clients use a watchdog telegram to make sure the master is still active. If you don’t call this watchdog within a specified time, the slave will close the connection. This feature is used to avoid unused open ports when the connection is interrupted.

How can I resolve the disconnection?

Thank you for your sharing and support.

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.