From 53ad00f1653970f223efa8b4634f95a1063cad90 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Thu, 27 Aug 2020 13:00:10 +0100 Subject: [PATCH] bump serialport dependency, add ja translation for baudrate message, fix linting, bump package --- io/serialport/25-serial.js | 50 +++++++++++----------- io/serialport/locales/en-US/25-serial.json | 2 +- io/serialport/locales/ja/25-serial.json | 2 +- io/serialport/package.json | 4 +- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/io/serialport/25-serial.js b/io/serialport/25-serial.js index 81f4fc0a..2d9b4f2c 100644 --- a/io/serialport/25-serial.js +++ b/io/serialport/25-serial.js @@ -41,19 +41,19 @@ module.exports = function(RED) { node.port = serialPool.get(this.serialConfig); node.on("input",function(msg) { - if (msg.hasOwnProperty("baudrate")) { - var baud = parseInt(msg.baudrate); - if (isNaN(baud)) { + if (msg.hasOwnProperty("baudrate")) { + var baud = parseInt(msg.baudrate); + if (isNaN(baud)) { node.error(RED._("serial.errors.badbaudrate"),msg); - } else { - node.port.update({baudRate: baud},function(err,res) { - if (err) { - var errmsg = err.toString().replace("Serialport","Serialport "+node.port.serial.path); - node.error(errmsg,msg); - } - }); - } - } + } else { + node.port.update({baudRate: baud},function(err,res) { + if (err) { + var errmsg = err.toString().replace("Serialport","Serialport "+node.port.serial.path); + node.error(errmsg,msg); + } + }); + } + } if (!msg.hasOwnProperty("payload")) { return; } // do nothing unless we have a payload var payload = node.port.encodePayload(msg.payload); node.port.write(payload,function(err,res) { @@ -135,18 +135,18 @@ module.exports = function(RED) { // Serial Out node.on("input",function(msg) { if (msg.hasOwnProperty("baudrate")) { - var baud = parseInt(msg.baudrate); - if (isNaN(baud)) { - node.error(RED._("serial.errors.badbaudrate"),msg); - } else { - node.port.update({baudRate: baud},function(err,res) { - if (err) { - var errmsg = err.toString().replace("Serialport","Serialport "+node.port.serial.path); - node.error(errmsg,msg); - } - }); - } - } + var baud = parseInt(msg.baudrate); + if (isNaN(baud)) { + node.error(RED._("serial.errors.badbaudrate"),msg); + } else { + node.port.update({baudRate: baud},function(err,res) { + if (err) { + var errmsg = err.toString().replace("Serialport","Serialport "+node.port.serial.path); + node.error(errmsg,msg); + } + }); + } + } if (!msg.hasOwnProperty("payload")) { return; } // do nothing unless we have a payload if (msg.hasOwnProperty("count") && (typeof msg.count === "number") && (node.serialConfig.out === "count")) { node.serialConfig.newline = msg.count; @@ -275,7 +275,7 @@ module.exports = function(RED) { return payload; }, write: function(m,cb) { this.serial.write(m,cb); }, - update: function(m,cb) { this.serial.update(m,cb); }, + update: function(m,cb) { this.serial.update(m,cb); }, enqueue: function(msg,sender,cb) { var payload = this.encodePayload(msg.payload); var qobj = { diff --git a/io/serialport/locales/en-US/25-serial.json b/io/serialport/locales/en-US/25-serial.json index f816b611..03ef70e6 100644 --- a/io/serialport/locales/en-US/25-serial.json +++ b/io/serialport/locales/en-US/25-serial.json @@ -67,7 +67,7 @@ "disconnected": "serial port __port__ disconnected", "closed": "serial port __port__ closed", "list": "Failed to list ports. Please enter manually.", - "badbaudrate": "Baudrate is not valid" + "badbaudrate": "Baudrate is invalid" } } } diff --git a/io/serialport/locales/ja/25-serial.json b/io/serialport/locales/ja/25-serial.json index 36bf27d1..647ed53c 100644 --- a/io/serialport/locales/ja/25-serial.json +++ b/io/serialport/locales/ja/25-serial.json @@ -52,7 +52,7 @@ "disconnected": "serial port __port__ disconnected", "closed": "serial port __port__ closed", "list": "ポートのリスト化に失敗しました。手動で入力してください。", - "badbaudrate": "Baudrate is not valid" + "badbaudrate": "ボーレートが不正です" } } } diff --git a/io/serialport/package.json b/io/serialport/package.json index d553ad75..d8f237ed 100644 --- a/io/serialport/package.json +++ b/io/serialport/package.json @@ -1,9 +1,9 @@ { "name" : "node-red-node-serialport", - "version" : "0.10.3", + "version" : "0.11.0", "description" : "Node-RED nodes to talk to serial ports", "dependencies" : { - "serialport" : "^8.0.8" + "serialport" : "^9.0.1" }, "repository" : { "type":"git",