diff --git a/sources/inverter-cli/inverter.cpp b/sources/inverter-cli/inverter.cpp index d7e6f53..2b4b6ee 100644 --- a/sources/inverter-cli/inverter.cpp +++ b/sources/inverter-cli/inverter.cpp @@ -205,9 +205,9 @@ void cInverter::poll() { } } -void cInverter::ExecuteCmd(const string cmd) { +void cInverter::ExecuteCmd(const string cmd, int replylen) { // Sending any command raw - if (query(cmd.data(), 7)) { + if (query(cmd.data(), replylen)) { m.lock(); strcpy(status2, (const char*)buf+1); m.unlock(); diff --git a/sources/inverter-cli/inverter.h b/sources/inverter-cli/inverter.h index 3501b6b..6b47c62 100644 --- a/sources/inverter-cli/inverter.h +++ b/sources/inverter-cli/inverter.h @@ -35,7 +35,7 @@ class cInverter { string *GetWarnings(); int GetMode(); - void ExecuteCmd(const std::string cmd); + void ExecuteCmd(const std::string cmd, int); }; #endif // ___INVERTER_H diff --git a/sources/inverter-cli/main.cpp b/sources/inverter-cli/main.cpp index 2c7cbbb..40ac9e2 100644 --- a/sources/inverter-cli/main.cpp +++ b/sources/inverter-cli/main.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -177,7 +178,23 @@ int main(int argc, char* argv[]) { // Logic to send 'raw commands' to the inverter.. if (!rawcmd.empty()) { - ups->ExecuteCmd(rawcmd); + int replylen; + if (!strcmp(rawcmd.c_str(), "QPI")) + replylen = 8; + else if (!strcmp(rawcmd.c_str(), "QID")) + replylen = 18; + else if (!strcmp(rawcmd.c_str(), "QVFW")) + replylen = 18; + else if (!strcmp(rawcmd.c_str(), "QVFW2")) + replylen = 19; + else if (!strcmp(rawcmd.c_str(), "QFLAG")) + replylen = 15; + else if (!strcmp(rawcmd.c_str(), "QBOOT")) + replylen = 5; + else if (!strcmp(rawcmd.c_str(), "QOPM")) + replylen = 6; + else replylen = 7; + ups->ExecuteCmd(rawcmd, replylen); // We're piggybacking off the qpri status response... printf("Reply: %s\n", ups->GetQpiriStatus()->c_str()); exit(0);