• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using node.js on NIOT-E-TP151-EN-RE
#1
Hello together,

in the first steps I tried to do the job with the Node-RED to build a OPC/UA-Gateway.
But due to slow development of the OPC/UA-Nodes we decided to go one step down and program the software in node.js.

Is the software already deployed on the box?

And are where some examples for development and debugging available.

I the past I have developed in C++ with using a in-circuit-emulator for testing. But these things are opsolete today.

Can you give me a hint, how to use node.js on the box and debug the code?

Kind regards,

Carsten Oswald
  Reply
#2
Hi Carsten,

well the box has Node-RED preinstalled and Docker as only two software components you can use. You say you can't go further with Node-RED, so the only possibility to load additional software onto the box using Docker and Containers. So if you want to have your own "thoughts" in the box you can extend it yourself. There is no such thing like OPC-UA preinstalled on the box.

I am not a node.js developer so I don't know how to do it the best. From a Linux shell I found this link on google https://nodejs.org/en/docs/guides/debugg...g-started/. But what I have seen also that one of colleague using Visual Studio Code along with Raspberry Pi applications to debug from remote. There are several links on the internet such as this one explaining how to proceed: https://medium.com/@equus3144/install-vs...895a9aff6f


The most practical way to develop own software and to check is is to buy a $20 compatible Raspberry Pi 3B with Raspbian OS on it and install node.js and all its debug capabilities.

If you then think of the NIOT-E-TPI51 device that is supporting Docker as only possibility to load additional software on it ... then it turn it would be good to continue node.js developments on original Raspberry Pi but under Docker.

To install Docker on Raspberry Pi follow this link https://www.raspberrypi.org/blog/docker-...pberry-pi/.  And then afterwards load a Raspbian OS container onto your Raspberry Pi 3B using the command


Code:
docker run -d --privileged --network=host --restart=always --name=raspbian hilschernetpi/netpi-raspbian


After the container is deployed on your Raspberry Pi then you can "jump" into it  using the command


Code:
docker exec -it raspbian /bin/bash


Then you can make developments in the container and test the "feeling" and have im mind that this container and everything you do in it will later work on NIOT-E-TPI device the same.

If you want to use the TPI device directly for developments and tests then I recommand to load the very same container hilschernetpi/netpi-raspbian onto your TPI51 device and access it over an SSH channel. Here is how to deploy this container on TPI to get it started: https://registry.hub.docker.com/r/hilsch...-raspbian/

Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#3
Hello Armin,

now that the netpi-raspbian is running with node.js and my programmed OPC/UA-Server sends data, I will ask my next questions.

Is my thought right, that I can access the NPIX RS485 via /dev/tty - device?

And is there a way to use the filed-side Ethernet-Port from the netpi-raspbian?
Filedbus support is not necessary, simple TCP/IP for MODBUSverIP


Looking forward your reply.

Carsten


Attached Files Thumbnail(s)
   
  Reply
#4
Hello Carsten,

yes you can access to NPIX RS485, als long as you map the correct "/dev/ttyS0" device to your container and set the GPIO 17 to direction output and value 1. This enables auto-direction control. In order to be able to set GPIOs in containers in general you have also to add the devive "/dev/gpiomem" to the container and to run it in "privileged" mode. This is all you need.

In order to let the netX run as ethernet interface just start a second container in parallel from here https://github.com/HilscherAutomation/ne...hernet-lan. Start is in host mode. Then the new network interface cifx0 witll be created on host side and you see it as second interface next to eth0 on the device's web-UI under network settings. There setup the ip configuration as standard. Make 100% sure that the system's Node-RED is not running because it would reconfigure the netX chip back to industrial ethernet support. This cannot run in parallel.

Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#5
Hello Armin,

many thanks, serial port and GPIO are forwarded to the node.js container, second container is running and I see the cixf0 in the control panel -> network -> LAN.
If a IP-address is asigned to the cifx0 in the control panel, the box sends the packets from the node.js-container to the requestet port?

Sample:
eth0: IP-address 192.168.30.155/24
cifx0: IP-address 172.17.1.200/24

In Docker, in the "hilschernetpi/netpi-raspbian"-Container, the node.js wants to establish a ModbusTCP connection to 172.17.1.100.

In my opinion, this should work without any additional task.
Is this right?

Looking forward your reply.

Carsten
  Reply
#6
Your setup is right.

If you now connect a Modbus TCP server with IP address 172.17.1.100 to the double RJ45 port cifx0 ports then all outgoing traffic to this IP address will be automatically routed by Linux to the cifx0 port and the response back to the requester ... in your case the container.
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#7
But why have you chosen such a cryptic IP address and range? 172.17.1.xxx ? Does it have a special reason?
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#8
(May-14th-2020, 10:43 AM)Armin@netPI Wrote: But why have you chosen such a cryptic IP address and range? 172.17.1.xxx ? Does it have a special reason?

What's cryptic on this range? It's just another private IP-range. I got it from my IP guys, and take it as common.
  Reply
#9
Thumbs Up 
Hello Armin,

now the work is almost done:
  • The netPI is running in Docker
  • Node.js + needed modules installed
  • OPC/UA-Server is running
  • MODBUS-RTU connection to Mitsubishi FX PLC controller is up
  • Data interchange is running, the data-format from Mitsubishi is a little bit confusing
  • Node-Script can be started as service
Many thanks for your great support until here.

Now, where are 2 points left, to get ready-to-show:
  • after reboot, the export of GPIO-PIN-17 got lost
    A litte shell-script fixes this

    .txt   pin17.sh.txt (Size: 274 bytes / Downloads: 2)
    But this is a little bit silly
  • Script should start automatically at startup, but this fials.
    I adapted a wild-card script for init.d. This works on the console but not at startup.Maybe, because the GPIO PIN 17 is missing?Script prototype:
    .txt   amadaserver.txt (Size: 2.06 KB / Downloads: 2) installing service:
    .txt   installservice.sh.txt (Size: 182 bytes / Downloads: 1)

Do you have a good idea to deal with this?

CU,

Carsten

Solved!!!

I have added my scripts in the entrypoint shell script.

   

Now the missing GPIO PIN 17 is rewritten on every boot and my service is started headless.

Many many thanks to Armin for your big support, endurance and patience!!!!


Attached Files Thumbnail(s)
   
  Reply
#10
Well Carsten,

one word to the GPIOs. The demand of a container is to keep the Docker host as untouched as possible. So it is quite natural that after a restart of the device the GPIO X is no longer exported ... this is why you need in any case a startscript file in a container that does exactly those setups each time the container is started / re-started.

Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  NIOT-E-NPIX-RS485 LucioFiam 6 4,000 January-21st-2023, 05:20 PM
Last Post: Armin@netPI
  Node Red configuration LucioFiam 3 1,648 November-30th-2022, 05:14 PM
Last Post: Armin@netPI
  secure node-red with a username and password Christian_Rau 3 2,845 December-3rd-2021, 11:06 AM
Last Post: Armin@netPI
  cifx0 and Node-Red fabio1975 5 3,104 November-22nd-2021, 01:13 PM
Last Post: Armin@netPI
  Node red web UI issue DSongra 3 3,152 July-22nd-2021, 02:47 PM
Last Post: Armin@netPI
  Node-RED 'projects' possible on netPI? JG_KIT 2 2,305 July-20th-2021, 01:11 PM
Last Post: JG_KIT
  Node-RED: OpcUa Client node tad 4 4,397 June-9th-2021, 08:51 AM
Last Post: tad
  NIOT-E-NPIX-4DI4DO with netpi-netx container WalterSchaefer 3 6,478 November-25th-2020, 01:06 PM
Last Post: zen89
  Accessing a modbus device connected to RTE port from Node-RED tad 10 7,906 October-2nd-2020, 07:21 AM
Last Post: Armin@netPI
  5 x NL 50-Mpi and Node Red like colector data? Jotarod 4 3,886 September-14th-2020, 01:59 PM
Last Post: Armin@netPI

Forum Jump:


Users browsing this thread: 1 Guest(s)