tyrrellsystems / node-red-contrib-serial-modbus

This node is now maintained from @leifnel's fork
https://github.com/leifnel/node-red-contrib-serial-modbus
Apache License 2.0
7 stars 13 forks source link

Pull request needs to be committed for module to be able to be built. #25

Closed leifnel closed 5 years ago

leifnel commented 5 years ago

I'm trying to install on a new raspberry

When building serialport, I got a lot of warnings, then this error:

^~~~ ../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Drain(Nan::NAN_METHOD_ARGS_TYPE)’: ../src/serialport.cpp:585:29: error: no matching function for call to ‘v8::Value::ToInt32()’ int fd = info[0]->ToInt32()->Int32Value();

I think this mentions the issue: @basvdijk serialport@4.0.7 was released in December 2016 and is fairly old. It supports Node.js v8 but doesn't support Node.js v10. For Node.js v10 support please upgrade to serialport@6.2.2.

leifnel commented 5 years ago

I forked, changed the package.json to "dependencies": { "bluebird": "^3.4.1", "modbus-serial": "^4.5.1", "serialport": "^6.2.2" or 7.0.1

With both versions I got the error

[modbusSerialConfig:4c4900d2.bfe69] Error: TypeError: this._client.isOpen is not a function

leifnel commented 5 years ago

Tried setting all dependencies to newest version.

Then I get this error:

[modbusSerialConfig:4c4900d2.bfe69] Error: Error: Unexpected data error, expected 10 got 10

leifnel commented 5 years ago

In /node_modules/modbus-serial/index.js, line 308 I expanded the check

`if (address !== transaction.nextAddress || code !== transaction.nextCode) {
      error = "Unexpected data error, expected " +
              transaction.nextAddress + "/" + transaction.nextCode +" got " +
                    address + "/" + code+ "   "+
                    (typeof transaction.nextAddress) + "/" + (typeof transaction.nextCode) +" got " +
                    (typeof address) + "/" + (typeof code);
                if (transaction.next)
                    transaction.next(new Error(error));
                return;
            }`

[modbusSerialConfig:4c4900d2.bfe69] Error: Error: Unexpected data error, expected 10/3 got 10/3 string/number got number/number

this means that transaction.nextAddress is a string, but a number is expected.

leifnel commented 5 years ago

As a cruddy patch to get the stuff running, I added this before the check above:

if (typeof transaction.nextAddress === "string") { transaction.nextAddress = parseInt(transaction.nextAddress, 10); } Of course this is not a permanent solution.

leifnel commented 5 years ago

Pull request #26 fixes this.

hardillb commented 5 years ago

Closing this as v0.0.11 now deployed and maintenance of this node migrated to @leifnel