Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does the example show the server sending a request to the client? #35

Open
jacobq opened this issue Feb 6, 2019 · 4 comments
Open
Assignees
Labels

Comments

@jacobq
Copy link
Contributor

jacobq commented Feb 6, 2019

In Modbus(TCP), the terms "server" & "slave" refer to devices that do not initiate contact with other devices but rather only respond to request they receive. The terms "client" & "master" refer to devices that initiate requests. So why does the first example have the server (slave) send a request (read-coils address 3-7) to a client (master)? This seems backwards.

This is my current test.js file. It creates a client and a server network socket and the server requests coils as soon as the client connects.

@dresende
Copy link
Member

dresende commented Feb 6, 2019

We could've used other names but we wanted to avoid master and slave and just use the terms used in networking for a server (which listens for a connection) and a client (which connects to). Also, you can initiate connections from any endpoint, there's no restriction on that, to enable developers to use modbus in more scenarios.

@dresende dresende self-assigned this Feb 6, 2019
@jacobq
Copy link
Contributor Author

jacobq commented Feb 6, 2019

Also, you can initiate connections from any endpoint, there's no restriction on that, to enable developers to use modbus in more scenarios.

Could you cite a corresponding standard regarding this? I understand that TCP allows this and perhaps your library does too, but I do not believe it is part of the Modbus standards unless you mean that each end is acting as both client and server (which is fine, but then why label them backwards in the example?). For example, MODBUS Application Protocol Specification V1.1b3 says on page 4 (emphasis added):

The MODBUS application data unit is built by the client that initiates a MODBUS transaction. ... The MODBUS application protocol establishes the format of a request initiated by a client.

Furthermore, all of the sequence diagrams show the flow of data being initiated by the client.

The MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE V1.0b also talks about this in the section titled "1.2 Client / Server Model" (page 2, emphasis added):

This client / server model is based on four type of messages: ...
A MODBUS Request is the message sent on the network by the Client to initiate a transaction,
A MODBUS Indication is the Request message received on the Server side,
A MODBUS Response is the Response message sent by the Server,
A MODBUS Confirmation is the Response Message received on the Client side

@dresende
Copy link
Member

dresende commented Feb 8, 2019

unless you mean that each end is acting as both client and server

That's what I wanted to state. This library follows protocol specification (message format), but does not enforce how you initiate connections or which endpoint is responsible for making requests.

I use this library for example on a scenario where devices connect to a centralised server but it's the server that then uses the connection to make requests.

@dresende
Copy link
Member

dresende commented Feb 8, 2019

Where you see modbus.tcp.server in the example, we should've used modbus.tcp.listen, following the network API of node.js (and others), to indicate that we're just binding to a local port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants