Skip to content

Commit

Permalink
enchance: Use node.client.connectUDP to support UDP type.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjinhuo committed Aug 26, 2024
1 parent 573764a commit dba1227
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 dba1227

Please sign in to comment.