Implementing virtual Serial port communication: java with node-red
We have created a GUI using Netbeans (Java) and we used node-red to communicate with a PLC. We are also using virtual serial port because we have been working with the OPC UA Protocol. We have already connected Node-Red with our GUI to generate a graph with random numbers; Figure 1 shows it.
Our challenge is to send data with some conditionals. To test our progress, we have created this function on our Flow; Figure 2:
However, the answer we get is shown in Figure 3 on the debug.
We tried some modifications, for example, we put “COM7” , and Figure 4 shows the answer we get when we run it:
Figure 5 shows the message of each button of our GUI.
If we delete “/n” of our java code, the node-red doesn’t work. The next picture shows what happens when we click 5 times on the buttom Led 2 “encender (turn on).” After we click only 1 time on another button, the debug sends a message after the last click, here is a picture— Figure 6—about that:
We think Node-Red is waiting an enter or “/n” to send a message. The key questions is Where can we save the variable from serial port?