It gets Hanged:
ushort[] registers = master.ReadHoldingRegisters(1,41140,16); where 1=slave ID,41140- Modbus Address and number of points
Here is my code:
ing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using Microsoft.VisualBasic;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using FtdAdapter;
using Modbus.Data;
using Modbus.Device;
try
{
Combo1.Text = _serialPort.PortName;
Combo2.Text = _serialPort.BaudRate.ToString();
Combo3.Text = _serialPort.Parity.ToString();
Combo4.Text = _serialPort.DataBits.ToString();
Combo5.Text = _serialPort.Handshake.ToString();
_serialPort.Open();
richTextBox1.AppendText("Serial Port Opened\n");
}
catch (Exception err)
{
string errormsg = "Could not open the port: " + err;
MessageBox.Show(errormsg);
}
IModbusSerialMaster master = ModbusSerialMaster.CreateRtu(_serialPort);
byte slaveId = 1;
ushort[] registers = master.ReadHoldingRegisters(1,41140,16); where 1=slave ID,41140- Modbus Address and number of points
master.WriteSingleRegister(1,41100,150);
ushort[] registers = master.ReadHoldingRegisters(1, 41140,16);
string vOut = registers.ToString();
Here is one link I found:
http://nmodbus.googlecode.com/svn-history/r313/branches/NModbus_net-2.0/src/Modbus.IntegrationTests/ModbusMasterFixture.csThanks!