Skip to content

Commit

Permalink
Merge pull request #490 from Hammer2014/master
Browse files Browse the repository at this point in the history
enchance: Use `node.client.connectUDP` to support UDP type.
  • Loading branch information
biancode authored Nov 2, 2024
2 parents 7cf303e + dba1227 commit 1c4f5e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/modbus-client.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
<option value="TCP-RTU-BUFFERED">RTU-BUFFERED</option>
<option value="TELNET">TELNET</option>
<option value="C701">C701</option>
<option value="UDP">UDP</option>
</select>
</div>
</div>
Expand Down
11 changes: 11 additions & 0 deletions src/modbus-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 1c4f5e3

Please sign in to comment.