enocean-js / enocean-js

Creative Commons Zero v1.0 Universal
30 stars 11 forks source link

enocean-in node stops by TypeError etc #162

Open at6ue opened 4 years ago

at6ue commented 4 years ago

Context:

Possible Cause:

Case 1) Error message

Oct 12 19:14:46 raspberrypi Node-RED[392]: (node:392) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'src' of undefined
Oct 12 19:14:46 raspberrypi Node-RED[392]:     at RadioERP2.get senderId [as senderId] (/home/red/.node-red/node_modules/@enocean-js/esp3-packets/src/packet-types/RadioERP2.js:39:58)
...

RadioERP2.addressControl Property returns undefined when it refers ctrl array beyond its boundary, then RadioERP2.senderId fails.

Case 2) Error message

Dec  3 02:55:05 raspberrypi Node-RED[32218]: (node:32218) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'toString' of null
Dec  3 02:55:05 raspberrypi Node-RED[32218]:     at ESP3Transformer.EnoceanInNode.data (/home/red/.node-red/node_modules/node-red-contrib-enocean/nodes/enocean-in.js:37:29)
...

RORG.toString(16) in EnOceanInNode fails because array rorgs in RadioERP2.RORG has some null values. This can be reproduced by sending byte stream to serial port for instance,

55000A020A9B2B04000C358800FF093201328B

This example assumes that RORG A5-07-01 motion sensor telegram changed to 0b1011 (reserved) by environmental noise.

enocean-in node also stops by other exceptions caught in ESPParser, because EnOceanInNode does not catch any exceptions. The error message is like,

{ code: 2,
  name: 'WRONG_BODY_CHECKSUM',
  desc: 'data checksum test failed' }

PS. Thank you very much for making such a great project!

Holger-Will commented 4 years ago

sorry for the long wait... looking into this. can you post some more telegrams, please? i do not have access to a lot of RadioERP2 devices and this could help improve the quality of the ERP2 implementation!

at6ue commented 4 years ago

Hi @Holger-Will , I'm glad you're back! As far as I know your parser works perfect, except for some illegal telegrams. Do you mean you want some more illegal telegram examples?

Holger-Will commented 4 years ago

As far as I know your parser works perfect,

good to hear!

Do you mean you want some more illegal telegram examples?

yes please, i could integrate them in my tests.

at6ue commented 4 years ago

For Case 1, 55000A020A9B8204000C358800FF09B301328B This has the first "reserved" in the address control parameter, which is not implemented in the ctrl array.

For Case 2, that I already mentioned above 55000A020A9B2B04000C358800FF093201328B This has the first "reserved" in the telegram type parameter, which is defined as null in rorgs array.

For the last example, which has wrong CRC. 55000A020A9B8204000C358800FF09B30132FF Similar errors can be caused by the other exceptions declared in ESP3Parser as well.

Holger-Will commented 4 years ago

thanks! i might find some time next weekend to integrate error handling into "node-red-contrib-enocean" and include these telegrams in the testsuite.