Intercept Modbus errors

Hello,

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.

Thanks in advance for your help.

"12 Jul 18:57:13 - [error] [modbus-read:8eb259425571f342] Error: Timed out"

Does a Catch node catch the error?

Hi,

Yes, but no details.

@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

Here (in the catch block), it intercepts the read error but not the write error, even though it is configured for all nodes.

@knolleary Thanks a lot

That is strange, is there an error in the log for the write error and does the modbus node show an error status?

Actually, it seems like there's an error only for the first stream, not the subsequent ones.

image

What do you mean by 'stream'?

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.

Is an error logged?
What status is shown under the 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.

Those are my deductions—still to be confirmed...

Sorry for my English.

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?

Sorry

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?

Reconnecting..

I'm not used to this yet—where can I find the GitHub link?

Thanks for your help.

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.

Yes,
With the node of status I Can have this ?
How can errors from a PLC connection configuration node be retrieved?

It won't give you the error message, just the text displayed under the node.