Hi, I am new to Node-Red and is trying things around.
I have a ToF sensor that will send distance data only if it is activated by sending a specific set of bytes to it. On node.js, this is how it is done:
function activateBuffer(){
var arr = [ ];
arr.push(0);
arr.push(17);
arr.push(1);
arr.push(69);
return new Buffer(arr);
}port.on('open', function() {
port.write( activateBuffer() );
});
On Node-Red, I have been trying to play around with sending data using INJECT, but I am not sure how can I type in a null character in the INJECT's Buffer payload in this case.
The numbers above could be changed to hexadecimal as 00 11 01 45, so in INJECT, I need to provide ASCII characters to match that. Something like "(null)E" in the buffer editor to get 00 11 01 45, but when I copy and paste, I only got "E", and no null character. So what can be done here?
PS. also, note that when I edit this, I could see the hex 11 and 01 as rectangular boxes, but when I posted it, those characters are invisible in the post somehow...
Alternatively, I have also tried the FUNCTION, and have INJECT invoke the FUNCTION which contains this code:
var arr = [ ];
arr.push(0);
arr.push(17);
arr.push(1);
arr.push(69);
return new Buffer(arr);
I then connect INJECT to FUNCTION to DEBUG, but when I deploy and activate INJECT, I got the following error:
"Function tried to send a message of type Buffer"
So in this case, how can I do this?