Skip to content

Commit

Permalink
allow define in write direction if given more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
john30 committed Jun 28, 2024
1 parent a8362bd commit 20982e5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ebusd/mainloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ result_t MainLoop::executeAuth(const vector<string>& args, string* user, ostring

result_t MainLoop::executeRead(const vector<string>& args, const string& levels, ostringstream* ostream) {
size_t argPos = 1;
bool hex = false, newDefinition = false;
bool hex = false, newDefinition = false, writeDirection = false;
OutputFormat verbosity = OF_NONE;
time_t maxAge = 5*60;
string circuit, params;
Expand All @@ -627,6 +627,9 @@ result_t MainLoop::executeRead(const vector<string>& args, const string& levels,
*ostream << "ERR: option not enabled";
return RESULT_OK;
}
if (newDefinition) {
writeDirection = true;
}
newDefinition = true;
} else if (args[argPos] == "-f") {
maxAge = 0;
Expand Down Expand Up @@ -742,7 +745,7 @@ result_t MainLoop::executeRead(const vector<string>& args, const string& levels,
" NAME NAME of the message to send\n"
" FIELD only retrieve the field named FIELD\n"
" N only retrieve the N'th field named FIELD (0-based)\n"
" -def read with explicit message definition (only if enabled):\n"
" -def read with explicit message definition (only if enabled, allow write direction if given more than once):\n"
" DEFINITION message definition to use instead of known definition\n"
" -h send hex read message (or answer from cache):\n"
" ZZ destination address\n"
Expand Down Expand Up @@ -842,9 +845,9 @@ result_t MainLoop::executeRead(const vector<string>& args, const string& levels,
return RESULT_OK;
}
deque<Message*> messages;
m_newlyDefinedMessages->findAll("", "", levels, false, true, false, false, true, false, 0, 0, false, &messages);
m_newlyDefinedMessages->findAll("", "", levels, false, true, writeDirection, false, true, false, 0, 0, false, &messages);
if (messages.empty()) {
*ostream << "ERR: bad definition: no read message";
*ostream << "ERR: bad definition: no read" << (writeDirection?"/write":"") << " message";
return RESULT_OK;
}
message = *messages.begin();
Expand Down

0 comments on commit 20982e5

Please sign in to comment.