Domoticz on NSA 325v2

Marvell Kirkwood based
Post Reply
skwere
Posts: 23
Joined: Sat May 09, 2015 7:12 pm

Domoticz on NSA 325v2

Post by skwere » Sat May 09, 2015 7:49 pm

Before explaining my problems with compiling Domoticz http://domoticz.com/ I need to inform you that I have very little experience with Linux and FFP. The experience I have I gathered from the method Google-trial-error-Google (which often led to this forum, a big thanks to all of you who shared your knowledge) at least resulted in a working Plex media server including Plexconnect-link to my Apple tv and a running FFP on my NSA325v2. After all my trial and error exercises, including breaking FFP (or slacker) by installing packages which did not run properly, I now have a clean FFP with proper packages installed on which I am trying to compile and install Domoticz.

I am trying to compile Domoticz using the instructions in the install.txt provided in the source code. My steps are 1. using SVN for the latest version, the use CMAKE to prepare the project using the provided CMakeLists, and then make the package. I am currently at the stage where this goes pretty well, compiling succeeds to 100% but then linking the files gives a lot of errors. As I can somewhat read and understand the error it has something to do with boost libraries. Below is the error text I copied from PuTTy, together with some information on the relevant packages currently installed in FFP. Unfortunately Google cannot help me anymore, so I am hoping some of you experts are able to push me into the right direction. Thanks for your help!

Installed packages (amongst others)
gcc 4.9.2
gcc-solibs 4.9.2
uClibc 0.9.33
uClibc solibs 0.9.33
Boost 1.49.0

Error message:
http://pastebin.com/GUUrrWsD

barmalej2
Posts: 2383
Joined: Sun Apr 29, 2012 5:24 pm

Re: Domoticz on NSA 325v2

Post by barmalej2 » Sat May 09, 2015 8:11 pm

Install libusb:

Code: Select all

slacker -UaA mz:libusb-1.0.9-arm-1.txz

skwere
Posts: 23
Joined: Sat May 09, 2015 7:12 pm

Re: Domoticz on NSA 325v2

Post by skwere » Sat May 09, 2015 8:16 pm

That one is installed, I just reinstalled it. I think I have all, or almost all, packages from Mijzelf and Fonz installed as a starting point.

barmalej2
Posts: 2383
Joined: Sun Apr 29, 2012 5:24 pm

Re: Domoticz on NSA 325v2

Post by barmalej2 » Sat May 09, 2015 8:47 pm

Then try these configure options:

Code: Select all

cmake . -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/ffp -DUSE_STATIC_BOOST=OFF -DLIBUSB_INCLUDE_DIR=/ffp/include -DLIBUSB_LIBRARY=/ffp/lib/libusb-1.0.so.0.1.0

skwere
Posts: 23
Joined: Sat May 09, 2015 7:12 pm

Re: Domoticz on NSA 325v2

Post by skwere » Sat May 09, 2015 8:58 pm

Did so, make is running now, will report back how this turned out. Thanks a lot for your effort so far.

skwere
Posts: 23
Joined: Sat May 09, 2015 7:12 pm

Re: Domoticz on NSA 325v2

Post by skwere » Sun May 10, 2015 11:06 am

That fixed the boost errors, only now I have a new problem with the usb setup I think. Here is the error message http://pastebin.com/zEKfMaUS.

Do I have to activate or link the usb drivers or something like that?

barmalej2
Posts: 2383
Joined: Sun Apr 29, 2012 5:24 pm

Re: Domoticz on NSA 325v2

Post by barmalej2 » Sun May 10, 2015 5:11 pm

I was a bit surprised, seeing that configuration process finds all libs except libsub. So I forced it manually, but actually it was wrong way. At least you got some info:
undefined reference to `usb_find_busses'
undefined reference to `usb_find_devices'
undefined reference to `usb_get_busses'
..............................................................
All these undefined references declarations does not belongs to libusb>1.0
They are from libusb<1.0, so called ​libusb-compat.
That means we used wrong library and that is why it fails to link.
You need to start all over again.
Install ​libusb-compat:

Code: Select all

slacker -a mz:libusb_compat-0.1.4-arm-1.txz
and configure with these options:

Code: Select all

cmake . -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/ffp -DUSE_STATIC_BOOST=OFF
This time autoconfiguration should find libusb itself.

barmalej2
Posts: 2383
Joined: Sun Apr 29, 2012 5:24 pm

Re: Domoticz on NSA 325v2

Post by barmalej2 » Mon May 11, 2015 10:30 am

Well, after 15 hours of compiling, domoticz build has finished on my NSA310. Hmm.. too long
Remark regarding source code of domoticz-prefix (in our case ffp) does not honored.

I have packaged test build and placed here:
http://downloads.zyxel.nas-central.org/ ... -arm-0.txz

Homedir is /ffp/opt/domoticz:
/ffp/opt/domoticz/domoticz --help
2015-05-11 13:10:58.933 Domoticz V2.2429 (c)2012-2015 GizMoCuz
2015-05-11 13:10:58.934 Startup Path: /e-data/aedfebd6-3d56-4344-8f80-b1ca60355017/ffproot/ffp/opt/domoticz/
2015-05-11 13:10:58.934 Usage: Domoticz -www port -verbose x
-www port (for example -www 8080)
-sslwww port (for example -sslwww 443)
-sslcert file_path (for example /opt/domoticz/server_cert.pem)
-wwwroot file_path (for example /opt/domoticz/www)
-dbase file_path (for example /opt/domoticz/domoticz.db)
-verbose x (where x=0 is none, x=1 is debug)
-startupdelay seconds (default=0)
-nowwwpwd (in case you forgot the web server username/password)
-log file_path (for example /var/log/domoticz.log)
-loglevel (0=All, 1=Status+Error, 2=Error)
-nocache (do not cache HTML pages (for editing)
-daemon (run as background daemon)
-syslog (use syslog as log output)

skwere
Posts: 23
Joined: Sat May 09, 2015 7:12 pm

Re: Domoticz on NSA 325v2

Post by skwere » Mon May 11, 2015 5:31 pm

It turned out I had some duplicate libusb install, after removing all installs, reinstalling both 1.0 and 0.1 packages the compiling finished completely. And even better, Domoticz is running stable. Thanks a lot for your help.

For those who also want to run domoticz, this is what I did:

Install all mz and fonz packages using slacker to setup the build environment (although probably all is a little overkill)

From the domoticz install.txt:

Getting the source code:
svn checkout svn://svn.code.sf.net/p/domoticz/code/trunk/ domoticz

cd domoticz

cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/ffp -DUSE_STATIC_BOOST=OFF CMakeLists.txt
make

now you should have the binary application, you can start it with
./domoticz

Compiling took around 2 hours on the NSA325v2


Only open items for me is to figure out how to start domoticz with NAS boot, and how to set the correct ttyUSB0 config for my P1 smartmeter (baud 9600, even parity, 7 databits, 1 stopbit).
Edit: using Minicom I managed to change the config and get proper output readings. Any tips to maintain this setup also after NAS reboot?

barmalej2
Posts: 2383
Joined: Sun Apr 29, 2012 5:24 pm

Re: Domoticz on NSA 325v2

Post by barmalej2 » Mon May 11, 2015 6:47 pm

As example of simple start script:

Code: Select all

#!/ffp/bin/sh

. /ffp/etc/ffp.subr

name="domoticz"
home_dir="/ffp/opt/domoticz"
command="$home_dir/$name"
required_dirs="$home_dir"
required_files="$command"
domoticz_flags="-www 8181 -sslwww 4444 -sslcert /ffp/opt/domoticz/server_cert.pem -log /ffp/var/log/domoticz.log -loglevel 1 -daemon"

run_rc_command "$1"
Name it domoticz.sh and place it to /ffp/start/ directory. File should be created with linux line endings.
Adjust path to directory, where you have put your domoticz binary.
Start it:

Code: Select all

sh /ffp/start/domoticz.sh start
Enable startup on NAS boot:

Code: Select all

chmod 755 /ffp/start/domoticz.sh
Disable startup:

Code: Select all

chmod 644 /ffp/start/domoticz.sh
BTW. Have you installed mz:zyxel_modules-2.6.31.8-arm-4.txz package?
Besides modules, this package has start-up script, which creates required ttyUSB nodes.

skwere
Posts: 23
Joined: Sat May 09, 2015 7:12 pm

Re: Domoticz on NSA 325v2

Post by skwere » Mon May 11, 2015 6:56 pm

Wow, thanks for the script, I really appreciate your efforts for creating a tailored solution! I will try to see if I can get it to work.

I have the zyxel_modules package installed, I even added some lines to have the USB serial drivers loaded at boot, which works. Only they load the default values for the connection, which is baud 9600 with 8 databits. My smartmeter output needs 7 databits in order to display the output correctly. Using cat /dev/ttyUSB* I get proper readings now by using Minicom to change the ttyUSB* config, only I think I will lose this settings at reboot due to the reloading of the drivers (and after messing up the settings the first time I was glad it did - trial and error methodology needs some luck 8-) )

Now I need to have the output loaded into Domoticz itself, but I think the Domoticz forum is a more appropriate location to go into that level of detail. I already received more help then I expected.

I am very happy Domoticz is running stable, and I hope other users can benefit from this thread.

Edit: script is, off course, running fine. Also I know now for sure that my Minicom changes are overwritten after reboot.
Edit 2: by updating the lockfile location in Minicom to an existing location the settings are maintained after reboot

skwere
Posts: 23
Joined: Sat May 09, 2015 7:12 pm

Re: Domoticz on NSA 325v2

Post by skwere » Sun May 17, 2015 8:16 pm

Ok, Domoticz itself is running for a week now. The application does not crash, however in the application's log I see messages over the eventsystem stopping, and a scheduler not working anymore. I have not looked yet into the why of these crashes.

I have been trying over the last week to get my P1 smart meter readings into Domiticz, but it does not show. When I read the /dev/ttyUSB0 in PuTTy I get the proper reading of the values. I have tried the latest beta version and the latest stable version of Domoticz, makes no difference. I got a tip from the Domoticz forum to add user pi to the dialout group using /dev/ttyUSB0, as this user is mentioned in the the Domoticz daemon. I did create such a user, but the dialout group does not exist. I created the dialout group, added pi as user, and linked the dialout group to ttyUSB0. This worked, until I reboot the NAS in order to have Domoticz run the values from the start.

I am not sure what to do now, and would like your advice.
a. abandon this project on the NSA325, and benefit of all the experience I gathered on a Raspberry Pi platform. Reason for this is that I just think that FFP itself is too far of of the RPI platform Domoticz initially is created for, and solving one problem would make other problems pop up due to this mismatch.
b. continue this project and turn this thread into usefull info for other NSA325 users. Problem here is that I am the one with in the end having a working system, but all knowledge has to come from more experienced users. I doubt anyone will continue solving someone elses problems without necessarily benefit from the solution. I am not sure I would myself.
c. see if some other domotica package (e.g. OpenRemote) will run, with possibly the same result as I have now: a partly working package.

What do you think?

barmalej2
Posts: 2383
Joined: Sun Apr 29, 2012 5:24 pm

Re: Domoticz on NSA 325v2

Post by barmalej2 » Mon May 18, 2015 8:20 pm

Well the choice is yours. If you have some free time, curiosity and willingness to finish it, then you can count to get some help here from me and hopefully from the others too. I see two problems from my side:
1. I am not sure that my experience is enough to help.
2. My free time will be very limited in the next two weeks. Most likely I will be able only on late evenings and not each day.

Still I think it is worth to try, because it seems to me, that you are near the finish line.

Speaking about you have discovered. It can't be permissions problem for now, because domoticz daemon is running with root privileges and it has full access to system.
I would read this Rene (Chimit) comment very carefully:
Besides that, Domoticz also stops reading the P1 meter if another process reads the same port at the same time. Even if just once (for testing or something). Domoticz needs to be restarted after that to allow for collecting data anew.
Does it nothing reminds to you?
Use

Code: Select all

sh /ffp/start/domoticz.sh restart
to restart domoticz daemon service.

skwere
Posts: 23
Joined: Sat May 09, 2015 7:12 pm

Re: Domoticz on NSA 325v2

Post by skwere » Mon May 18, 2015 8:43 pm

Thanks for your positive reply, I appreciate your willingness to help. It is a tough call, on one hand I don't want another device (Pi), on the other hand I am running out of willingness and patience as I spend hours and hours over the last days already with the same result after each try: nothing.

Good to know that I can eliminate the permission issue, or at least for now.

Then next, multiple processes reading ttyUSB0. To rule this out I already rebooted the NAS several times (I did not even think about only restarting the daemon), and this made no difference. For further testing I just restarted the daemon, no result in Domiticz. Within Domoticz I then disabled and enabled the P1 smart meter, again without result except for the eventsystem error. Is there a way to check which processes are reading ttyUSB0? The only thing I could think of is Minicom for setting the proper readout configuration, but after restarting the daemon this should no longer be an issue while I still do not get a reading in Domiticz..

Btw I do not expect instant replies on this issue at all, I do not have a lot of time during weekdays to mess with the NAS myself.

Instant update: looking at the P1MeterSerial.h it seems that my Minicom settings are not required for Domoticz, only hardware flowcontrol is not enabled by default all other settings are correct for my setup.

barmalej2
Posts: 2383
Joined: Sun Apr 29, 2012 5:24 pm

Re: Domoticz on NSA 325v2

Post by barmalej2 » Tue May 19, 2015 4:36 am

skwere wrote: Is there a way to check which processes are reading ttyUSB0?
Use

Code: Select all

lsof /dev/ttyUSB0
for that purpose.

Code: Select all

lsof /dev/ttyUSB*
might show for all ttyUSB's.

Post Reply