Error when running on Synology NAS

Topics: 5. Support
Jul 28, 2015 at 11:37 PM
I have compiled and installed SBFspot 3.0.8 on a Synology NAS running Linux kernel 2.6.32.12. I have used ipkg to install a toolchain and the necessary packages for compilation. These packages where:
  • boost-dev
  • boost-date-time
  • bluez-libs
Compilation was succesful, I have edited the SBFspot.cfg to fit my needs but when I run ./SBFspot I receive the following error:
./SBFspot: error while loading shared libraries: libbluetooth.so.2: cannot open shared object file: No such file or directory
Anyone has a clue on how to fix this? I have gotten so close in running SBFspot from a Synology NAS without having much Linux experience, I'd hate so see this go to waste.
Jul 28, 2015 at 11:45 PM
Ok, I seem to have gotten around this with the following command:
cp /usr/lib/libbluetooth.so.3 /usr/lib/libbluetooth.so.2
I guess there is some version issue. Unfortunately I have run into another error right after that looks similar:
./SBFspot: error while loading shared libraries: libboost_date_time.so.1.45.0: cannot open shared object file: No such file or directory
I have not found libboost_date_time.so.x yet though.
Marked as answer by Phuturist on 7/30/2015 at 3:41 AM
Jul 29, 2015 at 9:27 PM
Ok, another step forward. I solved the last error by changing LD_RUN_PATH to include the location where the boost libraries are installed. IPKG on the Synology NAS has a special location for this.

Unfortunately I'm still unable to get results. This is how it looks now.
Diskstation> ./SBFspot -v -finq -nocsv
SBFspot V3.0.8
Yet another tool to read power production of SMA solar inverters
(c) 2012-2015, SBF (https://sbfspot.codeplex.com)
Compiled for Linux (LE) 32 bit

Commandline Args: -v -finq -nocsv
Reading config './SBFspot.cfg'
Wed Jul 29 22:26:06 2015: INFO: Starting...
sunrise: 05:46
sunset : 21:34
Connecting to Local Network...
Initializing...
SUSyID: 125 - SessionID: 964614724 (0x397EDA44)
Inverter IP address: 192.168.0.128 from SBFspot.cfg
Wed Jul 29 22:26:07 2015: CRITICAL: Logon failed. Check 'USER' Password
Diskstation>
I'm assuming the error is related to not being able to connect to the database. However the settings in the config file seem to be correct. Could someone help me with the next steps.
Coordinator
Jul 29, 2015 at 9:44 PM
No, it fails to logon to the inverter. Default password for user is 0000 - Did you change it?
At this point there is no DB connection involved.
Jul 29, 2015 at 9:51 PM
Thanx for the quick response.

Right, I overlooked that. How stupid. I can now connect to the inverter but there is an issue with accessing the MySQL database. The Synology NAS has a MariaDB (fork of MySQL) as package and I'd like it to connect to that instance as it also runs other databases. I configured SBFspot.cfg to connect to that database but that does not seem to work however. Installing mysql through IPKG and configuring it through commandline gave me the following error.
Bla bla ...
AC Spot Data:
        Phase 1 Pac :   0.000kW - Uac:   0.00V - Iac:  0.000A
        Phase 2 Pac :   0.000kW - Uac:   0.00V - Iac:  0.000A
        Phase 3 Pac :   0.000kW - Uac:   0.00V - Iac:  0.000A
        Total Pac   :   0.000kW
SUSyID: 235 - SN: 2140010092
Grid Freq. : 0.00Hz
__Error: Can't open MySQL db [sbfspot] : Can't connect to local MySQL server through socket '/run/mysqld                                     /mysqld.sock' (2)__
********************
* ArchiveDayData() *
********************
startTime = 55B7FB60 -> 29/07/2015 00:00:00
**********************
* ArchiveMonthData() *
**********************
startTime = 5593C830 -> 01/07/2015 13:00:00
Reading events: 2015-Jul-01
Wed Jul 29 22:44:39 2015: INFO: Done.
Jul 29, 2015 at 10:03 PM
OK, I'm almost there. I can now connect to the MariaDB instance of MySQL but it's telling me the tables are missing in my database. Should I manually create these tables or what?
Error: exec_query() returned : Table 'sbfspot.Inverters' doesn't exist
Executed Statement: INSERT IGNORE INTO Inverters VALUES(2140010092,'','','',0,0,0,0,0,0,'','',0)Error: exec_query() returned : Table 'sbfspot.Inverters' doesn't exist
Executed Statement: UPDATE Inverters SET Name='',Type='',SW_Version='' WHERE Serial=2140010092Error: exec_query() returned : Table 'sbfspot.Inverters' doesn't exist
Executed Statement: UPDATE Inverters SET TimeStamp=1438203658,TotalPac=0,EToday=0,ETotal=0,OperatingTime=0,FeedInTime=0,Status='?',GridRelay='?',Temperature=0 WHERE Serial=2140010092Error: [spot_data]exec_query() returned : Table 'sbfspot.SpotData' doesn't exist
Executed Statement: INSERT INTO SpotData VALUES(1438203658,2140010092,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'?','?',0)********************
Another thing that is worring me is that all data seems to be 0, even the total. That will probably the next thing to troubleshoot.
Jul 29, 2015 at 10:11 PM
Well, I created the tables and I'm one step further. But there are still issue and I dont know what to do anymore.
  • all data is 0 even the total generation
  • there is an error saying Error: [day_data]mysql_stmt_execute() returned :
  • the script ends with Segmentation fault (core dumped) which doesnt seem right
Any pointers from here on?


The full result looks like this:
 Commandline Args: -v -finq -nocsv
Reading config './SBFspot.cfg'
Wed Jul 29 23:06:45 2015: INFO: Starting...
sunrise: 05:46
sunset : 21:34
Connecting to Local Network...
Initializing...
SUSyID: 125 - SessionID: 912140778 (0x365E29EA)
Inverter IP address: 192.168.0.128 from SBFspot.cfg
Logon OK
SetInverterTime() not executed! We're still testing...
SUSyID: 235 - SN: 2140010092
Device Name:
Device Class:
Device Type:
Software Version:
Serial number:    2140010092
SUSyID: 235 - SN: 2140010092
Device Status:      ?
SUSyID: 235 - SN: 2140010092
Device Temperature: 0.0°C
SUSyID: 235 - SN: 2140010092
Pac max phase 1: 0W
Pac max phase 2: 0W
Pac max phase 3: 0W
SUSyID: 235 - SN: 2140010092
Energy Production:
        EToday: 0.000kWh
        ETotal: 0.000kWh
        Operation Time: 0.00h
        Feed-In Time  : 0.00h
SUSyID: 235 - SN: 2140010092
DC Spot Data:
        String 1 Pdc:   0.000kW - Udc:   0.00V - Idc:  0.000A
        String 2 Pdc:   0.000kW - Udc:   0.00V - Idc:  0.000A
SUSyID: 235 - SN: 2140010092
AC Spot Data:
        Phase 1 Pac :   0.000kW - Uac:   0.00V - Iac:  0.000A
        Phase 2 Pac :   0.000kW - Uac:   0.00V - Iac:  0.000A
        Phase 3 Pac :   0.000kW - Uac:   0.00V - Iac:  0.000A
        Total Pac   :   0.000kW
SUSyID: 235 - SN: 2140010092
Grid Freq. : 0.00Hz
********************
* ArchiveDayData() *
********************
startTime = 55B7FB60 -> 29/07/2015 00:00:00
Error: [day_data]mysql_stmt_execute() returned :
**********************
* ArchiveMonthData() *
**********************
startTime = 5593C830 -> 01/07/2015 13:00:00
Segmentation fault (core dumped)
Coordinator
Jul 30, 2015 at 10:09 AM
Edited Jul 30, 2015 at 10:10 AM
Doesn't look so good for the moment... there is no data at all
At least EToday and ETotal should have some value:
Energy Production:
        EToday: 0.000kWh
        ETotal: 0.000kWh
        Operation Time: 0.00h
        Feed-In Time  : 0.00h
Same for Device Name and Type

Can you post a debug log (-d5 -v5)
Jul 30, 2015 at 11:41 AM
This morning I have tried it again and I now see data. With the -nosql parameter I'm not seeying any MySQL errors anymore as well (I dont need it as I'm using Domoticz to read the csv files).

The reason it didnt work last evening might be because I installed a Webconnect in the inverter last night. Although it was powered up again after that perhaps it needed some sunlight to start the communication through the Webconnect.

Thank you for the help.
Coordinator
Jul 30, 2015 at 3:06 PM
If you don't need SQL, you can compile with "make release" and you can uninstall SQLite
Aug 8, 2015 at 7:55 AM
How did you get this to compile on DSM? I'm having a compilation error and not sure what I need to install. Google in this instance isn't my friend (Google talks about 32 bit vs 64 bit gcc compilation) :-(

This is the error I get:
undefined references to `__sync_fetch_and_add_4'
Aug 9, 2015 at 5:14 PM
I'm probably not gonna be much of a help as I dont have any real Linux knowledge myself. All I did was follow this Wiki: http://forum.synology.com/wiki/index.php/Overview_on_modifying_the_Synology_Server,_bootstrap,_ipkg_etc and the Linux manual for SBFSpot. Luckely for me this worked fine on my DS111.
Aug 10, 2015 at 11:32 PM
Okay, so I got this to work by installing Debian Chroot on my Synology DS1513+. Couldn't get it to compile with the packages installed with ipkg (eventually got it to compile after fiddling with the shared libraries, but it wouldn't run: Segmentation Fault).

After installing chroot and downloading all the apt-get packages needed to build, I got it up and running.

I did notice that when running this morning at 5am it would still have a segmentation fault when writing out the info using -v5 (setting the verbosity to 3 or lower didn't show the segmentation fault). However, once the inverter started producing power around 7am, the segmentation fault went away and I can use -v5 with no problems.

I'm using version 3.1.0

The UploadDaemon is working without any issues and I now have the whole thing set up on my NAS.

The reason for moving from the Raspberry Pi to the NAS is my pi was on wireless and constantly dropped out, where as my NAS is on wired network connection. Since the NAS is already on 24/7, and supports bluetooth, I wanted to see if I could use it as my solar monitor. Don't have any spare wired network connections and didn't want to buy another switch and run more cable...

:-)
Coordinator
Aug 11, 2015 at 8:21 PM
@BleedingFingers
Can you post a -d5 -v5 debug log with Segmentation Fault?
Aug 11, 2015 at 8:35 PM
@BleedingFingers, perhaps this is unnecessary info as you got it running with Debian chroot already but this evening I tried to compile version 3.1.0 on My DS111 and it didnt work for me as well. I got the following error:
Diskstation> make release
test -d bin/Release || mkdir -p bin/Release
test -d obj/Release || mkdir -p obj/Release
g++ -Wall -O2  -c boost_ext.cpp -o obj/Release/boost_ext.o
g++ -Wall -O2  -c misc.cpp -o obj/Release/misc.o
g++ -Wall -O2  -c strptime.cpp -o obj/Release/strptime.o
g++ -Wall -O2  -c sunrise_sunset.cpp -o obj/Release/sunrise_sunset.o
g++ -Wall -O2  -c SBFNet.cpp -o obj/Release/SBFNet.o
In file included from SBFNet.cpp:37:
SBFspot.h:399: error: integer constant is too large for 'long' type
SBFspot.h:400: error: integer constant is too large for 'long' type
make: *** [obj/Release/SBFNet.o] Error 1
Compiling version 3.0.8 works fine however. If you want to get rid of Debian chroot you could give version a try.

@SBF, perhaps this is something to look into before releasing a new stable version.
Coordinator
Aug 11, 2015 at 9:15 PM
These lines have been changed in V3.1.0
Is DS111 32 or 64 bit OS?
The values should be 64 bit types, but it seems they are 32 bit on your system
Aug 12, 2015 at 7:02 AM
uname -r gives the following result:
Linux Diskstation 2.6.32.12 #5592 Wed Jul 29 14:39:15 CST 2015 armv5tel GNU/Linux synology_88f6282_111
It's a 32-bit CPU with of course a 32-bit OS.
Aug 13, 2015 at 5:05 AM
Edited Aug 13, 2015 at 5:07 AM
Interesting, the seg fault only happens in the morning and only before the inverter reports power generated. This morning I started logging at 5am and it runs in 5 minute intervals and each time it seg faulted until 7am when the inverter reported the first generation data.

Below is the last report that seg faulted (06:55, the next time it ran at 07:00 it worked fine and reported generation of 24.000W).

06:55 Seg Fault

07:00 Working

My System: Linux DiskStation 3.10.35 #5592 SMP Mon Jun 29 17:28:12 CST 2015 x86_64 GNU/Linux
Coordinator
Aug 13, 2015 at 8:28 PM
Edited Aug 13, 2015 at 8:32 PM
Is there a file 'core' in the current directory? If so, can you send it?

If not, what is the output of
cat /proc/sys/kernel/core_pattern
Seems to be somewhere in this part of the code:
if (VERBOSE_HIGH)
{
    for (int inv=0; Inverters[inv]!=NULL && inv<MAX_INVERTERS; inv++)
    {
        printf("SUSyID: %d - SN: %lu\n", Inverters[inv]->SUSyID, Inverters[inv]->Serial);
        for (idx=0; idx<sizeof(Inverters[inv]->dayData)/sizeof(DayData); idx++)
            if (Inverters[inv]->dayData[idx].datetime > 0)
                printf("%s : %.3fkWh - %3.3fW\n", strftime_t(cfg.DateTimeFormat, Inverters[inv]->dayData[idx].datetime), (double)Inverters[inv]->dayData[idx].totalWh/1000, (double)Inverters[inv]->dayData[idx].watt);
        puts("======");
    }
}

Aug 13, 2015 at 10:12 PM
It took a while to find where the core file was dumped.


Feb 7, 2016 at 9:55 PM
Hey,

i have a very similar problem. I have no plan how i should name this coulumns in SpotData.
And every run SBFspot crate a new row with similar informations of my inverter.
[2016-02-07 21:47:27.903] Error: [spot_data]exec_query() returned : Table 'SBFspot.SpotData' doesn't exist
Executed Statement: INSERT INTO SpotData VALUES(1454881647,2110075072,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9118,53269395,0,19745,19287.2,67.451,'OK','N/A',0)
i use only MySQL and a "make install_mysql" build

Thanks!