LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

make a TCP connection between LabView and Node-Red

Solved!
Go to solution

I am tring to make tcp connection between node-red and labview. but in order to do that I need to define IP address and port number of labview server in nodered. and I am not sure where to find them.

so could someone please help me with that.

2023-03-16_12h30_17.png

kuldeepM_0-1678969350551.png

 

0 Kudos
Message 1 of 4
(1,985 Views)
Solution
Accepted by kuldeepM

Without knowing NodeRed I'd say:

- NodeRed can surely run on any local IP, of course not 127.0.0.1. Check the IP of your PC and set the one on NodeRed to perhaps one higher. Pick any port.

- Once NodeRed is running a TCP stack, open a socket connection to NodeRed by using its IP and the selected port by using the TCP VIs.

0 Kudos
Message 2 of 4
(1,963 Views)

I am also not familiar with the Node-RED code here does, but at least the LV code doesn't seem to make much sense:

 

  1. You appear to be listening on port 88, but then you don't have anything using that port. Your NR code seems to use port 28. I don't know if these are running on the same PC, but if they are, the localhost address you used on the Node-RED side should work (barring firewalls, etc.).
  2. You use an IP address which you don't have anywhere else as the service name. This doesn't actually do anything, as the service name is just an NI thing for translating a name to a port number. You don't actually need to use that input.
  3. If someone connected, you try to read a single byte and convert it to a number, which I'm assuming does not match what's happening on the other side.
  4. You have no error handling, which is fairly important when doing TCP streaming (reconnections, etc.).

 

I would make the following suggestions:

  1. Consider moving to something like a web service, rather than streaming. That makes your code simpler and doesn't require you to handle the TCP code. It makes sense if you have discrete operations.
  2. If you still want streaming (in order to learn) or because you need it, start with something simpler. Use just Node-RED or just LV and create both sides there. Just pass bytes and see that you get them. Once you have that working, then try building the other side. The LV example finder has examples for TCP and I'm assuming there's no shortage of Node-RED examples too. Once that is working, then see how you encode and decode actual data.

 


___________________
Try to take over the world!
0 Kudos
Message 3 of 4
(1,917 Views)

Thank you for your reply.I have already made changes but Now I am facing this new problem:

https://forums.ni.com/t5/LabVIEW-Web-Development/TCP-SERVER-READING/td-p/4291879

0 Kudos
Message 4 of 4
(1,912 Views)