Closed davidonet closed 6 years ago
It is indeed confusing. I'll always used it this way, there was an issue some time back that adressed this issue too. I'll try to avoid this in the v3 release.
How can I avoid collision between a ReadInput(0x00) and a ReadDiscrete(0x00) ?
If you want to do it right then I would make a pull request and replace the input buffer with a new discrete buffer. That way you are fine.
Yes please :-)
Sorry for the long delay. Can you confirm that this is working the way you wanted it?
I've seen a pull request that seems to fix it : https://github.com/Cloud-Automation/node-modbus/pull/154 But it doesn't seem to be integrated in the current master branch : https://github.com/Cloud-Automation/node-modbus/blob/1cc5a9088a904c60470ac865c4ab2d24445cf655/src/handler/server/ReadDiscreteInputs.js#L38 There is still a getInput buffer in the ReadDiscreteInput.
Yes, you need to confirm that the pull request fixed the issue before I merge it into the master branch.
I don't know how to test it, I tried to fork the project but I can't merge the pull request in my fork.
I figure how it can be done locally : https://help.github.com/articles/checking-out-pull-requests-locally/
Yes it works Input buffer and Discrete buffer are distinct. tested with
// in SimpleServer
this.getInput().writeUInt16BE(0xff,0)
this.getDiscrete().writeUInt8(0xaa,0)
and on clientside
$ node ReadDiscreteInput.js localhost 8888 0 1
2017-11-07T11:57:45.570Z 'DEBUG :' 'init' 'connect'
2017-11-07T11:57:45.572Z 'DEBUG :' 'connect' 'connect'
2017-11-07T11:57:45.577Z 'DEBUG :' 'connect' 'ready'
2017-11-07T11:57:45.577Z 'DEBUG :' 'Trying to flush data.'
2017-11-07T11:57:45.577Z 'DEBUG :' 'ready' 'waiting'
2017-11-07T11:57:45.577Z 'DEBUG :' 'Sending pdu to the socket.'
2017-11-07T11:57:45.578Z 'DEBUG :' 'Data flushed.'
2017-11-07T11:57:45.583Z 'DEBUG :' 'received data'
2017-11-07T11:57:45.583Z 'DEBUG :' 'PDU extracted'
2017-11-07T11:57:45.583Z 'DEBUG :' 'received data'
2017-11-07T11:57:45.584Z 'DEBUG :' 'handling read discrete inputs response.'
2017-11-07T11:57:45.584Z 'DEBUG :' 'waiting' 'ready'
2017-11-07T11:57:45.585Z 'DEBUG :' 'Trying to flush data.'
2017-11-07T11:57:45.585Z 'DEBUG :' 'Nothing in request pipe.'
{ fc: 2,
byteCount: 2,
payload: <Buffer aa 00>,
coils:
[ false,
true,
false,
true,
false,
true,
false,
true,
false,
false,
false,
false,
false,
false,
false,
false ] }
2017-11-07T11:57:45.588Z 'DEBUG :' 'Closing client on purpose.'
2017-11-07T11:57:45.591Z 'DEBUG :' 'Socket closed with error' false
2017-11-07T11:57:45.591Z 'DEBUG :' 'ready' 'closed'
2017-11-07T11:57:45.591Z 'DEBUG :' 'Clearing timeout of the current request.'
2017-11-07T11:57:45.592Z 'DEBUG :' 'Cleaning up request fifo.'
$ node ReadInputRegister.js localhost 8888 0 1
2017-11-07T11:58:19.192Z 'DEBUG :' 'init' 'connect'
2017-11-07T11:58:19.194Z 'DEBUG :' 'connect' 'connect'
2017-11-07T11:58:19.198Z 'DEBUG :' 'connect' 'ready'
2017-11-07T11:58:19.199Z 'DEBUG :' 'Trying to flush data.'
2017-11-07T11:58:19.199Z 'DEBUG :' 'ready' 'waiting'
2017-11-07T11:58:19.199Z 'DEBUG :' 'Sending pdu to the socket.'
2017-11-07T11:58:19.199Z 'DEBUG :' 'Data flushed.'
2017-11-07T11:58:19.202Z 'DEBUG :' 'received data'
2017-11-07T11:58:19.203Z 'DEBUG :' 'PDU extracted'
2017-11-07T11:58:19.203Z 'DEBUG :' 'received data'
2017-11-07T11:58:19.203Z 'DEBUG :' 'handling read input registers response.'
2017-11-07T11:58:19.204Z 'DEBUG :' 'waiting' 'ready'
2017-11-07T11:58:19.204Z 'DEBUG :' 'Trying to flush data.'
2017-11-07T11:58:19.204Z 'DEBUG :' 'Nothing in request pipe.'
{ fc: 4,
byteCount: 2,
payload: <Buffer 00 ff>,
register: [ 255 ] }
2017-11-07T11:58:19.207Z 'DEBUG :' 'Closing client on purpose.'
2017-11-07T11:58:19.209Z 'DEBUG :' 'Socket closed with error' false
2017-11-07T11:58:19.209Z 'DEBUG :' 'ready' 'closed'
2017-11-07T11:58:19.209Z 'DEBUG :' 'Clearing timeout of the current request.'
2017-11-07T11:58:19.209Z 'DEBUG :' 'Cleaning up request fifo.'
Can you also copy the output from the command line. Thanks.
done
Thanks, I'll merge it soon then.
Sorry for the long delay, v2.4.0 has been released.
Why does ReadDiscrete use Input Buffer it's a bit confusing ?
https://github.com/Cloud-Automation/node-modbus/blob/321f71f15ad7f6516665bd7cc755a71232fba1b8/src/handler/server/ReadDiscreteInputs.js#L38
I can't find getDiscrete method.