mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Add msg.port to serial port input node
This commit is contained in:
parent
26458522dd
commit
0253f67882
@ -16,6 +16,7 @@
|
||||
<li>Wait for a timeout in milliseconds from the first character received</li>
|
||||
<li>Wait to fill a fixed sized buffer</li></ul></p>
|
||||
<p>It then outputs <code>msg.payload</code> as either a UTF8 ascii string or a binary Buffer object.</p>
|
||||
<p><code>msg.port</code> is set to the name of the port selected.</p>
|
||||
<p>If no split character is specified, or a timeout or buffer size of 0, then a stream of single characters
|
||||
is sent - again either as ascii chars or size 1 binary buffers.</p>
|
||||
</script>
|
||||
|
@ -117,8 +117,8 @@ module.exports = function(RED) {
|
||||
this.port.on('data', function(msg) {
|
||||
// single char buffer
|
||||
if ((node.serialConfig.newline === 0)||(node.serialConfig.newline === "")) {
|
||||
if (node.serialConfig.bin !== "bin") { node.send({"payload": String.fromCharCode(msg)}); }
|
||||
else { node.send({"payload": new Buffer([msg])}); }
|
||||
if (node.serialConfig.bin !== "bin") { node.send({"payload": String.fromCharCode(msg), port:node.serialConfig.serialport}); }
|
||||
else { node.send({"payload": new Buffer([msg]), port:node.serialConfig.serialport}); }
|
||||
}
|
||||
else {
|
||||
// do the timer thing
|
||||
@ -133,7 +133,7 @@ module.exports = function(RED) {
|
||||
var m = new Buffer(i+1);
|
||||
buf.copy(m,0,0,i+1);
|
||||
if (node.serialConfig.bin !== "bin") { m = m.toString(); }
|
||||
node.send({"payload": m});
|
||||
node.send({"payload": m, port:node.serialConfig.serialport});
|
||||
m = null;
|
||||
}, node.serialConfig.newline);
|
||||
i = 0;
|
||||
@ -148,7 +148,7 @@ module.exports = function(RED) {
|
||||
var m = new Buffer(i);
|
||||
buf.copy(m,0,0,i);
|
||||
if (node.serialConfig.bin !== "bin") { m = m.toString(); }
|
||||
node.send({"payload":m});
|
||||
node.send({"payload":m, port:node.serialConfig.serialport});
|
||||
m = null;
|
||||
i = 0;
|
||||
}
|
||||
@ -161,7 +161,7 @@ module.exports = function(RED) {
|
||||
var n = new Buffer(i);
|
||||
buf.copy(n,0,0,i);
|
||||
if (node.serialConfig.bin !== "bin") { n = n.toString(); }
|
||||
node.send({"payload":n});
|
||||
node.send({"payload":n, port:node.serialConfig.serialport});
|
||||
n = null;
|
||||
i = 0;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"name" : "node-red-node-serialport",
|
||||
"version" : "0.6.4",
|
||||
"version" : "0.6.5",
|
||||
"description" : "Node-RED nodes to talk to serial ports",
|
||||
"dependencies" : {
|
||||
"serialport" : "^6.0.5"
|
||||
"serialport" : "^6.1.1"
|
||||
},
|
||||
"repository" : {
|
||||
"type":"git",
|
||||
|
Loading…
Reference in New Issue
Block a user