From b25795841ebaf6fc62d584d94b134d35d7f18732 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Tue, 10 Mar 2020 09:41:44 +0200 Subject: [PATCH 1/5] Correct minor typo on watt_factor comment --- config/inverter.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/inverter.conf b/config/inverter.conf index b59d8dc..c5976d9 100644 --- a/config/inverter.conf +++ b/config/inverter.conf @@ -18,7 +18,7 @@ run_interval=120 # reading compared to measurement tools. Normally this will remain '1' amperage_factor=1.0 -# This allos you to modify the wattage in case the inverter is giving an incorrect +# This allows you to modify the wattage in case the inverter is giving an incorrect # reading compared to measurement tools. Normally this will remain '1' watt_factor=1.01 From dfbb0ecc0688ee47078f159e4007669523f4a80d Mon Sep 17 00:00:00 2001 From: Maxwell Date: Tue, 10 Mar 2020 09:52:13 +0200 Subject: [PATCH 2/5] Add additional configurable parameters for buffers Adds additional `qpiws`, `qmod` and `qpigs` parameters with default values used in source code, these values are currently based on the **skymax** inverter --- config/inverter.conf | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/config/inverter.conf b/config/inverter.conf index c5976d9..3b8ecb7 100644 --- a/config/inverter.conf +++ b/config/inverter.conf @@ -22,6 +22,21 @@ amperage_factor=1.0 # reading compared to measurement tools. Normally this will remain '1' watt_factor=1.01 + +# The following settings allow you to modify runtime buffers. +# N.B. These values may not be applicable to all inverter types, as such you will +# need to run docker exec -it voltronic-mqtt bash -c '/opt/inverter-cli/bin/inverter_poller -d -1' +# or simply inverter_poller -d -1 to check for warnings or errors +# mentioned in https://github.com/ned-kelly/docker-voltronic-homeassistant/issues/5 + # This allows you to modify the buffersize for the qpiri command -# as mentioned in https://github.com/ned-kelly/docker-voltronic-homeassistant/issues/5 qpiri=97 + +# This allows you to modify the buffersize for the qpiws command +qpiws=36 + +# This allows you to modify the buffersize for the qmod command +qmod=5 + +# This allows you to modify the buffersize for the qpigs command +qpigs=110 \ No newline at end of file From f7896ecd7e17fe98a7053dfc577cdab9000f9141 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Tue, 10 Mar 2020 09:59:22 +0200 Subject: [PATCH 3/5] Add additional fields to cInverter parameterized constructor Adds the capability to use non static values for `QPIWS`, `QMOD` and `QPIGS` commands --- sources/inverter-cli/inverter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/inverter-cli/inverter.h b/sources/inverter-cli/inverter.h index 125f2da..3501b6b 100644 --- a/sources/inverter-cli/inverter.h +++ b/sources/inverter-cli/inverter.h @@ -23,7 +23,7 @@ class cInverter { uint16_t cal_crc_half(uint8_t *pin, uint8_t len); public: - cInverter(std::string devicename, int qpiri); + cInverter(std::string devicename, int qpiri, int qpiws, int qmod, int qpigs); void poll(); void runMultiThread() { std::thread t1(&cInverter::poll, this); From de8bc8f8129d6c5330e0bf90d233c8be257b1942 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Tue, 10 Mar 2020 10:02:25 +0200 Subject: [PATCH 4/5] Update inverter.cpp allowing the usage of configured parameters See commit: f7896ecd7e17fe98a7053dfc577cdab9000f9141 --- sources/inverter-cli/inverter.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sources/inverter-cli/inverter.cpp b/sources/inverter-cli/inverter.cpp index c5240dd..45711f4 100644 --- a/sources/inverter-cli/inverter.cpp +++ b/sources/inverter-cli/inverter.cpp @@ -9,13 +9,16 @@ #include #include -cInverter::cInverter(std::string devicename, int qpiri) { +cInverter::cInverter(std::string devicename, int qpiri, int qpiws, int qmod, int qpigs) { device = devicename; status1[0] = 0; status2[0] = 0; warnings[0] = 0; mode = 0; qpiri = qpiri; + qpiws = qpiws; + qmod = qmod; + qpigs = qpigs; } string *cInverter::GetQpigsStatus() { @@ -154,13 +157,13 @@ bool cInverter::query(const char *cmd, int replysize) { void cInverter::poll() { int n,j; - extern const int qpiri; + extern const int qpiri, qpiws, qmod, qpigs; while (true) { // Reading mode if (!ups_qmod_changed) { - if (query("QMOD", 5)) { + if (query("QMOD", qmod)) { SetMode(buf[1]); ups_qmod_changed = true; } @@ -168,7 +171,7 @@ void cInverter::poll() { // reading status (QPIGS) if (!ups_qpigs_changed) { - if (query("QPIGS", 110)) { + if (query("QPIGS", qpigs)) { m.lock(); strcpy(status1, (const char*)buf+1); m.unlock(); @@ -188,7 +191,7 @@ void cInverter::poll() { // Get any device warnings... if (!ups_qpiws_changed) { - if (query("QPIWS", 36)) { + if (query("QPIWS", qpiws)) { m.lock(); strcpy(warnings, (const char*)buf+1); m.unlock(); From 6b5c5d600ab58eced107d51f4232d95a382bed88 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Tue, 10 Mar 2020 10:05:45 +0200 Subject: [PATCH 5/5] Load command buffer sizes from configuration Sets values for qpiws, qmod and qpigs from configuration file if they are available. See commit: dfbb0ecc0688ee47078f159e4007669523f4a80d --- sources/inverter-cli/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sources/inverter-cli/main.cpp b/sources/inverter-cli/main.cpp index e54c741..7650fab 100644 --- a/sources/inverter-cli/main.cpp +++ b/sources/inverter-cli/main.cpp @@ -43,7 +43,7 @@ string devicename; int runinterval; float ampfactor; float wattfactor; -int qpiri; +int qpiri, qpiws, qmod, qpigs; // --------------------------------------- @@ -93,6 +93,12 @@ void getSettingsFile(string filename) { attemptAddSetting(&wattfactor, linepart2); else if(linepart1 == "qpiri") attemptAddSetting(&qpiri, linepart2); + else if(linepart1 == "qpiws") + attemptAddSetting(&qpiws, linepart2); + else if(linepart1 == "qmod") + attemptAddSetting(&qmod, linepart2); + else if(linepart1 == "qpigs") + attemptAddSetting(&qpigs, linepart2); else continue; } @@ -174,7 +180,7 @@ int main(int argc, char* argv[]) { } bool ups_status_changed(false); - ups = new cInverter(devicename,qpiri); + ups = new cInverter(devicename,qpiri,qpiws,qmod,qpigs); // Logic to send 'raw commands' to the inverter.. if (!rawcmd.empty()) {