Cloud-Automation / node-modbus

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

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

Open yangit opened 5 months ago

yangit commented 5 months ago

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!

stefanpoeter commented 4 months ago

Hi @yangit, thank you for your commitment. This needs to be tested in the unit test. Can you provide a test?

stefanpoeter commented 3 weeks ago

Would be great I you provide a test for this.