chrome-modbus icon indicating copy to clipboard operation
chrome-modbus copied to clipboard

Connecting the Modbus

Open hammadtq opened this issue 9 years ago • 0 comments

Hi,

I found an error and struggled with it for a while.

When we acquire a new client via:

var client = new ModbusClient()

The function in modbus.js has:

`ModbusClient = function (timeout, autoreconnect) {

    if (!(this instanceof ModbusClient))
        return new ModbusClient(timeout, autoreconnect);

    // needed for the inheritance
    StateMachine.call(this, 'init');

    var host            = 'localhost',
        port            = 502,
        id              = 0,`

While again, after acquiring the client I am giving host and port:

client.connect(host, port);

After much struggle, I found out that above 'localhost' is creating all the problem. If I change it to the IP address then it works fine. However, I am not sure why library is using an IP there and then also using a different connection function. Can you please have a look?

Great work by the way!

hammadtq avatar Sep 18 '16 10:09 hammadtq