Modbus TCP and process.env.NODE_RED_HOME

#1

First: Running Windows 10 and a freshly installed NR with node.js 10.15.3.

I am trying to communicate with a Modbus TCP slave and am having some success with the biancode and Argonne-National-Labs contrib nodes. However the altamira/ node-red-contrib-modbustcp-no-pooling
seems not to install, although the failure is only apparent when I re-start NR and get the error

29 Mar 16:48:02 - [warn] [node-red-contrib-modbustcp-no-pooling/modbus tcp] Error: Cannot find module 'C:\Users\mizejc\AppData\Roaming\npm\node_modules\node-red/red/red' (line:46)

The node installs modbustcp.js which contains the lines:

module.exports = function (RED) {
var RED = require(process.env.NODE_RED_HOME+"/red/red");

which seems to be the source of the problem because of the "/red/red" path substring which is not a Windows thing. But I don't know enough about node.js to know whether that's really it or not.

Any suggestions?

Thanks.

I've opened an issue but they haven't done anything in 3 years so I don't have a very high expectation of a response.

If anyone wants to recommend which of the Modbus TCP "libraries" (is that the right word?) is the best, I'm open for suggestions.

0 Likes

#2

Hi @CaptClaude

it looks like that node is still using a way of accessing the Node-RED runtime that has been long deprecated and should have been updated years ago.

The 0.20 release of Node-RED changed the internal layout of the code, so the assumptions that node made about how to access the core of the runtime no longer hold true.

I see you've already raised an issue on the node - that's the right first place to start in resolving this.

1 Like

#3

Both node-red-contrib-modbustcp and node-red-contrib-modbustcp -no-pooling bring with them files names modbustcp.js and both files have identical headers, but they are very different.

Fortunately for me there is a more consistently maintained Modbus TCP library (is that the right word?) that I can use: Klaus Landsdorf's node-red-contrib-modbus with which I am slowly coming to grips.

Thanks.

0 Likes