I need to write the string array of hex commands to the serial supported RS232 device, I am trying to send it using a buffer but it is not available in Node-Red version 0.10.40. Could anyone suggest me some possible ways and ideas to send this data? I welcome your suggestions and thank you in advance!
There is no "Node-Red version 0.10.40". Do you mean NodeJS?
If so, that version is pretty outdated and no longer supported by Node-RED.
Which version of Node-RED are you running? You can see it in the console or at the bottom of the editor settings menu.
But apart from that, you can use a function
node to achieve the same.
Have a look at the Buffer docs and the Buffer.from()
method to create a Buffer from an array.
As an example:
msg.payload = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
return msg;
Thank you for your reply. I admit that I am a beginner but It is strange because in the console the version is 0.15.2
, but the node -v command shows 0.10.40.Oof, that's a pretty old version, especially if you are capable of running Node v10 on this device. Can you explain how you installed node-red, and if it would be possible to upgrade to a newer version?
Edit: sorry I read that wrong, Node v0.10 is far older. Still the same question, can you explain how you installed it/what platform you're running on?
I did not install the node-red by myself, actually; I am working on the wireless gateway device in which the node-red of that version is pre-installed.
I tried to implement your idea but this error message came, do you know where have I done something wrong?
Sadly, that won't work, because of this small note:
When running node v0.10 (EOL 2016), you're unable to use the Buffer functionality.
As is shown with the error displayed:
You are right because in the latest version of node-red I got the expected output. Do you have any idea what should I do now to implement same thing in the old version? ,
You can go back to the 0.10.x version of the Buffer docs to see the available functions: https://nodejs.org/docs/latest-v0.10.x/api/buffer.html
I think the following would do it:
msg.payload = new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
return msg;
Thank you, I go through the Buffer docs. By the way, your code generated this output
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.