Implementing virtual Serial port communication: java with node-red (The Figures are attached in subsequent postings)

Looking at figure 4, you receive from COM7. As you can see, this value arrives in msg.payload so your function should be checking for msg.payload === "2«"

E.g...

if (msg.payload === "2«") {
  msg.payload = {
    opcuaCommand:"addFolder"
  }
  msg.topic = "ns=1;s=Variables";
  return msg;
}
node.warn(`Unrecognised comm '${msg.payload}'`);
return null;




Forgive me for saying but this is a basic fundamental of node-red - I believe you would benefit from spending a bit time learning the basics....


1


I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.


2


There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

https://nodered.org/docs/user-guide/messages


3


To make code more readable and importable it is important to surround your code with three backticks
```
like this
```

You can edit and correct your post by clicking the pencil icon.

See this post for more details - How to share code or flow json