Hello,
I am trying to return robot data in Node-RED. Currently, I have a robot script that runs on the robot (client) that sends the data e.g. joint position to my RPi. I have been able to used a python script to create a server socket such that when I run it, and then run the robot script on the robot, the robot data sends to the output window in my python ide. I thought that I would be able to use the TCP node in node red to bring this data in, but after various attempts I have been unsuccessful. I have both tried to listen and connect to the RPi IP and port, tried the various output settings within the tcp node. I thought it might be a decoding issue, so I have tried to use the convert (iconv) node to decode it (utf8), and used a function to try and decode it. I have also tried to put my server socket script into a python node, but I am unfamiliar with this an I am sure on how to get the msg payload out. I would like to stick to the TCP node if possible. I have also tried the tcp-server and the tcp-client nodes to no success. I would appreciate any guidance on my problem, thanks in advance! The output in the python ide for the joint angles is a list: [89.587, 5.007, 98.900, -8.145, 64.251, -102.354]. The python code for reference is:
import socket
HOST = "192.168.0.50"
PORT = 2000
server = socket.socket()
#print('socket created')
server.bind((HOST, PORT))
server.listen(1)
client, addr = server.accept()
msg = client.recv(1024)
print(msg.decode('utf-8'))
client.close()
server.close()