klajo / wpi

An Erlang NIF for the WiringPi library for the Raspberry Pi
GNU Lesser General Public License v3.0
30 stars 10 forks source link

NIF does not load due to undefined symbol in wpi.c e.g. 'lcdPosition' and other issues in R17 #9

Open davidoccam opened 9 years ago

davidoccam commented 9 years ago

dear Klas,

using git 2.0a tag

NIF would not load so I put in a test for the error.

on_load() -> %% Force wiringPi to return -1 on initalization failure. In %% wiringPi this was not necessary, but starting at v2 the setup %% functions exit instead. a change between wiringPi v1 and v2. %% Use return values in order to provide more erlangy error handling. os:putenv("WIRINGPI_CODES", "true"), case erlang:load_nif(filename:join(code:priv_dir(wpi), "./wpi_drv"), 0) of ok->io:format("wpi on_load ok~n",[]); Error1->io:format("Error in wpi on_load ~p~n",[Error1]) end.

Error in wpi on_load {error, {load_failed, "Failed to load NIF library: '/home/pi/rcouch-newbuild/rel/rcouch/bin/../lib/wpi-0.1/priv/wpi_drv.so: undefined symbol: lcdPosition'"}}

The NIF load continued to fail similarly until I commented out wpi.c lines as follows

160-162 lcdInit 174 lcdHome 186 lcdClear 200 lcdPosition 213 lcdPutchar 231 lcdPuts 245 value=shiftIn..... 269 shiftOut

==> wpi (compile)

The NIF then loaded and worked as expected

(rcouch@127.0.0.1)1> wpi:setup_sys(). wpi on_load ok ok

perhaps I should be using master? It seems only lcd functions are affected and I am not using this so no real problem for me.

thanks for your sharing David Martin

davidoccam commented 9 years ago

dear Klas, I switched to master branch and all my perceived problems went away. I am using gpio binary and wpi:setup_sys(). and so far no root needed sorry to have raised false problems David Martin

klajo commented 9 years ago

Hi,

No worries. So everything is ok then?

Cheers, Klas