jdcaprace / signalk-raspberry-pi-ina219

SignalK node server plugin that reads data from ina219 current/voltage/power sensors on Raspberry-Pi
MIT License
4 stars 2 forks source link

signalk-raspberry-pi-ina219 plugin issue #2

Open RichFind opened 2 years ago

RichFind commented 2 years ago

I keep getting the following messages in the Server Log, debug is not turned on. There are two problems, the TypeError, and the the values are being displayed in the Server Log repeatedly. The values displayed in the Data Browser look good as well as the values in the Server Log. Aug 07 16:58:23 TypeError: Cannot read properties of undefined (reading 'catch') at Timeout.readina219 [as _onTimeout] (/home/pi/.signalk/node_modules/signalk-raspberry-pi-ina219/index.js:128:7) Aug 07 16:58:25 Bus voltage (V): 0 Aug 07 16:58:25 Shunt voltage (mV): -0.42 Aug 07 16:58:25 Shunt Current (mA): -8.4 Aug 07 16:58:25 Load Current (A): -0.008400000000000001 Aug 07 16:58:25 Load voltage (V): -0.00041999999999999996 TIA

jakobdalsgaard commented 1 year ago

I get the same :-) also I always run SignalK on my boat and it becomes unreponsive due to too many open filedescriptors; this plugin is leaking filedescriptors. I suspect that this line is wrong:

https://github.com/jdcaprace/signalk-raspberry-pi-ina219/blob/master/index.js#L128

      .catch((err) => {                                                             
      console.log(`ina219 read error: ${err}`);          
      });             

However due to the previous lines being commented out, this falls back to being a method call on:

        app.handleMessage(plugin.id, delta)

that according to this:

https://github.com/SignalK/signalk-server/blob/master/src/interfaces/plugins.ts#L93

returns void -- i.e. it's trying to call .catch on void -- won't work.

However I'm a bit unsure of why the lines have been commented out ...

jakobdalsgaard commented 1 year ago

I moved the line https://github.com/jdcaprace/signalk-raspberry-pi-ina219/blob/master/index.js#L100 to outside the ina219 function (and removed the async keyword) this fixed the bleeding of filedescriptors.