I am using the Modbus Write and Read functions.
I have enabled logging and error reporting, which output to the Windows Command Prompt (cmd) console.
How can I intercept these messages directly at the function output, or retrieve them from the console?
If a read or write error occurs, I want to set a variable to 1.
@jlt57 can you modify that Debug node to show the complete msg object? It is currently showing msg.payload - the Catch node will include error details under msg.error
When you say there are no errors on subsequent ones do you mean there are no errors, or there are errors but they are not reported, or do you mean something else?
Yes, there are errors, but they aren't being reported.
As shown in the screenshot, the "read (2)" block is polling (e.g., a disconnected cable error is detected by the catch node); however, if I inject a write command using the "1 xrite" node, no error is reported by the catch node.
Hi,
Actually, when you have just a single read node or a single write node, the error is reported via the Catch node.
If you have both a read and a write operation in the same tab, only the read error (the first error) is reported by the Catch node.
Regarding why it's the read operation in my case: I think it's related to polling.
Continuing with my line of reasoning as to why only one event is reported by the Catch node:
it's because both nodes point to the same connection node that links to the PLC.
It’s just something you need to be aware of.
With PLCs, you can diagnose every command sent; that’s why I wanted to do the same thing with Node-RED.
You would expect the read node to be the first one to generate an error as it tries regularly.
You didn't actually answer the questions. If (after the read error) you try to write, does it log another error (in the log) and what status is shown under the node?
If you disable the read node, so it does not generate an error, then with the modbus working correctly you disconnect and try another write do you then get an error from the write node?
You didn't actually answer the questions. If (after the read error) you try to write, does it log another error (in the log) and what status is shown under the node? --> NO
If you disable the read node, so it does not generate an error, then with the modbus working correctly you disconnect and try another write do you then get an error from the write node? --> YES
It would be more helpful if an error was thrown each time an operation is attempted I think. You could raise an issue on the node's github page and see if the author agrees.
You still didn't answer all of the question - what status is shown under the nodes when in error?
You might be best to use a Status node to give you the status, and use that to know whether there is a problem or if all is working.
Got to flows.nodered.org, find the node and there should be link to the GitHub page, on the right hand side I think. Or an internet search asking in words where to find it would likely work.