Cloud-Automation / node-modbus

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

Fixes #199 – RTU CRC failed because of typo bodyCount => byteCount #200

Closed martijnthe closed 6 years ago

martijnthe commented 6 years ago

When using Node 10, the expected CRC value in the test case itself also did not match the actual value. I also changed the value to be able to detect byte swaps.

This wasn't caught before because:

  1. Node 8's implementation of Buffer.prototype.readUInt16BE returns 0 when NaN is passed. See https://github.com/Cloud-Automation/node-modbus/issues/199#issuecomment-401561941. This is fixed in later versions of Node (I was using Node 10), but in Travis, only up to 8 is being tested.
  2. The test expectation was all zeroes, matching the return value when NaN was passed when using Node 8.
stefanpoeter commented 6 years ago

Thanks for that

stefanpoeter commented 6 years ago

Since there are some minor fixes in 3.0.1 regarding rtu i'll gonna setup a RTU test environment in my office and see that 3.0.1 can be released. Again thanks for you work.