Cloud-Automation / node-modbus

Modbus TCP Client/Server implementation for Node.JS
466 stars 174 forks source link

Accessing the resp components in a key:value manner #153

Closed sergiupienar closed 6 years ago

sergiupienar commented 6 years ago

What methods are available on the resp object, e.g. is there any way of getting the value in a nice way ?

{ fc: 3, byteCount: 20, payload: <Buffer 00 15 00 64 00 5a 00 64 00 c8 00 64 00 c8 00 00 00 00 00 00>, register: [ 21, 100, 90, 100, 200, 100, 200, 0, 0, 0 ] }

Are there any getters for fc, byteCount, etc ?

stefanpoeter commented 6 years ago

why do you want to have getters?

sergiupienar commented 6 years ago

When dealing with the response that comes after a read request (be it on coils, registers, etc) it would be handy to fetch the payload in a nicer manner - i.e. resp.getPayload(), resp.getRegister().

stefanpoeter commented 6 years ago

i disagree, the response is a simple json object, the easiest form to store complex data in javascript. I don't see any need to prototype the response with getters and setters. If you were using es5-class-getter the syntax would be exactly the same (resp.payload and resp.register)