maxwellhadley / node-red-contrib-rfxcom

node-RED nodes to access an RFXtrx433 transceiver
BSD 2-Clause "Simplified" License
22 stars 13 forks source link

"offset" is not an integer got "NaN" #92

Closed svefro closed 4 years ago

svefro commented 4 years ago

Updated node-red and all my contrib nodes today and got this strange error:

Serial port not open 2020-03-15 21:51:29.819 [rfxcom] on /dev/ttyUSB0 - Dropped : 0D,00,00,00,00,00,00,00,00,00,00,00,00,00 15 Mar 21:51:30 - [info] [rfx-detector-in:654c11f7.16e65] connecting to /dev/ttyUSB0 2020-03-15 21:51:30.310 [rfxcom] on /dev/ttyUSB0 - RFXtrx433 disconnected from /dev/ttyUSB0 2020-03-15 21:51:30.311 [rfxcom] on /dev/ttyUSB0 - Cleared command message queue 15 Mar 21:51:30 - [info] [rfx-detector-in:654c11f7.16e65] disconnected: "offset" is not an integer got "NaN"

Tried downgrading to node-red-contrib-rfxcom@2.9.1 but the same error persisted.

Running node v12.16.1 on a raspberry pi 2 that is controlling my entire house. I'm using node-red-contrib-rfxcom for all my lights and some temperature sensors so it is quite annoying that it does not work after the update.

Do you have any idea what can cause this error? rfxcom is connected to /dev/ttyUSB0

tried running "minicom -b 9600 -o -D /dev/ttyUSB0" and got some data when pressing a button on a 433 remote so it seems that the serial port is working.

i have tried to clear my flows.json file and set up a new flow with a rfx-lights node and it produces the same error: "offset" is not an integer got "NaN"

Could not find a forum to post to so posting here.

Any idea what might cause this?

maxwellhadley commented 4 years ago

The first two messages mean the serial port was closed unexpectedly (by something else), which causes the node to become disconnected. The "offset" is not an integer got "NaN" message I'm not sure about - I think there may be an error somewhere in the code that handles errors, at some level in the function stack. I'll investigate further as soon as I get time.

I don't know why the serial port should vanish like that - it may be a newly-introduced bug in Serialport, since it works with minicom. Can you please check what version of serialport the node is using?

svefro commented 4 years ago

Thanks for looking in to this. I relay appreciate it.

I tested creating a node sample app that looks like this: ` var rfxcom = require('rfxcom'); var rfxtrx = new rfxcom.RfxCom("/dev/ttyUSB0", {debug: true});

rfxtrx.on("lighting4", function (evt) { console.log(evt) });

rfxtrx.initialise(function () { console.log("Device initialised"); }); `

It get's access to the port right away and starts showing received messages from rfxcom, even if node red is running. (and the node-red-log window spams the same error message as before)

I tried installing node-red and setting up a new flow on another raspberry pi and it works fine. So it seems that it is something with my environment on my home pi that is causing this.

I have also tried deleting the node_modules folder and doing a "npm install", same error afterwards.

serialport@8.0.7 and rfxcom@2.1.1 is installed in ".node-red"

i do not know where to start tracking down the "offset" is not an integer got "NaN" error.

is there a way of getting the file and line position of where the the error originates?

maxwellhadley commented 4 years ago

I've been using serialport 8.0.5. I'll try 8.0.7 and see if I can duplicate the issue. But if your sample app connects correctly (while node red doesn't) then it looks like serialport is not the root cause

svefro commented 4 years ago

i deleted node_modules and package.json plus most files in ".node-red". After this i tested with only the basic nodes and got it working. Then restored my flows.json file and installed all the missing modules one by one. Eventually i had all the required nodes installed and everything is working.

I don't know what to make of this but i got rid of a whole bunch of unused nodes in the process.

maxwellhadley commented 4 years ago

Very strange - however, I think there is still an error in the error handling giving rise to the "offset" is not an integer message so I am reopening the issue

maxwellhadley commented 4 years ago

No luck tracking this down, I haven't been able to reproduce the problem: I will close the issue - that should provoke it to happen again!