Modbus TCP with node-red

Home Forums Conduit: AEP Model Modbus TCP with node-red

Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #16852
    Michael Hance
    Participant

    Hello,

    We want to develop a modbus solution with node-red on our Conduit gateway.
    Currently, a node-red package for modbus exists (https://flows.nodered.org/node/node-red-contrib-modbus). But it seems that requires nodejs >= 4.7. Or today our Conduit use nodejs 0.10.40. So, has anyone ever tried to use this node-red-modbus package on Conduit gateway ? If yes, is it necessary to update nodejs version ? Can this nodejs update cause troubles on our Conduit gateway ? Finally, if we can’t use this package, how to develop a modbus solution on node-red 0.11.1 with nodejs 0.10.40 and npm version 1.4.28 ?

    Thank a lot !!

    • This topic was modified 7 years, 2 months ago by Michael Hance.
    #16855
    Jeff Hatch
    Keymaster

    Michael,

    I am not sure whether or not the modbus node you want to use will work with nodejs 0.10.40. However, it is not possible to upgrade nodejs beyond 0.10.x due to the Conduit being restricted to the armV5tej instruction set.

    Upgrading Node-RED on Conduit is being investigated to see if and where we can end up beyond the 0.11.1 release.

    Jeff

    #16857
    Michael Hance
    Participant

    Thank you for your reply,

    I wanted to know if it was possible because in another topic (here : http://www.multitech.net/developer/forums/topic/node-red-nodes-available/#post-13689) M. Lawrence Griffiths said he had managed to use the node-red modbus package. I don’t know what kind of product he used but today i have a MTCDT-210A Conduit and it seems we can’t use this node-red package on this conduit. My use case is : getting datas from LoRa and put them in a ModBus server with node-red. So, i will try to find another solution.

    • This reply was modified 7 years, 2 months ago by Michael Hance.
    #16859
    Peter Ferland
    Blocked

    As an alternative I’d recommend using python. I’ve used minimalmodbus for serial and pyModbusTCP for TCP. If you’re using mqtt a good, simple python mqtt client is paho-mqtt. Simple usage examples for pyModbusTCP are on the project’s page:
    https://pypi.python.org/pypi/pyModbusTCP/
    https://eclipse.org/paho/clients/python/

    Paho-mqtt has a convenient method for single shot publishing: https://eclipse.org/paho/clients/python/docs/#id17
    You can publish to a topic the mosquitto server running on the conduit at localhost:1883 without authentication. You can then subscribe to the topic you choose using a node-red input node. (Or publish directly to a remote server)

    The easiest way to install all this on the Conduit is running these commands:
    # opkg update
    # opkg install python-pip
    # curl https://bootstrap.pypa.io/ez_setup.py | python
    # pip install pyModbusTCP
    # pip install paho-mqtt

    #16864
    Peter Ferland
    Blocked

    I didn’t see your last post before my reply, sorry.

    For that use case you could call a python script using an “exec” node that just passes your message as an argument. (msg.payload is the first argument by default)

    #16877
    Michael Hance
    Participant

    Thank you for this alternative. I thought about a pythonic solution too.

    I think i’ll try that. For init script at startup, do you have recommendation about linux folder I need to use to start my python server ?

    #16879
    Peter Ferland
    Blocked

    Since you’re using the AEP model you can make use of the device hq application management infrastructure by creating a custom application package using the following instructions: http://www.multitech.net/developer/software/aep/creating-a-custom-application/
    Theres instructions for manual installation during development on this page: http://www.multitech.net/developer/software/aep/creating-a-custom-application/custom-development/

    AEP is based on mlinux so you are free to create an init.d script that calls an application anywhere, say /opt/ or /usr/bin but you’ll have to manually reinstall after a firmware update. There is a very small partition that is not wiped out on firmware upgrades at /var/config but it is only 8MB and is intended for configuration files and the like.

    • This reply was modified 7 years, 2 months ago by Peter Ferland.
    #16985
    Michael Hance
    Participant

    Thank you,

    I start to implement my solution.

    About set up, you said :

    pip install pyModbusTCP

    It’s only a modbus client, so i replaced pyModbusTCP package with pymodbus package because i need to implement a modbus server on Conduit.

    Do you think there will be a problem running if I install the pymodbus package ? Can the Conduit gateway support a modbus server ?

    #16986
    Lawrence Griffiths
    Participant

    Michael when you install using npm it takes the latest npm package.
    node-red-contrib-modbus has been completely re-written and has a number of discrepancies which means it won’t run on AEP.

    I think I used version 0.7.0 which only does modbus TCP you wan’t get RTU working on AEP.

    To install old npm versions use the following
    npm install node-red-contrib-modbus@0.7.0

    To see a list of all versions
    npm view node-red-contrib-modbus versions

    I have friend that is running 3 or more AEP’s using node-red-contrib-modbus I will ask what version they got working.

    Lawrence

    #16987
    Peter Ferland
    Blocked

    pymodbus can be installed on the conduit however its not quite as simple as using minimalmodbus or pymodbustcp because it depends on the compiled python extension “twisted” for threading.

    An ipk is not provided on the default package feed so you’ll have to cross compile it yourself using the bitbake environment documented on this page: http://www.multitech.net/developer/software/mlinux/mlinux-building-images/building-a-custom-linux-image/
    The recipe name is python-twisted. You do not need to build an image, you can scp over the python-twisted-core ipk to the Conduit and install using opkg. After that you can use pip to install pymodbus.

    #16988
    Michael Hance
    Participant

    @Lawrence

    I checked the following site : https://libraries.io/npm/node-red-contrib-modbus/0.4.8

    I don’t know if I can trust it, but from the version 0.4.8 the nodejs requirement was 0.13.4.
    Comments above show that we have limitations, because our nodejs version of Conduit gateway is 0.11.1 and can’t be updated :

    However, it is not possible to upgrade nodejs beyond 0.10.x due to the Conduit being restricted to the armV5tej instruction set.

    In your case, do you remember the version of nodejs and npm that you have used before ? It is nice of you to ask your friends about their versions.

    @Peter

    I tried to install pymodbus two hours ago. I had some compilation errors but the package pymodbus seems to run.
    With your advice i’m going to reinstall pymodbus

    #16991
    Michael Hance
    Participant

    @Lawrence
    Sorry, i made a mistake:

    because our nodejs version of Conduit gateway is 0.11.1 and can’t be updated

    it’s nodejs 0.10.40 not 0.11.1. The 0.11.1 is the version of node-red. Do you know the nodejs requirement for node-red@0.14.1 (the required version for node-modbus package)

    • This reply was modified 7 years, 2 months ago by Michael Hance.
    #17014
    Peter Ferland
    Blocked

    The limiting factor is that google V8 dropped support for armv5 after V8 version 3.17. This means that versions of node.js that require later versions of V8 cannot be compiled for the Conduit.

    • This reply was modified 7 years, 2 months ago by Peter Ferland.
    #17082
    Michael Hance
    Participant

    Hello,

    @Lawrence,

    I tried to install node-red-contrib-modbus@0.7.0 with several npm command.
    Here error log :

    admin@mtcdt:/opt/node-red# npm install node-red-contrib-modbus-0.7.0.tgz –prod –unsafe-perm
    npm WARN package.json mts-gpio@ No description
    npm WARN package.json mts-gpio@ No repository field.
    npm WARN package.json mts-gpio@ No README data
    npm WARN package.json mts-mcard@ No description
    npm WARN package.json mts-mcard@ No repository field.
    npm WARN package.json mts-mcard@ No README data
    npm WARN package.json mts-serial@ No description
    npm WARN package.json mts-serial@ No repository field.
    npm WARN package.json mts-serial@ No README data
    /
    > serialport@4.0.7 install /opt/node-red/node_modules/node-red-contrib-modbus/node_modules/node-modbus/node_modules/serialport
    > node-pre-gyp install –fallback-to-build

    node-pre-gyp ERR! Tried to download(404): https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v11-linux-arm.tar.gz
    node-pre-gyp ERR! Pre-built binaries not found for serialport@4.0.7 and node@0.10.40 (node-v11 ABI) (falling back to source compile with node-gyp)
    gyp ERR! build error
    gyp ERR! stack Error: not found: make
    gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:43:28)
    gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:46:29)
    gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:57:16
    gyp ERR! stack at Object.oncomplete (evalmachine.<anonymous>:108:15)
    gyp ERR! System Linux 3.12.27
    gyp ERR! command “/usr/bin/node” “/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “build” “–fallback-to-build” “–module=/opt/node-red/node_modules/node-red-contrib-modbus/node_modules/node-modbus/node_modules/serialport/build/Release/serialport.node” “–module_name=serialport” “–module_path=/opt/node-red/node_modules/node-red-contrib-modbus/node_modules/node-modbus/node_modules/serialport/build/Release”
    gyp ERR! cwd /opt/node-red/node_modules/node-red-contrib-modbus/node_modules/node-modbus/node_modules/serialport
    gyp ERR! node -v v0.10.40
    gyp ERR! node-gyp -v v1.0.1
    gyp ERR! not ok
    node-pre-gyp ERR! build error
    node-pre-gyp ERR! stack Error: Failed to execute ‘/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build –fallback-to-build –module=/opt/node-red/node_modules/node-red-contrib-modbus/node_modules/node-modbus/node_modules/serialport/build/Release/serialport.node –module_name=serialport –module_path=/opt/node-red/node_modules/node-red-contrib-modbus/node_modules/node-modbus/node_modules/serialport/build/Release’ (1)
    node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/opt/node-red/node_modules/node-red-contrib-modbus/node_modules/node-modbus/node_modules/serialport/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
    node-pre-gyp ERR! stack at ChildProcess.emit (events.js:98:17)
    node-pre-gyp ERR! stack at maybeClose (child_process.js:766:16)
    node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:833:5)
    node-pre-gyp ERR! System Linux 3.12.27
    node-pre-gyp ERR! command “node” “/opt/node-red/node_modules/node-red-contrib-modbus/node_modules/node-modbus/node_modules/serialport/node_modules/.bin/node-pre-gyp” “install” “–fallback-to-build”
    node-pre-gyp ERR! cwd /opt/node-red/node_modules/node-red-contrib-modbus/node_modules/node-modbus/node_modules/serialport
    node-pre-gyp ERR! node -v v0.10.40
    node-pre-gyp ERR! node-pre-gyp -v v0.6.32
    node-pre-gyp ERR! not ok
    Failed to execute ‘/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build –fallback-to-build –module=/opt/node-red/node_modules/node-red-contrib-modbus/node_modules/node-modbus/node_modules/serialport/build/Release/serialport.node –module_name=serialport –module_path=/opt/node-red/node_modules/node-red-contrib-modbus/node_modules/node-modbus/node_modules/serialport/build/Release’ (1)

    npm ERR! serialport@4.0.7 install: node-pre-gyp install --fallback-to-build
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the serialport@4.0.7 install script.
    npm ERR! This is most likely a problem with the serialport package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR! node-pre-gyp install –fallback-to-build
    npm ERR! You can get their info via:
    npm ERR! npm owner ls serialport
    npm ERR! There is likely additional logging output above.
    npm ERR! System Linux 3.12.27
    npm ERR! command “node” “/usr/bin/npm” “install” “node-red-contrib-modbus-0.7.0.tgz” “–prod” “–unsafe-perm”
    npm ERR! cwd /opt/node-red
    npm ERR! node -v v0.10.40
    npm ERR! npm -v 1.4.28
    npm ERR! code ELIFECYCLE
    npm ERR! not ok code 0

    I have same result with :

    npm install node-red-contrib-modbus@0.7.0
    npm install node-red-contrib-modbus.tgz (.tgz downloaded from website with 0.7.0 version)

    and tried these previous commands with –unsafe-perm, –prod and/or –build-from-source

    I can see serialport-v4.0.7-node-v11-linux-arm.tar.gz not exist and i don’t know how to prevent this error

    #17143
    Lawrence Griffiths
    Participant

    Hi if fact it’s a different modbus package my friend got working https://www.npmjs.com/package/node-red-contrib-modbustcp-no-pooling

    #30702

    Hi, has anyone got a modbus server working on a conduit gateway, using either a node-red package or python?
    I am currently trying the same thing, without succes.

Viewing 16 posts - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.