gch1p / inverter-tools

advanced tools for voltronic inverters
BSD 3-Clause "New" or "Revised" License
18 stars 5 forks source link

Install GCC on Raspberry Pi and build C++17 programs #1

Closed blacksocket closed 1 year ago

blacksocket commented 3 years ago

Hello,

Do I need first Install GCC on Raspberry Pi and build C++17 programs ? I used this guide below but not sure how to compile the inverter tools. Could you please provide the exact commands to build this software on RPI ?

https://gist.github.com/sol-prog/95e4e7e3674ac819179acf33172de8a9

Commands used in the video https://youtu.be/-bCG87jBDqA :

sudo apt update && sudo apt upgrade -y

git clone https://bitbucket.org/sol_prog/raspberry-pi-gcc-binary.git cd raspberry-pi-gcc-binary tar -xjvf gcc-9.1.0-armhf-raspbian.tar.bz2 sudo mv gcc-9.1.0 /opt cd .. rm -rf raspberry-pi-gcc-binary

cd ~ echo 'export PATH=/opt/gcc-9.1.0/bin:$PATH' >> ~/.bashrc echo 'export LD_LIBRARY_PATH=/opt/gcc-9.1.0/lib:$LD_LIBRARY_PATH' >> ~/.bashrc . ~/.bashrc sudo ln -s /usr/include/arm-linux-gnueabihf/sys /usr/include/sys sudo ln -s /usr/include/arm-linux-gnueabihf/bits /usr/include/bits sudo ln -s /usr/include/arm-linux-gnueabihf/gnu /usr/include/gnu sudo ln -s /usr/include/arm-linux-gnueabihf/asm /usr/include/asm sudo ln -s /usr/lib/arm-linux-gnueabihf/crti.o /usr/lib/crti.o sudo ln -s /usr/lib/arm-linux-gnueabihf/crt1.o /usr/lib/crt1.o sudo ln -s /usr/lib/arm-linux-gnueabihf/crtn.o /usr/lib/crtn.o

g++-9.1 -std=c++17 -Wall -pedantic test_fs.cpp -o test_fs ./test_fs

Thank You!

gch1p commented 3 years ago

Hi. Not sure about Raspbian, but on Armbian I just use gcc from repos.

To build inverter-tools, you first need to install dependencies, something like:

apt-get install cmake make build-essential libhidapi-hidraw0 libhidapi-libusb0 libhidapi-dev libserialport0 libserialport-dev

Then clone the repo and change to its directory. Then:

mkdir build
cd build
cmake ..
make

if you have enough RAM, you can parallel the build using make -j4 where 4 is the number of CPU cores. It will speed up the compilation but you can run out of memory on low end devices

Optionally:

sudo make install
blacksocket commented 3 years ago

Hi, it works now but when performing make install I am getting now the error "No such file or directory" below.

pi@raspberrypi:/inverter-tools/build $ sudo make install Scanning dependencies of target inverterd [ 2%] Building CXX object CMakeFiles/inverterd.dir/src/inverterd.cc.o In file included from /home/pi/inverter-tools/src/common.h:6, from /home/pi/inverter-tools/src/inverterd.cc:11: /home/pi/inverter-tools/src/formatter/formatter.h:12:10: fatal error: nlohmann/json.hpp: No such file or directory

include <nlohmann/json.hpp>

      ^~~~~~~~~~~~~~~~~~~

compilation terminated. make[2]: [CMakeFiles/inverterd.dir/build.make:63: CMakeFiles/inverterd.dir/src/inverterd.cc.o] Error 1 make[1]: [CMakeFiles/Makefile2:80: CMakeFiles/inverterd.dir/all] Error 2 make: *** [Makefile:130: all] Error 2

Thank you!

gch1p commented 3 years ago

Ah, right.

git submodule update --init
blacksocket commented 3 years ago

Now it has been complied properly ;-) I am trying to launch the program as below and getting "error: invalid device". Not sure if this is the proper use. Do you have maybe the example configuration file ?

./inverterctl --device usb: --usb-vendor-id 0665: --usb-device-id 5161:

usage: ./inverterctl OPTIONS [COMMAND]

Options: -h: Show short help --help: Show this help --raw : Execute arbitrary command and print response (example: ^P005PI) --device : Device type to use. See below for list of supported devices --timeout : Device read/write timeout, in milliseconds (default: 1000) --verbose: Print debug information (including hex dumps of device traffic) --format : Output format for command responses

Device types: usb USB device serial Serial device pseudo Pseudo device (only useful for development/debugging purposes)

USB device options: --usb-vendor-id : Vendor ID (default: 0665) --usb-device-id : Device ID (default: 5161)

My inverter has been discovered as below:

pi@raspberrypi:~/inverter-tools/build $ lsusb Bus 001 Device 004: ID 0665:5161 Cypress Semiconductor USB to Serial

gch1p commented 3 years ago
  1. You don't need to pass device ids as those are defaults anyway.
  2. ./inverterctl --device usb: --usb-vendor-id 0665: --usb-device-id 5161:

    Here I see some unneeded colons, use --device usb, not --device usb:

Try for example inverterctl --device usb get-status.

To view full list of commands: inverterctl --help.

P.S. Most likely you need root permissions to interact with USB device

blacksocket commented 3 years ago

Still having some issues. The device (InfiniSolar 10kW Solar Hybrid Inverter) is connected to RPI via USB.

pi@raspberrypi:~/inverter-tools/build $ sudo ./inverterctl --device usb get-status error: response is invalid: validate() failed

pi@raspberrypi:~/inverter-tools/build $ ll /dev/usb total 0 drwxr-xr-x 2 root root 60 Jun 6 23:15 . drwxr-xr-x 16 root root 3580 Jun 6 23:15 .. crw------- 1 root root 180, 96 Jun 6 23:15 hiddev0

Many thanks for your help!

gch1p commented 3 years ago

Hm, this device isn't tested, maybe it uses different protocol.

Please share the output of:

sudo ./inverterctl --device usb --verbose get-status

or

sudo ./inverterctl --device usb --verbose get-protocol-id
blacksocket commented 3 years ago

Below is the output:

pi@raspberrypi:~/inverter-tools/build $ sudo ./inverterctl --device usb --verbose get-status voltronic::Device::send(): writing 10 bytes 0x0000: 5e 50 30 30 35 47 53 58 14 0d ^P005GSX.. voltronic::USBDevice::write(): dataSize=10, writeSize=8 0x0000: 5e 50 30 30 35 47 53 58 14 0d ^P005GSX.. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::USBDevice::write(): dataSize=2, writeSize=2 0x0000: 14 0d .. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::recv(): got 5 bytes 0x0000: 5e 30 1b e3 0d ^0... error: response is invalid: validate() failed

gch1p commented 3 years ago

It seems that your inverter uses P17 protocol which is not currently supported. But let's confirm this.

I've just uploaded a new branch called p17-test, fetch and checkout to it (or manually patch inverterctl.cc, it's one line https://github.com/gch1p/inverter-tools/commit/bac33ab8991df1dbb6dac851efad8f0ec9fbc870), rebuild inverterctl and launch this:

sudo ./inverterctl --device usb --verbose --raw "^P003PI"

I expect it to show something like ^D00517 in response.

Other commands won't work at the moment. But you can try invoking some of them manually, like --raw "^P003GS". Should return general status.

If we confirm that your inverter is indeed using P17 protocol, then I'll support it in a week or so, fortunately the protocol datasheet is available.

blacksocket commented 3 years ago

Owsome! ;-) Below the output after recompiled code:

pi@raspberrypi:~/inverter-tools/build $ sudo ./inverterctl --device usb --verbose --raw "^P003PI" voltronic::Device::send(): writing 8 bytes 0x0000: 5e 50 30 30 33 50 49 0d ^P003PI. voltronic::USBDevice::write(): dataSize=8, writeSize=8 0x0000: 5e 50 30 30 33 50 49 0d ^P003PI. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::recv(): got 10 bytes 0x0000: 5e 44 30 30 35 31 37 ca ec 0d ^D00517... 0x0000: 5e 44 30 30 35 31 37 ^D00517 ^D00517

pi@raspberrypi:~/inverter-tools/build $ sudo ./inverterctl --device usb --verbose --raw "^P003GS" voltronic::Device::send(): writing 8 bytes 0x0000: 5e 50 30 30 33 47 53 0d ^P003GS. voltronic::USBDevice::write(): dataSize=8, writeSize=8 0x0000: 5e 50 30 30 33 47 53 0d ^P003GS. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=0 error: timeout: data reading already took 1001 ms

gch1p commented 3 years ago

Nice, it's really P17.

About that timeout, try --timeout 3000 or something like that, maybe it's just too slow. Mine is returning status in about 500ms so I set 1000ms as the default.

gch1p commented 3 years ago

So I'll implement P17 and notify you, I hope for your help in testing.

blacksocket commented 3 years ago

Below is the output with --timeout set to 3000 . Of course I will help with anything needed just let me know! ;-)

pi@raspberrypi:/inverter-tools/build $ sudo ./inverterctl --device usb --timeout 3000 --verbose --raw "^P003PI" voltronic::Device::send(): writing 8 bytes 0x0000: 5e 50 30 30 33 50 49 0d ^P003PI. voltronic::USBDevice::write(): dataSize=8, writeSize=8 0x0000: 5e 50 30 30 33 50 49 0d ^P003PI. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::recv(): got 10 bytes 0x0000: 5e 44 30 30 35 31 37 ca ec 0d ^D00517... 0x0000: 5e 44 30 30 35 31 37 ^D00517 ^D00517

pi@raspberrypi:~/inverter-tools/build $ sudo ./inverterctl --device usb --timeout 3000 --verbose --raw "^P003GS" voltronic::Device::send(): writing 8 bytes 0x0000: 5e 50 30 30 33 47 53 0d ^P003GS. voltronic::USBDevice::write(): dataSize=8, writeSize=8 0x0000: 5e 50 30 30 33 47 53 0d ^P003GS. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::recv(): got 115 bytes 0x0000: 5e 44 31 31 30 30 30 30 30 2c 30 30 30 30 2c 30 ^D1100000,0000,0 0x0010: 30 30 30 2c 30 30 30 30 2c 30 35 34 30 2c 30 39 000,0000,0540,09 0x0020: 39 2c 2b 30 30 30 32 31 2c 32 33 32 34 2c 32 33 9,+00021,2324,23 0x0030: 34 38 2c 32 32 39 36 2c 34 39 39 38 2c 30 30 30 48,2296,4998,000 0x0040: 30 2c 30 30 30 30 2c 30 30 30 30 2c 32 33 32 34 0,0000,0000,2324 0x0050: 2c 32 33 34 36 2c 32 32 39 36 2c 34 39 39 39 2c ,2346,2296,4999, 0x0060: 2c 2c 2c 30 32 39 2c 30 33 31 2c 30 30 30 2c 30 ,,,029,031,000,0 0x0070: a0 42 0d .B. 0x0000: 5e 44 31 31 30 30 30 30 30 2c 30 30 30 30 2c 30 ^D1100000,0000,0 0x0010: 30 30 30 2c 30 30 30 30 2c 30 35 34 30 2c 30 39 000,0000,0540,09 0x0020: 39 2c 2b 30 30 30 32 31 2c 32 33 32 34 2c 32 33 9,+00021,2324,23 0x0030: 34 38 2c 32 32 39 36 2c 34 39 39 38 2c 30 30 30 48,2296,4998,000 0x0040: 30 2c 30 30 30 30 2c 30 30 30 30 2c 32 33 32 34 0,0000,0000,2324 0x0050: 2c 32 33 34 36 2c 32 32 39 36 2c 34 39 39 39 2c ,2346,2296,4999, 0x0060: 2c 2c 2c 30 32 39 2c 30 33 31 2c 30 30 30 2c 30 ,,,029,031,000,0 ^D1100000,0000,0000,0000,0540,099,+00021,2324,2348,2296,4998,0000,0000,0000,2324,2346,2296,4999,,,,029,031,000,0

gch1p commented 3 years ago

Nice. It works. ^D1100000,0000,0000,0000,0540,099,+00021,2324,2348,2296,4998,0000,0000,0000,2324,2346,2296,4999,,,,029,031,000,0 is your raw status data.

blacksocket commented 3 years ago

It means my inverter respond with the general status using the P17 protocol in this test ? You mentioned that the protocol P17 datasheet is available. Can you send me the link, so I will also learn something about that.. ;-)

gch1p commented 3 years ago

Yes.

PI17_InfiniSolar-5KW-protocol-20160309.pdf

Here is it. I started working on supporting P17 in inverter-tools btw.

blacksocket commented 3 years ago

Great, many thanks! ;-)

blacksocket commented 3 years ago

Hello Evgeny, how are you ? How did you play on the European Football Championship in St. Petersburg ? ;-) Were you able to code something during this time ;-)

KristianHeider commented 3 years ago

You can close this issue while it is running on my raspberry 3b. My ea sun power inverter hybrid uses P18. Thank you for your implementation.

blacksocket commented 3 years ago

KristianHeider,

We are talking here about supporting P17 protocol.

blacksocket commented 3 years ago

Attached P17 events XML from the java based software. Events_P17.xml.txt .

https://www.ostrovni-elektrarny.cz/support/Voltronic/SolarPower_1.14SP7_Windows.rar https://www.ostrovni-elektrarny.cz/support/Voltronic/SolarPowerCS_1.14SP7_Linux_64bit.bin https://www.ostrovni-elektrarny.cz/support/Voltronic/

blacksocket commented 3 years ago

I found also some solution regarding P17 protocol here: https://github.com/wolfgangr/infinitalk/blob/master/P17_def.pl

blacksocket commented 3 years ago

Another implementation of P17 protocol I found on github which seems to be also interesting:

https://github.com/danielschramm/qt_inverter_10k

mdm183 commented 3 years ago

Hi, I am trying to query my inverter, have successfully built the code on my pi and have the inverter connected on USB. Response i get back is no good. I also tried the P17 protocol from the test branch but still the same issue. Here is the output i receive:

root@pk-pi-02:/data/git/inverter-tools/build# ./inverterctl --device usb --verbose --raw "^P003ET" voltronic::Device::send(): writing 8 bytes 0x0000: 5e 50 30 30 33 45 54 0d ^P003ET. voltronic::USBDevice::write(): dataSize=8, writeSize=8 0x0000: 5e 50 30 30 33 45 54 0d ^P003ET. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::recv(): got 5 bytes 0x0000: 5e 30 1b e3 0d ^0... 0x0000: 5e 30 ^0 ^0

mdm183 commented 3 years ago

To add - The Java software i am using is 'Solar Power V1.16SP5'

gch1p commented 3 years ago

@mdm183 what inverter is that?

gch1p commented 3 years ago
root@pk-pi-02:/data/git/inverter-tools/build# ./inverterctl --device usb --verbose --raw "^P003ET"
voltronic::Device::send(): writing 8 bytes
0x0000: 5e 50 30 30 33 45 54 0d ^P003ET.

this is definitely an output from utility compiled from p17 test branch (with disabled crc) and you probably shouldn't use it. Did you try sending ^P005ET using master branch?

mdm183 commented 3 years ago

@gch1p its a 6KW version of the hybrid inverter, running 2 in parallel. I will test the command with the master branch and report back

mdm183 commented 3 years ago

@gch1p Interesting, This time i get 16 bytes back:

root@pk-pi-02:/data/git/inverter-tools/build# ./inverterctl --device usb --verbose --raw "^P005ET" voltronic::Device::send(): writing 10 bytes 0x0000: 5e 50 30 30 35 45 54 4e 91 0d ^P005ETN.. voltronic::USBDevice::write(): dataSize=10, writeSize=8 0x0000: 5e 50 30 30 35 45 54 4e 91 0d ^P005ETN.. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::USBDevice::write(): dataSize=2, writeSize=2 0x0000: 91 0d .. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::recv(): got 16 bytes 0x0000: 5e 44 30 31 31 30 30 34 38 30 33 30 32 a1 5e 0d ^D01100480302.^. 0x0000: 5e 44 30 31 31 30 30 34 38 30 33 30 32 ^D01100480302 ^D01100480302

mdm183 commented 3 years ago

Just to add - I have 2 inverters running in parallel with 1 usb cable connected. I have another solo inverter connected to another USB port. As i can't reference the actual port to connect to (/dev/hidraw0), the outputs may be showing the 2 connected usb ports. I am just interested in getting the parallel ones to talk. Actually i can turn off the other inverter so it doesn't make things complicated!

mdm183 commented 3 years ago

@gch1p ok I have powered off the inverter, new results below, ignore the time-out as that would be the powered off inverter

root@pk-pi-02:/data/git/inverter-tools/build# ./inverterctl --device usb --verbose --raw "^P005ET" voltronic::Device::send(): writing 10 bytes 0x0000: 5e 50 30 30 35 45 54 4e 91 0d ^P005ETN.. voltronic::USBDevice::write(): dataSize=10, writeSize=8 0x0000: 5e 50 30 30 35 45 54 4e 91 0d ^P005ETN.. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::USBDevice::write(): dataSize=2, writeSize=2 0x0000: 91 0d .. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::Device::readLoop(): bytesRead=0 error: timeout: data reading already took 1002 ms

gch1p commented 3 years ago

Interesting, This time i get 16 bytes back

This time it works. Now try something like inverterctl --device usb get-status.

For querying inverters connected in parallel try get-p-status 0 or get-p-status 1 or get-p-status 2... Actually I have just one inverter so I didn't test parallel stuff, I just implemented it according to documentation. Launch inverterctl --help and look for commands that accept id as an argument and try using them.

mdm183 commented 3 years ago

@gch1p OMG - You are a legend. This is now working :) Thank you so much for your help on this. I tried so many different systems but failed with this inverter, your tool has done the trick

mdm183 commented 3 years ago

Do see an issue with the p-status

root@pk-pi-02:/data/git/inverter-tools/build# ./inverterctl --device usb get-p-status 1 error: response is invalid: while parsing p18::response_type::ParallelGeneralStatus: list is expected to be 29 items long, got only 28 items root@pk-pi-02:/data/git/inverter-tools/build# ./inverterctl --device usb get-p-status 1 --verbose voltronic::Device::send(): writing 12 bytes 0x0000: 5e 50 30 30 37 50 47 53 31 39 97 0d ^P007PGS19.. voltronic::USBDevice::write(): dataSize=12, writeSize=8 0x0000: 5e 50 30 30 37 50 47 53 31 39 97 0d ^P007PGS19.. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::USBDevice::write(): dataSize=4, writeSize=4 0x0000: 31 39 97 0d 19.. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::recv(): got 114 bytes 0x0000: 5e 44 31 30 39 31 2c 33 2c 30 30 2c 30 30 30 30 ^D1091,3,00,0000 0x0010: 2c 30 30 30 2c 32 33 30 33 2c 35 30 30 2c 30 36 ,000,2303,500,06 0x0020: 34 34 2c 30 36 30 31 2c 30 31 32 38 38 2c 30 31 44,0601,01288,01 0x0030: 32 30 30 2c 30 31 30 2c 30 31 30 2c 34 39 35 2c 200,010,010,495, 0x0040: 30 31 33 2c 30 30 30 2c 30 30 30 2c 30 36 33 2c 013,000,000,063, 0x0050: 30 30 30 30 2c 30 30 30 30 2c 30 37 36 30 2c 30 0000,0000,0760,0 0x0060: 30 30 30 2c 30 2c 30 2c 31 2c 32 2c 32 2c 30 a1 000,0,0,1,2,2,0. 0x0070: 85 0d .. error: response is invalid: while parsing p18::response_type::ParallelGeneralStatus: list is expected to be 29 items long, got only 28 items

Tried get-p-status 1 / 0 and 2 but still the same.

gch1p commented 3 years ago

hm, ok give me 5 minutes, i'll try to fix it

gch1p commented 3 years ago

I pushed the fix 46c308bc1406ccf7415698ca24e69865022edaee

gch1p commented 3 years ago

If you intend to use it for monitoring, I strongly advise using inverterd instead of inverterctl. inverterd was created exactly for that purpose, it's faster (because you don't spawn a new process everytime you read data) and it puts incoming commands in queue and executes them in order, to avoid race conditions in case there's more than 1 connected client, and this is just a must-have feature. Otherwise, if you launch two inverterctl instances simultaneously and both will try to do something, you'll get usb device lockups, garbage in responses and all kinds of other errors, because the inverter can handle only 1 client at a time and preferably not too fast, at least the one that i have at home (inverterd adds a delay between queries that you can adjust, i use something like 150ms).

I personally use it (among other things) to read the inverter status once a second and build dashboards like this in grafana, works perfecly:

mdm183 commented 3 years ago

@gch1p Hi - yes completely agree. Intension is to use it as a service and get MQTT parsing through to integrate with Grafana and other stuff. Will report back after I pull the new fix.. Thank you once again

mdm183 commented 3 years ago

Thank you - the new build is working perfectly can now query the parallel inverters. Finally I can now continue with my project. Big big thanks!

gch1p commented 3 years ago

You're welcome.

As for the original subject of this ticket, the P17 support, I'm sorry for such enormous delay with it, I've been really busy with my work and other life stuff. I've implemented about 30% of it and then stopped, but I think I'll get back to it soon.

mdm183 commented 3 years ago

Just to add, not a show stopper, but something I guess as I am testing out parallel, found another similar issue,

exec get-p-rated 0 err {"result":"error","message":"response is invalid: while parsing p18::response_type::ParallelRatedInformation: item 5 is expected to be 2 characters long, got 3 characters"}

exec get-p-rated 1 err {"result":"error","message":"response is invalid: while parsing p18::response_type::ParallelRatedInformation: item 5 is expected to be 2 characters long, got 3 characters"}

gch1p commented 3 years ago

Can you get the verbose output, with the actual response of your inverter?

mdm183 commented 3 years ago

here you go

root@pk-pi-02:/data/git/inverter-tools/build# ./inverterctl --device usb get-p-rated 1 --verbose voltronic::Device::send(): writing 12 bytes 0x0000: 5e 50 30 30 37 50 52 49 31 7d bc 0d ^P007PRI1}.. voltronic::USBDevice::write(): dataSize=12, writeSize=8 0x0000: 5e 50 30 30 37 50 52 49 31 7d bc 0d ^P007PRI1}.. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::USBDevice::write(): dataSize=4, writeSize=4 0x0000: 31 7d bc 0d 1}.. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::recv(): got 45 bytes 0x0000: 5e 44 30 34 30 31 2c 31 34 2c 39 36 31 34 32 31 ^D0401,14,961421 0x0010: 30 37 31 30 30 34 32 31 30 30 30 30 30 30 2c 30 07100421000000,0 0x0020: 2c 30 33 30 2c 30 33 30 2c 31 8d dc 0d ,030,030,1... error: response is invalid: while parsing p18::response_type::ParallelRatedInformation: item 5 is expected to be 2 characters long, got 3 characters

gch1p commented 3 years ago

fixed

mdm183 commented 3 years ago

nice one dude - will check. Another bug found - missing inverter temperature from parallel command, do see a max temp which is 0, when i run the normal get-status i can see the temperature. Here is the verbose:

root@pk-pi-02:/data/git/inverter-tools/build# ./inverterctl --device usb --format table get-p-status 1 --verbose voltronic::Device::send(): writing 12 bytes 0x0000: 5e 50 30 30 37 50 47 53 31 39 97 0d ^P007PGS19.. voltronic::USBDevice::write(): dataSize=12, writeSize=8 0x0000: 5e 50 30 30 37 50 47 53 31 39 97 0d ^P007PGS19.. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::USBDevice::write(): dataSize=4, writeSize=4 0x0000: 31 39 97 0d 19.. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::recv(): got 114 bytes 0x0000: 5e 44 31 30 39 31 2c 33 2c 30 30 2c 30 30 30 30 ^D1091,3,00,0000 0x0010: 2c 30 30 30 2c 32 33 30 33 2c 34 39 39 2c 30 36 ,000,2303,499,06 0x0020: 36 37 2c 30 36 31 31 2c 30 31 32 38 38 2c 30 31 67,0611,01288,01 0x0030: 32 30 30 2c 30 31 31 2c 30 31 30 2c 34 37 38 2c 200,011,010,478, 0x0040: 30 31 33 2c 30 30 30 2c 30 30 30 2c 30 34 36 2c 013,000,000,046, 0x0050: 30 30 30 30 2c 30 30 30 30 2c 30 37 31 38 2c 30 0000,0000,0718,0 0x0060: 30 30 30 2c 30 2c 30 2c 31 2c 32 2c 32 2c 30 f0 000,0,0,1,2,2,0. 0x0070: 16 0d .. Parallel ID connection status: Existent Working mode: Battery mode Fault code: 0 Grid voltage: 0 V Grid frequency: 0 Hz AC output voltage: 230.3 V AC output frequency: 49.9 Hz AC output apparent power: 667 VA AC output active power: 611 Wh Total AC output apparent power: 1288 VA Total AC output active power: 1200 Wh Output load percent: 11 % Total output load percent: 10 % Battery voltage: 47.8 V Battery discharge current: 13 A Battery charging current: 0 A PV1 Input power: 0 Wh PV2 Input power: 0 Wh PV1 Input voltage: 71.8 V PV2 Input voltage: 0 V MPPT1 charger status: Abnormal MPPT2 charger status: Abnormal Load connection: Connected Battery power direction: Discharge DC/AC power direction: DC/AC Line power direction: Do nothing Max. temperature: 0

mdm183 commented 3 years ago

And this is the output from the get-status, you can see the inverter temperature is there:

root@pk-pi-02:/data/git/inverter-tools/build# ./inverterctl --device usb --format table get-status --verbose voltronic::Device::send(): writing 10 bytes 0x0000: 5e 50 30 30 35 47 53 58 14 0d ^P005GSX.. voltronic::USBDevice::write(): dataSize=10, writeSize=8 0x0000: 5e 50 30 30 35 47 53 58 14 0d ^P005GSX.. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::USBDevice::write(): dataSize=2, writeSize=2 0x0000: 14 0d .. voltronic::Device::writeLoop(): bytesWritten=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::readLoop(): bytesRead=8 voltronic::Device::recv(): got 111 bytes 0x0000: 5e 44 31 30 36 30 30 30 30 2c 30 30 30 2c 32 33 ^D1060000,000,23 0x0010: 30 33 2c 35 30 30 2c 30 36 34 34 2c 30 35 39 31 03,500,0644,0591 0x0020: 2c 30 31 30 2c 34 37 37 2c 30 30 30 2c 30 30 30 ,010,477,000,000 0x0030: 2c 30 31 34 2c 30 30 30 2c 30 34 35 2c 30 33 33 ,014,000,045,033 0x0040: 2c 30 30 30 2c 30 30 30 2c 30 30 30 30 2c 30 30 ,000,000,0000,00 0x0050: 30 30 2c 30 30 30 30 2c 30 30 30 30 2c 30 2c 30 00,0000,0000,0,0 0x0060: 2c 30 2c 31 2c 32 2c 32 2c 30 2c 30 0b 5c 0d ,0,1,2,2,0,0.. Grid voltage: 0 V Grid frequency: 0 Hz AC output voltage: 230.3 V AC output frequency: 50 Hz AC output apparent power: 644 VA AC output active power: 591 Wh Output load percent: 10 % Battery voltage: 47.7 V Battery voltage from SCC: 0 V Battery voltage from SCC2: 0 V Battery discharging current: 14 A Battery charging current: 0 A Battery capacity: 45 % Inverter heat sink temperature: 33 °C MPPT1 charger temperature: 0 °C MPPT2 charger temperature: 0 °C PV1 input power: 0 Wh PV2 input power: 0 Wh PV1 input voltage: 0 V PV2 input voltage: 0 V Configuration state: Default MPPT1 charger status: Abnormal MPPT2 charger status: Abnormal Load connection: Connected Battery power direction: Discharge DC/AC power direction: DC/AC Line power direction: Do nothing Local parallel ID: 0

gch1p commented 3 years ago

Another bug found - missing inverter temperature from parallel command, do see a max temp which is 0, when i run the normal get-status i can see the temperature. Here is the verbose:

This is actually what I "fixed" earlier, when inverterctl said it was expecting 29 items but found only 28. Your inverter doesn't report that temperature so the value stays zero. You should just ignore it I guess.

The temperature should be the last field, but in the protocol documentation it's marked in red (see that red bbb?) image image

I don't know what exactly red means, the docs doesn't say, but now I think it means that this field is optional and may be missing on some inverters.

mdm183 commented 3 years ago

@gch1p ok thanks, yeah must be some optional thing. I will re-compile the changes shortly...cheers

gch1p commented 3 years ago

@mdm183 can you please tell me how exactly your inverter is called? Its full name. I'll add it to the list of tested devices

mdm183 commented 3 years ago

Sure, its known as Crown 6KW Axpert VMII Hybrid Inverter (knock off of the same MPP-solar inverter), was purchased for my dads house in Pakistan https://coollineenergy.com/product/crown-micro-elego-6kw-solar-hybrid-inverter/