Skip to content

Commit

Permalink
set registers in Flex Server
Browse files Browse the repository at this point in the history
Added the ability to set any Register in the Flex-Server for development / Slave simulation purpose
  • Loading branch information
opt-natter committed May 15, 2019
1 parent 3ff1573 commit 0acc26f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/modbus-flex-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2017,2018 Klaus Landsdorf (http://bianco-royal.de/)
All rights reserved.
node-red-contrib-modbus - The BSD 3-Clause License
@author <a href="mailto:klaus.landsdorf@bianco-royal.de">Klaus Landsdorf</a> (Bianco Royal)
**/
/**
Expand Down Expand Up @@ -126,19 +127,18 @@ module.exports = function (RED) {
node.startServer()

node.on('input', function (msg) {

if( msg.payload.register === 'holding'
|| msg.payload.register === 'coils'
|| msg.payload.register === 'input'
|| msg.payload.register === 'discrete'){

if (!(Number.isInteger(msg.payload.address) &&
msg.payload.address >= 0 &&
msg.payload.address <= 65535)) {
node.error('Address Not Valid', msg)
return
}
switch (type) {
switch (msg.payload.register) {
case 'holding':
node.registers.writeUInt16BE(msg.payload.value, (msg.payload.address + node.splitAddress) * node.bufferFactor)
break
Expand Down Expand Up @@ -182,5 +182,4 @@ module.exports = function (RED) {
} catch (err) {
internalDebugLog(err.message)
}

}
}

0 comments on commit 0acc26f

Please sign in to comment.