Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inverter_poller: Add more commands for -r flag #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sources/inverter-cli/inverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,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 @@ -184,7 +185,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