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

Question: How to check the connection status? #117

Open
DheemanthBhat opened this issue Sep 14, 2020 · 0 comments
Open

Question: How to check the connection status? #117

DheemanthBhat opened this issue Sep 14, 2020 · 0 comments

Comments

@DheemanthBhat
Copy link

DheemanthBhat commented Sep 14, 2020

Hi,
How do we know that connection is still active before attempting to write data to PLC?
I am currently using

if(s7Connection.isoConnectionState !== 4) {
  throw new Error("Not connected to PLC");
} else {
  s7Connection.writeItems(address, data, cb);
}

Should we call initiateConnection for every plc operation (read or write to data-blocks)?
something like:

s7Connection.initiateConnection(s7ConnectionDetails, err => {
  if (err) {
    reject('Error connecting to PLC.');
  } else {    
    s7Connection.writeItems(addresses, data, writeStatus => {
      s7Connection.dropConnection(() => {
        resolve(writeStatus);
      });
    });
  }
});

Please help!

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

No branches or pull requests

1 participant