CRITICAL: Failed to initialize Speedwire connection.

Topics: 5. Support
Jan 25 at 9:21 AM
Edited Jan 25 at 10:17 AM
For compatibility reasons with my old logging solution I want to parse parts of the output of
/usr/local/bin/sbfspot.3/SBFspot -v -finq -nocsv -nosql
from within a php script and write it into a database.

Executing the script from the shell via "php -f scriptname.php" works perfectly fine, but when using it from cronjob I see this error:
CRITICAL: Failed to initialize Speedwire connection.
I am using
shell_exec('/usr/local/bin/sbfspot.3/SBFspot -v -finq -nocsv -nosql')
from within my php script. What am I doing wrong? Any idea?

If I echo the output, this is the result:
SBFspot V3.3.1
Yet another tool to read power production of SMA solar inverters
(c) 2012-2016, SBF (https://sbfspot.codeplex.com)
Compiled for Linux (LE) 32 bit

Commandline Args: -v -finq -nocsv -nosql
Reading config '/usr/local/bin/sbfspot.3/SBFspot.cfg'
Wed Jan 25 12:10:01 2017: INFO: Starting...
sunrise: 07:59
sunset : 16:39
Connecting to Local Network...
Initializing...
SUSyID: 125 - SessionID: 870131845 (0x33DD2885)
Inverter IP address: 192.168.166.162 from SBFspot.cfg
Wed Jan 25 12:10:06 2017: CRITICAL: Failed to initialize Speedwire connection.
Coordinator
Jan 25 at 10:23 AM
Try with a fixed IP-address in config (if not already done)
Enable debug mode with -d5
Cron is running with another user?
Jan 25 at 11:12 AM
In the SBFspot.cfg I entered a fixed IP. AS I said: from the commandline the script works perfect...
Debug mode says:
Wed Jan 25 13:00:01 2017: INFO: Starting...
sunrise: 07:59
sunset : 16:39
Connecting to Local Network...
Initializing...
SUSyID: 125 - SessionID: 886553217 (0x34D7BA81)
Inverter IP address: 192.168.166.162 from SBFspot.cfg
--------: 00 01 02 03 04 05 06 07 08 09
00000000: 53 4D 41 00 00 04 02 A0 00 00
00000010: 00 01 00 26 00 10 60 65 09 A0
00000020: FF FF FF FF FF FF 00 00 7D 00
00000030: 81 BA D7 34 00 00 00 00 00 00
00000040: 01 80 00 02 00 00 00 00 00 00
00000050: 00 00 00 00 00 00 00 00
58 Bytes sent to IP [192.168.166.162]
ethGetPacket()
Timeout reading socket
No data!
Wed Jan 25 13:00:06 2017: CRITICAL: Failed to initialize Speedwire connection.
Cron is running with my standard user, I already tried it also as root, but no effect.
Coordinator
Jan 25 at 12:32 PM
Strange... I have no further ideas.
Can't test it either as I don't have an Ethernet connected inverter.
The data packet is OK, but it looks like it's not arriving at the inverter.
Maybe a PHP/CRON script with a ping command will tell you more?
Jan 25 at 2:53 PM
Edited Jan 25 at 3:53 PM
I made another PHP script with just a ping to the inverter and echoed the output in a cronjob. No problem, everything as expected. No idea why this other script works from the commandline but not from cronjob.

Calling the command with a batch file and a cronjob works. Calling this batch file from the php script does not work.