node-modbus-serial icon indicating copy to clipboard operation
node-modbus-serial copied to clipboard

Can a Modbus TCP Slave actively send a frame to a Modbus TCP Master?

Open Oniokey opened this issue 1 year ago • 3 comments

I looked through various examples and documentation and found that a slave cannot actively send a frame of data to the master, but this can be useful in certain scenarios, such as when an IoT server is acting as a slave, one might want to be able to send down some configurations from the cloud to a device, which would require the slave to be able to actively send data to the master.

So, how can I send data from slave to master?

Oniokey avatar Dec 14 '24 07:12 Oniokey

When the slave station sends data to the master station, i think it just calling the write register API?

Stormpass avatar Jan 02 '25 01:01 Stormpass

Sorry, but I didn't get it. When I start a slave station, I use this

import { ServerTCP, IServiceVector } from "modbus-serial"

const vector: IServiceVector = { /* some functions here */ }

const client = new ServerTCP(vector, {host: "0.0.0.0", port: 8502, debug: true, unitID: 1});

but client did not have the write register API

Oniokey avatar Jan 06 '25 07:01 Oniokey

You need to read about Modbus and you will see that it's a master/slave protocol. The only way to exchange information between a slave and a master is by having the master send a request to the slave.

The whole protocol is built around the concept of request => response.

This is not a limitation in this library, it's a limitation in the protocol.

When slaves start sending data without it being requested they are no longer Modbus devices, since they aren't respecting the specification.

Xsandor avatar Apr 10 '25 14:04 Xsandor