This is my code:
private void timer1_Tick(object sender, EventArgs e)
{
using (TcpClient client = new TcpClient("127.0.0.1", 502))
{
ModbusIpMaster master = ModbusIpMaster.CreateIp
(client);
for (ushort i = 0; i < 16; i++)
{
ushort[] value = master.ReadHoldingRegisters(i,
1);
textBoxes[i].Text = Convert.ToString(value[0]);
}
}
}
I know I could read all 16 registers in one message but i'm just
trying features. The thing is I always get that error on the second
execution of the loop. Testing client.Connected and connecting it
again will not work either (I get an error like a connection request
has already been made). Using .Net framework 3.5, windows xp, visual
studio 2008.
Any ideas? Thank you!