Thank you for the informative post. I was wondering if this is the same situation for the Wago PFC200 controllers?
If so, how does one read up on the devices and there names? For example here the serial port is “/dev/ttySTM1”. Is this information freely available somewhere?
Additionally, I am busy working with a PFC22-8216 controller that has a built-in serial port, however we have added a serial card 750-652 on the kbus. Is there any way to access the serial comms on the card via the kbus for NodeRED or would you suggest using the built-in port for NodeRED?
Just for a bit more information, here is a copy of the email I sent to Wago’s support for some more context of the issue.
I have a pfc200, 8216 controller.
I have been able to successfully run Modbus tcp/ip communication with a power meter in Node-RED. I’m now trying to do the same but with Modbus rtu.
I am using the node-red-contrib-modbus package and am interfacing with an inverter. The controller has a built-in RS-485 port (I think it is /dev/ttyO1 on the controller’s Linux system), we also have a 750-652 serial card connected to the controller.
What I want to please know is how do I use Node-RED to perform the Modbus rtu comms. In docker I believe I have to set the port permission when starting the Node-RED container? I assume that this will be related to the serial port (/dev/tty…). I’m not sure whether it will be easier to setup the onboard serial port or the 750-652. If you could please advise what I should try.
@WagoKurt thank you very much for the response, it has helped my understanding a lot. I have since set port ttyO1 to rs485 by using the command line tool (/etc/config-tools ./set_serial_mode_rs485). I also ensured that the necessary r+w permissions were allowed to ttyO1 for read and write access to the port using the chmod command.
To get the modbus rtu communication working tried using the node-red-node-serial port palette for modbus rtu but to no avail. I’m not sure if the functions in that palette are capable of performing modbus rtu read and write operations? In the example guide you attached I see it is used for ASCII.
I would just like to please confirm that modbus rtu can be achieved with the pfc200 8216 controller in Node-RED? And that it is most commonly done by using the node-red-contrib-modbus package, with the built-in RS485 port (X3)?
The reason I ask is because I have tried to perform a modbus RTU read but each time the docker container keeps restarting, even if I use the (–security-opt seccomp:unconfined) command when running the container. I’m not sure if this is a common issue? I also cannot assign port 1880 when --network=host is applied in the command, this may also be what is causing the problem.
For more context, the modbus read block in Node-RED just says “waiting” and the container restarts which causes it to lose connection. I then have to stop and remove the container and repeat the process.
Do you perhaps have some ideas as to where I could be going wrong? Sorry for all the information but I just want to provide as much context as possible. Any advice would be greatly appreciated.
Can you verify what containers are running with the command;
docker container ls
I would ensure only one container is running for the initial testing of the serial port. And also can you confirm that the Codesys runtime is disabled.
@Devlin_Hugo@WagoKurt
I am experiencing a similar issue on my wago CC100 running node red in docker. I’ve spent the last couple of days trying to solve this but with no positive outcome. Even with only one modbus serial read node and a debugger, after configuring the modbus read node, node red immidiately crash and goes into infinite boot-loop. I finally managed to find the flows.json via FTP and remove the modbus node from the flow and node red started back up on its own, as it should.
Same thing happens (serial only, TCP works fine) with node-red-contrib-serialport and node-red-contrib-modbus.
I’ve found some older info about this being an issue in the past as well, but on raspberry pi. In this case I would assume this is either a firmware or a node issue
I don’t have any logs available just now. FYI, I have two Wago CC100 installed docker and node-red exactly the same way, both are acting the same way.
I can confirm that the runtime on the controller has been disabled. Each time Node-RED has crashed I have stopped and removed the container using the “docker stop containerID” and “docker rm containerID”. I would then run the “docker container ls” command to confirm that it was removed successfully.
Subsequently, I have been trying to run a container which doesn’t keep restarting by playing around with the docker run command, but each time the serial port ttyO1 is required the issue arises. For a bit more context, I was using a similar approach to that of @StefSoma by making use of a single modbus read node and a debugger when Node-RED kept rebooting.
I would also just like to please confirm that the PFC200 controllers have been used to achieve serial communication (modbus RTU) using Node-RED? Not sure if there are better ways to test if the port is working?
@WagoGrim Thank you for the guidance. Unfortunately it made no difference. I modified the 99-serial.rules file, but still, the minute I add a modbus and a debugger (in a fresh clean flows, not other flows what so ever) and deploy. Node-RED immidiately goes into infinate boot-loop
root@CC100-568AF0:~ ls -l /dev/ttySTM1
crw-rw-rw- 1 root dialout 247, 1 Jun 19 11:09 /dev/ttySTM1
I used this command to create the node-red container initially, as far as I can see. It worked fine. Node red “finds” the serial port in the “search” field in the config window of modbus-client node.
My only trick is to try something different docker container like Telegraf in the repo I linked to then we know if its only Node-RED or not in your setup… Recipe something like:
docker pull arm32v7/telegraf
You can modify this conf-file, you only need the serial driver app inside here…
Run and see if its working or not…
docker run -d --name mytelegraf --device=/dev/serial:/dev/serial:rw -v /home/admin/telegraf.conf:/etc/telegraf/telegraf.conf:ro arm32v7/telegraf:latest
You can also try this Modbus/TCP to RTU gateway.
It also requires to associate the host serial device to the container.
You can adjust the verbosity if needed.
Sorry for taking a while to respond, quite a lot going on at the moment.
I have managed to create a container with modbus rtu that does not crash. However the actual reads are not successful which is perhaps a configuration error on my side. I don’t believe so though as I have been very thorough in checking the communication parameters as well as the registers I’m reading from.
I keep getting a “Error: Client Not Ready To Read At State reconnecting” error in the debug channel as indicated in the provided screenshot. Not sure if this is something you have dealt with before? Or if perhaps @WagoKurt and @WagoGrim have any possible suggestions.
Instead of using a debug node directly after the Modbus Read node, I used a Modbus Response node which seems to be effective in preventing the crashing. I also ran @WagoGrim’s chmod command (thanks @WagoGrim ) chmod ugo+rw /dev/serial. I believe that the permissions for the port were already granted before the command though, as I mentioned in my previous posts.
I then connected the debug node to the Modbus Read node where it connects to the Modbus Response node. Still no luck reading any actual registers unfortunately but at least the container seems stable.
When I run the command and check file this is the message which appears each time I “inject” the modbus read node:
21 Jun 13:05:47 - [error] [modbus-read:65d2b5d11c21941e] Error: Client Not Ready To Read At State reconnecting
I’m going to try using the advice in the post @StefSoma provided a link to and try to rebuild the serial node. Will post an update here if I have any success.
A further update, if I remove the connection timeout in the Modbus Read node, the node in idles the green “active” state. I then trigger the modbus rtu read in Node-RED and now I get an error which says “Error: Port Not Open”.
This seems to point to the fact that there’s some type of configuration issue with the serial port.
@WagoKurt I’m trying my exact same setup /config as for another wago C100 that’s working with both TCP and serial node-red-contrib-modbus. Last time I ran npm rebuild --build-from-source. After that (and making sure the modbus wiring and EOL resistor were in place it worked). However, the npm rebuild did not work on my new cc100.
This time I also tried this to no avail.
npm cache clean -f
rm -rf node_modules/
npm install
TCP works perfectly fine using node-red-modbus, only serial not working.