Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to initialise Energenie ENER314-RT board error: -1 #14

Closed
red-kooga opened this issue Jan 3, 2020 · 24 comments
Closed

Unable to initialise Energenie ENER314-RT board error: -1 #14

red-kooga opened this issue Jan 3, 2020 · 24 comments

Comments

@red-kooga
Copy link

hi, i have tried two different boards on pi zero and pi b, neither initialise the board, i have enabled spi with raspi-config.
debug reports: "Unable to initialise Energenie ENER314-RT board error: -1"
and "TypeError: Cannot read property 'push' of undefined"
the red and green do light when node is added to palette.
when teaching socket i get error something went wrong teaching the device.

thanks

@Achronite
Copy link
Owner

Achronite commented Jan 4, 2020

Error -1 is caused by either the version of the radio returning less than 36 via SPI, or it could be caused by a mutex locking issue. The former may be caused by different SPI pin assignments on the zero or Pi B. Can you confirm which version of the boards you have?

Is there anything else output in the node-red-log ?

Have you had any success outside of node-red and this module?

How are your editing/compiling skills? I can send you instructions on how to enable debug to diagnose this further.

@red-kooga
Copy link
Author

I am using pi zero and pi model B, i have just tried moving sd card from the zero to model B3+ because i couldn't install on B3, same errors.
I haven't tried any other means to test the ENER314-RT., I will look for RFM69 examples.
I haven't much experience compiling but willing to try.

@red-kooga
Copy link
Author

tried on pi B again these are the errors when control node is deployed:

05/01/2020, 09:27:14
msg : string[57]
"Unable to initialise Energenie ENER314-RT board error: -1"
05/01/2020, 09:27:14node: ENER314-RT
msg : error
"TypeError: Cannot read property 'push' of undefined"
05/01/2020, 09:27:14node: test_!
msg : error
"TypeError: libradio.radio_init is not a function"

lsmod shows:
spi_bcm2835 20480 0

@Achronite
Copy link
Owner

Achronite commented Jan 5, 2020

Strange - looks like it is not finding the C functions via the library that this version uses known as 'ref'. This library has unfortunately been deprecated, and is known not to work under node v12+ and node-red v1.+

What version of node and node-red are you using?

I have a new version which has had a substantial rewrite and is currently undergoing test (see my develop branch) which removes the dependency on 'ref', and also introduces support for the thermostatic radiator valves. I hope to release this soon as v0.3 after I have tidied up the code.

In the meantime if you did want to try and run a debug version of the v0.2 code do the following as user 'pi':
$ cd ~/.node-red/node_modules/node-red-contrib-energenie-ener314rt/C/energenie
edit file 'C/energenie/trace.h', and remove the '//' in front of the line '#define TRACE_POSIX'
recompile the C code by typing:
$ node-gyp rebuild
restart node-red (something like: node-red-stop, node-red-start)

if you don't have node-gyp installed, you can install it via npm: $ sudo npm install -g node-gyp

@red-kooga
Copy link
Author

i am running v1.0.3, i will try and recompile early next week

@Achronite
Copy link
Owner

I think this error is probably due to 'ref' and 'ffi' being deprecated then, you need to wait for v0.3. I'm in final test with it now.
Duplicate issue of #7

@red-kooga
Copy link
Author

Thanks, I wait for new release

@Achronite
Copy link
Owner

New version is now released, please let me know if it fixes your issue

@red-kooga
Copy link
Author

red-kooga commented Jan 11, 2020 via email

@Achronite
Copy link
Owner

Achronite commented Jan 11, 2020

Can you please check the version of node? (node -v) It needs to be at least v10.

I've put together a quick test program for you to try outside of node-red (with debug enabled), you can find it here: https://github.com/Achronite/ener314rt-debug

Please node-red-stop first if you have my node installed.

@red-kooga
Copy link
Author

red-kooga commented Jan 12, 2020 via email

@Achronite
Copy link
Owner

Achronite commented Jan 12, 2020

Please try the debug stand-alone program that I created for you. https://github.com/Achronite/ener314rt-debug.

And paste the log.

I have an old Model B too somewhere...

@red-kooga
Copy link
Author

red-kooga commented Jan 12, 2020 via email

@Achronite
Copy link
Owner

OK the unexpected radio version is a clue. The device is not being recognised. It could be a problem accessing the SPI driver, the board is faulty or is not installed correctly. It is definitely the ENER314-RT that you are using? (the one with the gold coil on top).

Do the red and green lights flash quickly when the program starts?

image

@red-kooga
Copy link
Author

red-kooga commented Jan 12, 2020 via email

@Achronite
Copy link
Owner

Achronite commented Jan 12, 2020

I'll check with the person who wrote the original SPI driver that I use for this to see if there are any known issues with your config.

I'll dig out my old Pi B to see if I can replicate your issue, what version of buster are you running?

@Achronite Achronite reopened this Jan 12, 2020
@Achronite
Copy link
Owner

Achronite commented Jan 12, 2020

OK, been taking a look at the issue list with the SPI driver, a similar issue to yours where radiover was returning 0: whaleygeek/pyenergenie#82 and whaleygeek/pyenergenie#119 Can you take a look through these threads? particularly the bits around hardware SPI driver being disabled?

@Achronite
Copy link
Owner

Achronite commented Jan 12, 2020

Sorry about triple post :)

I've tried to reproduce your issue, I downloaded raspbian buster, ran etcher and then booted up my old Pi model B.
The program ran OK, without any changes, so I'm really not sure what is going on for you! Maybe it is faulty hardware?

`pi@raspberrypi:~ $ wget https://github.com/Achronite/ener314rt-debug/archive/master.zip
--2020-01-12 18:35:54-- https://github.com/Achronite/ener314rt-debug/archive/master.zip
Resolving github.com (github.com)... 140.82.118.3
Connecting to github.com (github.com)|140.82.118.3|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/Achronite/ener314rt-debug/zip/master [following]
--2020-01-12 18:35:55-- https://codeload.github.com/Achronite/ener314rt-debug/zip/master
Resolving codeload.github.com (codeload.github.com)... 140.82.113.10
Connecting to codeload.github.com (codeload.github.com)|140.82.113.10|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/zip]
Saving to: âmaster.zipâ

master.zip [ <=> ] 48.46K 295KB/s in 0.2s

2020-01-12 18:35:56 (295 KB/s) - âmaster.zipâ saved [49618]

pi@raspberrypi:~ $ unzip master.zip
Archive: master.zip
a5f38bfa6782fa72dacc5c802ad8734d4e216c49
creating: ener314rt-debug-master/
inflating: ener314rt-debug-master/.gitignore
creating: ener314rt-debug-master/C/
creating: ener314rt-debug-master/C/achronite/
inflating: ener314rt-debug-master/C/achronite/lock_radio.c
inflating: ener314rt-debug-master/C/achronite/lock_radio.h
inflating: ener314rt-debug-master/C/achronite/napi_energenie.c
inflating: ener314rt-debug-master/C/achronite/ook_send.c
inflating: ener314rt-debug-master/C/achronite/ook_send.h
inflating: ener314rt-debug-master/C/achronite/openThings.c
inflating: ener314rt-debug-master/C/achronite/openThings.h
creating: ener314rt-debug-master/C/energenie/
inflating: ener314rt-debug-master/C/energenie/LICENSE
inflating: ener314rt-debug-master/C/energenie/delay.h
inflating: ener314rt-debug-master/C/energenie/delay_posix.c
inflating: ener314rt-debug-master/C/energenie/gpio.h
inflating: ener314rt-debug-master/C/energenie/gpio_rpi.c
inflating: ener314rt-debug-master/C/energenie/hrfm69.c
inflating: ener314rt-debug-master/C/energenie/hrfm69.h
inflating: ener314rt-debug-master/C/energenie/radio.c
inflating: ener314rt-debug-master/C/energenie/radio.h
inflating: ener314rt-debug-master/C/energenie/spi.h
inflating: ener314rt-debug-master/C/energenie/spis.c
inflating: ener314rt-debug-master/C/energenie/system.h
inflating: ener314rt-debug-master/C/energenie/trace.h
inflating: ener314rt-debug-master/LICENSE
inflating: ener314rt-debug-master/README.md
inflating: ener314rt-debug-master/binding.gyp
inflating: ener314rt-debug-master/test.js
pi@raspberrypi:~ $ cd ener314*
pi@raspberrypi:~/ener314rt-debug-master $ node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@10.15.2 | linux | arm
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/share/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/pi/ener314rt-debug-master/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/share/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/include/nodejs/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/usr/include/nodejs',
gyp info spawn args '-Dnode_gyp_dir=/usr/share/node-gyp',
gyp info spawn args '-Dnode_lib_file=/usr/include/nodejs/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/pi/ener314rt-debug-master',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/pi/ener314rt-debug-master/build'
CC(target) Release/obj.target/ener314rt/C/achronite/napi_energenie.o
CC(target) Release/obj.target/ener314rt/C/achronite/lock_radio.o
CC(target) Release/obj.target/ener314rt/C/achronite/ook_send.o
CC(target) Release/obj.target/ener314rt/C/achronite/openThings.o
CC(target) Release/obj.target/ener314rt/C/energenie/radio.o
CC(target) Release/obj.target/ener314rt/C/energenie/hrfm69.o
CC(target) Release/obj.target/ener314rt/C/energenie/spis.o
CC(target) Release/obj.target/ener314rt/C/energenie/gpio_rpi.o
CC(target) Release/obj.target/ener314rt/C/energenie/delay_posix.o
SOLINK_MODULE(target) Release/obj.target/ener314rt.node
COPY Release/ener314rt.node
make: Leaving directory '/home/pi/ener314rt-debug-master/build'
gyp info ok
pi@raspberrypi:~/ener314rt-debug-master $ node test.js
napi_energenie.Init() called
radio-test: Initialising
init_ener314(): initialising
init_ener314(): mutex created & locked
radio_init
radio_ver=36
radio_standby
_wait_ready
radio_standby
_wait_ready
radio-test: N-API radio_init returned 0
radio-test: switching 1:1:true
ook_send: Zone=1, Switch=1, state=1
_wait_ready
radio_mod_transmit()
_wait_ready
_wait_txready
radio_send_payload(): 20 tx payloads
|||||||||||||||||||*|**_wait_ready
radio-test: switching 1:1:false
ook_send: Zone=1, Switch=1, state=0
radio_mod_transmit()`

@red-kooga
Copy link
Author

red-kooga commented Jan 12, 2020 via email

@red-kooga
Copy link
Author

after looking at the issue with pyenergenie i disabled spi rebooted and ran the test and it worked, but still error with node red on pi zero "TypeError: Cannot read property 'push' of undefined", and something went wrong teaching device.
i will try a fresh install of buster tomorrow on pi 3.
thanks
pi@raspberrypi:~/ener314rt-debug $ node test.js
napi_energenie.Init() called
radio-test: Initialising
init_ener314(): initialising
init_ener314(): mutex created & locked
radio_init
radio_ver=36
radio_standby
_wait_ready
radio_standby
_wait_ready
radio-test: N-API radio_init returned 0
radio-test: switching 1:1:true
ook_send: Zone=1, Switch=1, state=1
_wait_ready
radio_mod_transmit()
_wait_ready
_wait_txready
radio_send_payload(): 20 tx payloads
||
||||**|||||||**|||||||_wait_ready
radio-test: switching 1:1:false
ook_send: Zone=1, Switch=1, state=0
radio_mod_transmit()
_wait_ready
_wait_txready
radio_send_payload(): 20 tx payloads
||
|||*|
||||||**|||||||**|_wait_ready
openthings_deviceList(): called
@openThings_devicePut() device added: 0:6195
openthings_deviceList(): Returning: {"numDevices":1, "devices":[
{"mfrId":4,"productId":3,"deviceId":6195,"control":2,"product":"Radiator Valve","joined":1}]}
radio-test: deviceList={"numDevices":1, "devices":[
{"mfrId":4,"productId":3,"deviceId":6195,"control":2,"product":"Radiator Valve","joined":1}]}
radio-test: switching 1:1:true
ook_send: Zone=1, Switch=1, state=1
radio_mod_transmit()
_wait_ready
_wait_txready
radio_send_payload(): 20 tx payloads
||||||*|||||||**||||||**|*_wait_ready
^C

@Achronite
Copy link
Owner

Achronite commented Jan 13, 2020

Excellent news! Glad to see that we got to the bottom of that, I'll close this issue with an update that documents the fix in the README and produces a better error message from the node.

I believe that I fixed the 'push' error in v0.3 of my node-red node, are you running this version?

@red-kooga
Copy link
Author

i am running v0.3, the only error i get now is with ook teaching "something went wrong teaching device", iv'e managed to teach ook devices by setting a zone and then injecting a 1 and then i can control the socket with injecting boolean true or false.

@Achronite
Copy link
Owner

OK I'll take a look at the teaching error. It effectively does the same as sending a true anyway. It's probably something that I broke with the move to the new library.

@Achronite
Copy link
Owner

Achronite commented Jan 17, 2020

Just released v0.3.2 node, this should close all your issues, including the teach error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants