node-modbus icon indicating copy to clipboard operation
node-modbus copied to clipboard

Fix write-single-coil.ts incorrect processing of true value #338

Open yangit opened this issue 2 months ago • 1 comments

Fix for the #338 The WriteSingleCoilResponseBody constructor declares that it can handle boolen but it can not do that. So I have addled boolean handling into the function.

Manually tested for both true and false input.

I have tried to make commit a oneliner like so this._value = value === ( true || 0xFF00 ? 0xFF00 : 0x0000) But did not find it readable enough and did not like being dependent on parenthesis

I have not added any automated test for this fix because unfortunately I'm unable to properly run npm install neither on my mac nor on ubuntu, the SerialPort package fails to install and I have further issues with mocha (I did try to install that globally along with sinon).

Hope that helps!

yangit avatar Apr 20 '24 19:04 yangit