-
Notifications
You must be signed in to change notification settings - Fork 122
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
Read single item #127
Comments
readAllItems doesn't return the values synchronously. It is meant to be called with a callback function (asynchronously) to initiate a read, which can take a while depending on how many values you are reading and what your network is like. nodes7 can be used over a VPN which means a response can take seconds, and you don't want your app to be non-responsive in that time. Modifying valuesReady isn't what I would suggest either as valuesReady is meant to be called as a callback function with the values when they are returned from the PLC, not as a function to get the values for use elsewhere. You can, however, create an object within your module and update it in valuesReady, then have another function that returns its value. Try this sort of pattern:
|
Thanks for the suggestion, I will see if this can solve the issue. |
I'm getting "[84762,535272400 172.16.1.11 S1] Waiting to read for all R/W operations to complete. Will re-trigger readAllItems in 100ms." in a eternal loop. It only stops if I send a command write. |
I've been looking into a way to read one or a few booleans and although I managed to use the "conn.readAllItems(valuesReady);", I would like to bind the logged values to variables, so I could send them back to my client.
console.log("\n\n\nTrying to read something here");
conn.addItems(["TEST3"]);
let read = conn.readAllItems(valuesReady);
console.log("Read is: " + read); // this results in "Read is: Undefined"
I also tried to modify the valuesReady function:
function valuesReady(anythingBad, values) {
}
But again, no success.
Does anyone knows how can I get a readable value?
Maybe I could even contribute to some specific code if there's no such a function to do it.
The text was updated successfully, but these errors were encountered: