From dba12270e00880b79e613e78c1bdbc4a40254ae2 Mon Sep 17 00:00:00 2001 From: chenjinhuo <13926930429@139.com> Date: Mon, 26 Aug 2024 09:25:19 +0800 Subject: [PATCH] enchance: Use `node.client.connectUDP` to support UDP type. --- src/modbus-client.html | 1 + src/modbus-client.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/modbus-client.html b/src/modbus-client.html index e6b2cf3b..a111d450 100644 --- a/src/modbus-client.html +++ b/src/modbus-client.html @@ -256,6 +256,7 @@ + diff --git a/src/modbus-client.js b/src/modbus-client.js index 6e15f96e..f030e357 100644 --- a/src/modbus-client.js +++ b/src/modbus-client.js @@ -372,6 +372,17 @@ module.exports = function (RED) { return false }) break + case 'UDP': + verboseLog('UDP port') + node.client.connectUDP(node.tcpHost, { + port: node.tcpPort, + autoOpen: true + }).then(node.setTCPConnectionOptions) + .catch((err) => { + node.modbusTcpErrorHandling(err) + return false + }) + break default: verboseLog('TCP port') node.client.connectTCP(node.tcpHost, {