modbus icon indicating copy to clipboard operation
modbus copied to clipboard

Change input of WriteSingleCoil from uint16 to bool

Open cblauvelt opened this issue 7 years ago • 2 comments

Having the second input to Client.WriteSingleCoil be a boolean instead of a uint16 that requires either 0xFF00 or 0x0000 seems more intuitive. What would you think of this change?

cblauvelt avatar Mar 04 '17 18:03 cblauvelt

Thanks for your suggestion. I agree that a boolean may be better in this case, but I also would like to not change the API to make it backward compatible. I think uint16 is fine as that is what server will receive and respond. What do you think if I add ON and OFF constants (0xFF00 and 0x0000) instead?

nqv avatar Mar 06 '17 02:03 nqv

I think that would work fine. I was thinking of defining these in my own program as well but if it's in the library it wouldn't be necessary. I would also recommend that there be an example in the README.

cblauvelt avatar Mar 09 '17 23:03 cblauvelt