Skip to content

Commit

Permalink
inverter-cli: Add more commands for -r flag
Browse files Browse the repository at this point in the history
Accept the QPI, QID, QVFW, QVFW2, QFLAG, QBOOT, and QOPM commands.

ned-kelly#76
  • Loading branch information
dilyanpalauzov committed Aug 25, 2022
1 parent 25e24a6 commit 313d6f4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sources/inverter-cli/inverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,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();
Expand Down
2 changes: 1 addition & 1 deletion sources/inverter-cli/inverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 18 additions & 1 deletion sources/inverter-cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <pthread.h>
#include <signal.h>
#include <string.h>

#include <iostream>
#include <string>
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 313d6f4

Please sign in to comment.