danieloneill / EpsolarServer

Epsolar Tracer-series logging/monitoring for Linux (and Raspberry Pi)
MIT License
31 stars 10 forks source link

using with Raspberry #9

Open tanoea opened 4 years ago

tanoea commented 4 years ago

Hello, I am trying to use it with my raspberry pi 3. Everything looks good until i experience an error. When I 'qmake' and 'make' the EpsolarServer.pro, it gives me an error: pi@raspberrypi:~/EpsolarServer $ make g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DSETTINGS="\"/etc/epsolarServer.conf\"" -DCOMPILETIME="\"Mon May 11 03:48:04 2020\"" -DQT_DEPRECATED_WARNINGS -DHTTP -DWEBSOCKET -DLIBMB -DQT_NO_DEBUG -DQT_SQL_LIB -DQT_WEBSOCKETS_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -isystem /usr/include/modbus -isystem /usr/include/arm-linux-gnueabihf/qt5 -isystem /usr/include/arm-linux-gnueabihf/qt5/QtSql -isystem /usr/include/arm-linux-gnueabihf/qt5/QtWebSockets -isystem /usr/include/arm-linux-gnueabihf/qt5/QtNetwork -isystem /usr/include/arm-linux-gnueabihf/qt5/QtCore -I. -I/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++ -o epsolar.o src/epsolar.cpp src/epsolar.cpp: In member function ‘bool Epsolar::open(const QString&, quint32, int, const QString&, int)’: src/epsolar.cpp:40:40: error: invalid conversion from ‘timeval’ to ‘uint32_t’ {aka ‘unsigned int’} [-fpermissive] modbus_set_response_timeout(m_ctx, &tv); ^~~ src/epsolar.cpp:40:43: error: too few arguments to function ‘int modbus_set_response_timeout(modbus_t, uint32_t, uint32_t)’ modbus_set_response_timeout(m_ctx, &tv); ^ In file included from src/epsolar.h:8, from src/epsolar.cpp:1: /usr/include/modbus/modbus.h:186:16: note: declared here MODBUS_API int modbus_set_response_timeout(modbus_t ctx, uint32_t to_sec, uint32_t to_usec); ^~~~~~~ src/epsolar.cpp:41:36: error: invalid conversion from ‘timeval’ to ‘uint32_t’ {aka ‘unsigned int’} [-fpermissive] modbus_set_byte_timeout(m_ctx, &tv); ^~~ src/epsolar.cpp:41:39: error: too few arguments to function ‘int modbus_set_byte_timeout(modbus_t, uint32_t, uint32_t)’ modbus_set_byte_timeout(m_ctx, &tv); ^ In file included from src/epsolar.h:8, from src/epsolar.cpp:1: /usr/include/modbus/modbus.h:189:16: note: declared here MODBUS_API int modbus_set_byte_timeout(modbus_t ctx, uint32_t to_sec, uint32_t to_usec); ^~~~~~~ make: *** [Makefile:437: epsolar.o] Error 1

I tried to continue following the steps. Then, When i tried to open with my chromium, it says This site can’t be reached192.168.0.106 refused to connect.

Did I do something wrong? I only got that error above, and no other error for the rest.

danieloneill commented 4 years ago

No no, you're doing it right. It looks like libmodbus changed their API a bit. I'll take a peek at it and see if I can get you going.

There have been a few deprecated methods, I've expected this kind of breaking change for a while

danieloneill commented 4 years ago

Okay, can you try grabbing the latest master and recompiling? I've updated that bit, and it seems to fix the build issues.

If you aren't familiar with git, just type "git pull" from the EpsolarServer directory, and it should pull down an updated README.md and src/epsolar.cpp.

Also, if you wouldn't mind, tell me if your build fails with qhttpserver looking for safequeue.h? It's a problem I've noticed on a new system here.

tanoea commented 4 years ago

hello Daniel, This is the result from qhttpserver

pi@raspberrypi:~/EpsolarServer/3rdparty/qhttpserver $ make cd src/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/pi/EpsolarServer/3rdparty/qhttpserver/src/src.pro ) && make -f Makefile make[1]: Entering directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/src' make[1]: Nothing to be done for 'first'. make[1]: Leaving directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/src' cd examples/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/pi/EpsolarServer/3rdparty/qhttpserver/examples/examples.pro ) && make -f Makefile make[1]: Entering directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples' cd helloworld/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/pi/EpsolarServer/3rdparty/qhttpserver/examples/helloworld/helloworld.pro ) && make -f Makefile make[2]: Entering directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples/helloworld' make[2]: Nothing to be done for 'first'. make[2]: Leaving directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples/helloworld' cd greeting/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/pi/EpsolarServer/3rdparty/qhttpserver/examples/greeting/greeting.pro ) && make -f Makefile make[2]: Entering directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples/greeting' make[2]: Nothing to be done for 'first'. make[2]: Leaving directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples/greeting' cd bodydata/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/pi/EpsolarServer/3rdparty/qhttpserver/examples/bodydata/bodydata.pro ) && make -f Makefile make[2]: Entering directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples/bodydata' make[2]: Nothing to be done for 'first'. make[2]: Leaving directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples/bodydata' make[1]: Leaving directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples

pi@raspberrypi:~/EpsolarServer/3rdparty/qhttpserver $ make install cd src/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/pi/EpsolarServer/3rdparty/qhttpserver/src/src.pro ) && make -f Makefile install make[1]: Entering directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/src' /usr/lib/qt5/bin/qmake -install qinstall -exe ../lib/libqhttpserver.so.0.1.0 /usr/local/lib/libqhttpserver.so.0.1.0 Error copying ../lib/libqhttpserver.so.0.1.0 to /usr/local/lib/libqhttpserver.so.0.1.0: Cannot create /usr/local/lib/libqhttpserver.so.0.1.0 for output make[1]: [Makefile:492: install_target] Error 3 (ignored) strip --strip-unneeded /usr/local/lib/libqhttpserver.so.0.1.0 strip: '/usr/local/lib/libqhttpserver.so.0.1.0': No such file make[1]: [Makefile:493: install_target] Error 1 (ignored) ln -f -s libqhttpserver.so.0.1.0 /usr/local/lib/libqhttpserver.so ln: failed to create symbolic link '/usr/local/lib/libqhttpserver.so': Permission denied make[1]: [Makefile:494: install_target] Error 1 (ignored) ln -f -s libqhttpserver.so.0.1.0 /usr/local/lib/libqhttpserver.so.0 ln: failed to create symbolic link '/usr/local/lib/libqhttpserver.so.0': Permission denied make[1]: [Makefile:495: install_target] Error 1 (ignored) ln -f -s libqhttpserver.so.0.1.0 /usr/local/lib/libqhttpserver.so.0.1 ln: failed to create symbolic link '/usr/local/lib/libqhttpserver.so.0.1': Permission denied make[1]: [Makefile:496: install_target] Error 1 (ignored) /usr/lib/qt5/bin/qmake -install qinstall /home/pi/EpsolarServer/3rdparty/qhttpserver/src/qhttpserver.h /usr/local/include/qhttpserver.h Error copying /home/pi/EpsolarServer/3rdparty/qhttpserver/src/qhttpserver.h to /usr/local/include/qhttpserver.h: Cannot create /usr/local/include/qhttpserver.h for output make[1]: [Makefile:508: install_headers] Error 3 (ignored) /usr/lib/qt5/bin/qmake -install qinstall /home/pi/EpsolarServer/3rdparty/qhttpserver/src/qhttprequest.h /usr/local/include/qhttprequest.h Error copying /home/pi/EpsolarServer/3rdparty/qhttpserver/src/qhttprequest.h to /usr/local/include/qhttprequest.h: Cannot create /usr/local/include/qhttprequest.h for output make[1]: [Makefile:509: install_headers] Error 3 (ignored) /usr/lib/qt5/bin/qmake -install qinstall /home/pi/EpsolarServer/3rdparty/qhttpserver/src/qhttpresponse.h /usr/local/include/qhttpresponse.h Error copying /home/pi/EpsolarServer/3rdparty/qhttpserver/src/qhttpresponse.h to /usr/local/include/qhttpresponse.h: Cannot create /usr/local/include/qhttpresponse.h for output make[1]: [Makefile:510: install_headers] Error 3 (ignored) /usr/lib/qt5/bin/qmake -install qinstall /home/pi/EpsolarServer/3rdparty/qhttpserver/src/qhttpserverapi.h /usr/local/include/qhttpserverapi.h Error copying /home/pi/EpsolarServer/3rdparty/qhttpserver/src/qhttpserverapi.h to /usr/local/include/qhttpserverapi.h: Cannot create /usr/local/include/qhttpserverapi.h for output make[1]: [Makefile:511: install_headers] Error 3 (ignored) /usr/lib/qt5/bin/qmake -install qinstall /home/pi/EpsolarServer/3rdparty/qhttpserver/src/qhttpserverfwd.h /usr/local/include/qhttpserverfwd.h Error copying /home/pi/EpsolarServer/3rdparty/qhttpserver/src/qhttpserverfwd.h to /usr/local/include/qhttpserverfwd.h: Cannot create /usr/local/include/qhttpserverfwd.h for output make[1]: [Makefile:512: install_headers] Error 3 (ignored) make[1]: Leaving directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/src' cd examples/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/pi/EpsolarServer/3rdparty/qhttpserver/examples/examples.pro ) && make -f Makefile install make[1]: Entering directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples' cd helloworld/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/pi/EpsolarServer/3rdparty/qhttpserver/examples/helloworld/helloworld.pro ) && make -f Makefile install make[2]: Entering directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples/helloworld' make[2]: Nothing to be done for 'install'. make[2]: Leaving directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples/helloworld' cd greeting/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/pi/EpsolarServer/3rdparty/qhttpserver/examples/greeting/greeting.pro ) && make -f Makefile install make[2]: Entering directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples/greeting' make[2]: Nothing to be done for 'install'. make[2]: Leaving directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples/greeting' cd bodydata/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/pi/EpsolarServer/3rdparty/qhttpserver/examples/bodydata/bodydata.pro ) && make -f Makefile install make[2]: Entering directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples/bodydata' make[2]: Nothing to be done for 'install'. make[2]: Leaving directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples/bodydata' make[1]: Leaving directory '/home/pi/EpsolarServer/3rdparty/qhttpserver/examples

danieloneill commented 4 years ago

You need to run "make install" as root, try sudo make install

tanoea commented 4 years ago

Thanks for your attention Daniel. Yes. I did after that. it gives me the safequeue.h problems. tried to copy it manually and follow the rest command. but still in the end, my chromium browser says 192.168.0.106 connection refused.

I am trying to reinstall a clean raspbian now and retry all the procedures from the beginning. I might did something stupid and ruined the instalation. I will let you know after i restart everything.

danieloneill commented 4 years ago

There's no need for that, I'll go over the instructions again to clarify each step.

There's also another patch for the rs485 adapter that seems extremely common with the AN series of controllers:

By default, they are in RS422 mode, and needs to either run a patched driver or be kicked into rs485 at runtime.

I think I found a way to do that, so I'm going to try getting that going and push up a new patch. If you can give it a bit of time I may be able to also simplify the whole process of installation and setup.

tanoea commented 4 years ago

yes. i am using the epever cable and it needs some modification. I found it from another place, i am following the below instruction. I think this is perfect, and your modules acknowledge my ttyXRUSB

Linux driver for Exar USB UART

Heres how to install the driver for a usb to rs-485 similar to the one found here The xr_usb_serial_common directory contains the makefile and instructions that will compile properly on Rasbian OS on a raspberry pi 3. Before compiling be sure to install the linux headers with sudo apt-get install raspberrypi-kernel-headers

After installing the headers be sure to sudo bundle then sudo make. The resulting xr_usb_serial_common.ko file will need to be moved to /lib/modules/YOUR_LINUX_VERSION/extra/. After building and moving the module, remove the cdc-acm driver that automatically installs for the usb-485 adapter.

rmmod cdc-acm modprobe -r usbserial modprobe usbserial

You will also need to add the cdc-acm to the system blacklist:

echo blacklist cdc-acm > /etc/modprobe.d/blacklist-cdc-acm.conf Note: If echo doesnt work you will need to add blacklist cdc-acm manually to the blacklist with vim vi /etc/modprobe.d/blacklist-cdc-acm.conf

Finally add xr_usb_serial_common to '/etc/modules' to autoload the module on startup.

After all of this is done make sure that the new driver loads correctly by reloading the linux dependency list depmod -ae Then load the module with modprobe xr_usb_serial_common

If all goes well you should see ttyXRUSB when listing ls /dev/tty*

tanoea commented 4 years ago

halo Daniel. I re-did everything from scratch. I did not notice any error, unless i missed it. the chromium still does not show anything, it says connection refused.

when you said "Once running, you can see your graph start to populate by pointing your HTML5 compliant web browser to: http://(host address):8080/" does it mean i should connect my cable first with epsolar controler, or the browser should show some empty graph before i connect it to epsolar controler?

thanks.

danieloneill commented 4 years ago

The exar driver has a way to switch it to rs485 without requiring a special kernel module, I've made that change.

The service won't automatically start itself on boot and requires root permission unless you make certain changes to certain Linux things.

You need to have the cable connected from startup and all the time after.

Another nice touch would be using udev to stop and start the communication if the cable is unplugged or plugged back in.

There are a few issues that have come to light. The first is without knowing how to setup permissions or deal with systemd services, making this all automated is kind of a pain. Luckily it can be assumed that everybody using this will have the exar cable and running it on a pi, so that can be automated in a script.

Actually, everything can, including the kernel module noise.

In my work recently, the exar kernel module crashed and, since I was done working on it for the evening I just left my computer on. This morning it was hard crashed, and.. it was that exar kernel module. Sooooo I'll look into that so your pi won't suffer the same fate, and hopefully run reliably for years of monitoring.

The newer version is close to testing ready. Hopefully I'll get some time to add a few features tonight. I'll publish the code to a separate GitHub project and link to it when it's ready to test and play with.

I'll also work on scripting the installation process such that it will automatically register as a startup service, permissions things, and so on.

For now, simply connect your controller cable and run sudo EpsolarServer which should get it up and running.

tanoea commented 4 years ago

I tried sudo EpsolarServer:

pi@raspberrypi:~/EpsolarServer $ sudo EpsolarServer sudo: EpsolarServer: command not found

but the file EpsolarServer is present in the folder.

UPDATE I tried to connect my pi with vnc, and double click the file EpsolarServer. it runs. hihihihi I am very happy to see empty graphs on my pi. I dont know why i cannot run it from terminal.

i will try to connect my raspi with solar controler later on and see what will happen with the graph. I will let you know the result.

Screenshot from 2020-05-14 09-09-24

tanoea commented 4 years ago

Hello Daniel,

I tried to connect my raspi with solar controler. Looks like its working for a moment, then producing connection timeout. Here is what the terminal says:

pi@raspberrypi:~/EpsolarServer $ sudo ./EpsolarServer QHttpServer . (slot_)listen : "0.0.0.0" : "8080" 0x1b5a078 Connected Loaded registers: QHash((13069, QMap(("lowhigh", QVariant(int, 2))("n", QVariant(QString, "Generated energy today"))("scale", QVariant(double, 100))))(13068, QMap(("lowhigh", QVariant(int, 1))("n", QVariant(QString, "Generated energy today"))("scale", QVariant(double, 100))))(12801, QMap(("n", QVariant(QString, "Charge controller status"))("scale", QVariant(double, 1))))(12800, QMap(("n", QVariant(QString, "Battery status"))("scale", QVariant(double, 1))))(12558, QMap(("n", QVariant(QString, "Load watts"))("scale", QVariant(double, 0.01))))(12557, QMap(("n", QVariant(QString, "Load current"))("scale", QVariant(double, 0.01))))(12556, QMap(("n", QVariant(QString, "Load voltage"))("scale", QVariant(double, 0.01))))(13061, QMap(("lowhigh", QVariant(int, 2))("n", QVariant(QString, "Consumed energy today"))("scale", QVariant(double, 100))))(12546, QMap(("n", QVariant(QString, "Charge watts"))("scale", QVariant(double, 0.01))))(13060, QMap(("lowhigh", QVariant(int, 1))("n", QVariant(QString, "Consumed energy today"))("scale", QVariant(double, 100))))(12545, QMap(("n", QVariant(QString, "Charge current"))("scale", QVariant(double, 0.01))))(12544, QMap(("n", QVariant(QString, "Charge voltage"))("scale", QVariant(double, 0.01))))(12570, QMap(("n", QVariant(QString, "Battery SOC"))("scale", QVariant(double, 1))))(13075, QMap(("lowhigh", QVariant(int, 2))("n", QVariant(QString, "Generated energy total"))("scale", QVariant(double, 0.01))))(13074, QMap(("lowhigh", QVariant(int, 1))("n", QVariant(QString, "Generated energy total"))("scale", QVariant(double, 0.01))))(12573, QMap(("n", QVariant(QString, "Battery temperature"))("scale", QVariant(double, 0.01))))(13077, QMap(("lowhigh", QVariant(int, 2))("n", QVariant(QString, "CO2 reduction"))("scale", QVariant(double, 100))))(13076, QMap(("lowhigh", QVariant(int, 1))("n", QVariant(QString, "CO2 reduction"))("scale", QVariant(double, 100))))) Connection timed out Connection timed out Connection timed out Connection timed out Connection timed out Connection timed out Connection timed out

Screenshot from 2020-05-15 14-08-05