Communication problem with a robot via TCP/IP

Hi,

I use Node Red to communicate with a Universal Robots robot. I connect to it via TCP / IP.

From the robot, I receive a stream of buffer, according to the manufacturer, with a frequency of 10 Hz.

Unfortunately, when using this connection, it turned out that some of the information did not reach NodeRed at all.

I did the test: I wrote a program with the same functionality but outside Node Red in JS and easily received all the information.

Dear developers. can you help me or show me where the problem is?

Below "recipe" of the message from robot:

Below my code:

Iread byte 4 from the signal I received, unfortunately I have never received a message with the number 25 .

If you need additional information, screenshots etc. let me know.

Thank you very much in advance,
Regards,
Michał

I'd start with sending data/payload (unmodified) to a debug node to see if data is broken up or missing something before trying to figure out if the function code or node-red environment is the problem.

Just to put your mind at ease a little, I use TCP for receiving ASCII data (no real difference) from a legacy system, but the data has a well defined start and end mark to work from.

What instructs your TCP node that it's a finished piece of data? Are you sure data is not split differently to how you expect? (Debug node is your friend here as explained in first node)

1 Like

Hi @Steve-Mcl,

I have checked all of things you mentioned and unfortunetly I have no solution to my problem. I have never received message that I should have.

Now I am thinking how to make my own tcp input node basing on my Javascript code.

Could anybody help with that?

My code in JS.
var net = require('net');
var client = net.connect(30001, '10.35.135.240', function() {
console.log('connected to server!');
});

client.on('data', function(data) {

if(data instanceof Buffer){

var buf1msglen = data.slice(0,4);
var buf2msgtype = data.slice(4,5);

var msglen = buf1msglen = buf1msglen.readUInt32BE(0);
var msgtype = buf2msgtype.readUInt8(0);

//console.log('Message length: ' + msglen);
//console.log('Message type: ' + msgtype);

if(msgtype === 20){
//console.log('found messagetype 20___--');

 var buf3robotmsgtype = data.slice(14,15);
 var robotmsgtype = buf3robotmsgtype.readUInt8(0);

 console.log('Robot message type: ' + robotmsgtype); 
if(robotmsgtype===9){
	buf4requestType=data.slice(19,20);
	var requestType=buf4requestType.readUInt8(0);
	
	buf5textMessage=data.slice(20,msglen);
	var textMessage=buf5textMessage.toString();


	console.log('Request type: ' + requestType);
	console.log('Text type: ' + textMessage);
	}

}
}

});

client.on('end', function() {
console.log('disconnected from server');
})

  1. Maybe you should share some info about your node-red flow and the data your actually receiving.

  2. TCP guarantees the delivery of all data so what do you actually mean by the the information did not reach NodeRed at all

  3. Also some links to the actual Universal Robots and its API documentation might help us giving support (or at least get the forum people interested).

  4. Doesn't it support a better protocol than a TCP stream to get its status (seems pretty outdated).