From b39eeb52eb2c398f4f951c58219e406efbde5ba1 Mon Sep 17 00:00:00 2001 From: Raphael Pertl Date: Sat, 22 Feb 2020 23:04:00 +0100 Subject: [PATCH] fix example config, cpp errors, tested with voltronic 5000 and qpiri 102 --- config/inverter.conf | 4 ++++ sources/inverter-cli/inverter.cpp | 4 +++- sources/inverter-cli/inverter.h | 4 +--- sources/inverter-cli/main.cpp | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/config/inverter.conf b/config/inverter.conf index 5d45fb4..b59d8dc 100644 --- a/config/inverter.conf +++ b/config/inverter.conf @@ -21,3 +21,7 @@ amperage_factor=1.0 # This allos 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 + +# 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 diff --git a/sources/inverter-cli/inverter.cpp b/sources/inverter-cli/inverter.cpp index cb553b2..c5240dd 100644 --- a/sources/inverter-cli/inverter.cpp +++ b/sources/inverter-cli/inverter.cpp @@ -9,12 +9,13 @@ #include #include -cInverter::cInverter(std::string devicename) { +cInverter::cInverter(std::string devicename, int qpiri) { device = devicename; status1[0] = 0; status2[0] = 0; warnings[0] = 0; mode = 0; + qpiri = qpiri; } string *cInverter::GetQpigsStatus() { @@ -153,6 +154,7 @@ bool cInverter::query(const char *cmd, int replysize) { void cInverter::poll() { int n,j; + extern const int qpiri; while (true) { diff --git a/sources/inverter-cli/inverter.h b/sources/inverter-cli/inverter.h index a978a4f..125f2da 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); + cInverter(std::string devicename, int qpiri); void poll(); void runMultiThread() { std::thread t1(&cInverter::poll, this); @@ -34,8 +34,6 @@ class cInverter { string *GetQpigsStatus(); string *GetWarnings(); - int qpiri; - int GetMode(); void ExecuteCmd(const std::string cmd); }; diff --git a/sources/inverter-cli/main.cpp b/sources/inverter-cli/main.cpp index 4cb0b04..e54c741 100644 --- a/sources/inverter-cli/main.cpp +++ b/sources/inverter-cli/main.cpp @@ -174,7 +174,7 @@ int main(int argc, char* argv[]) { } bool ups_status_changed(false); - ups = new cInverter(devicename); + ups = new cInverter(devicename,qpiri); // Logic to send 'raw commands' to the inverter.. if (!rawcmd.empty()) {