using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using EasyModbus;
namespace TestGui
{
public partial class Form1 : Form
{
public ModbusClient m;
public Form1()
{
InitializeComponent();
m = new ModbusClient();
m.IPAddress = "172.17.6.23";
m.Port = 502;
m.Connect();
}
private void button1_Click(object sender, EventArgs e)
{
m.Connected.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
var r = m.ReadCoils(0, 1);
}
}
}
The Connected property always returns false, no matter if I check it right after .Connect() or even when I just read some data from my modbus device like in the button2_Click method above. Tested with version 1.0.5555.26938.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It works! but is there any way to detect if the physical connection is established? because when I disconnect, I get an exception when using the connect property ..
from now, thank you very much
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi! Can I any case detect in Modbus client (C#) connection is established.
While I disconnect MB server Modbus client steel retyrn some data, and conected property is "TRUE"
version of EasyMB - 5.0
TRhanks!
Last edit: Andrey 2018-08-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, unfortunately the "Connected" Property isn't 100% reliable. If the Server closes the connection, the "Connected" Property is still "TRUE". If you are trying to send a requets, in that case you would get an Timeout Exception.
Propably the "Available" Method could be helpful. That Method checks only if the Server can be pinged via Network, but not if the connection is still alive.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When I run a sample application like this:
The Connected property always returns false, no matter if I check it right after .Connect() or even when I just read some data from my modbus device like in the button2_Click method above. Tested with version 1.0.5555.26938.
You are right. I just fixed it.
Thank you!
Hello, I had the same problem when using the property attached, could you solve it?
The problem above has been fixed. I just tried it, and it is working.
Did you use the latest Version (V1.5) ?
No, where I can download it?
It works! but is there any way to detect if the physical connection is established? because when I disconnect, I get an exception when using the connect property ..
from now, thank you very much
Hi! Can I any case detect in Modbus client (C#) connection is established.
While I disconnect MB server Modbus client steel retyrn some data, and conected property is "TRUE"
version of EasyMB - 5.0
TRhanks!
Last edit: Andrey 2018-08-27
Hi, unfortunately the "Connected" Property isn't 100% reliable. If the Server closes the connection, the "Connected" Property is still "TRUE". If you are trying to send a requets, in that case you would get an Timeout Exception.
Propably the "Available" Method could be helpful. That Method checks only if the Server can be pinged via Network, but not if the connection is still alive.