unify decode output result+log, fix special broadcast write output
This commit is contained in:
+27
-22
@@ -864,11 +864,18 @@ result_t MainLoop::executeRead(const vector<string>& args, const string& levels,
|
|||||||
}
|
}
|
||||||
ret = cacheMessage->decodeLastData(pt_any, false, fieldIndex == -2 ? nullptr : fieldName.c_str(), fieldIndex, verbosity,
|
ret = cacheMessage->decodeLastData(pt_any, false, fieldIndex == -2 ? nullptr : fieldName.c_str(), fieldIndex, verbosity,
|
||||||
ostream);
|
ostream);
|
||||||
if (ret != RESULT_OK) {
|
if (ret < RESULT_OK) {
|
||||||
if (ret < RESULT_OK) {
|
logError(lf_main, "read %s %s cached: decode %s", cacheMessage->getCircuit().c_str(),
|
||||||
logError(lf_main, "read %s %s cached: %s", cacheMessage->getCircuit().c_str(),
|
cacheMessage->getName().c_str(), getResultCode(ret));
|
||||||
cacheMessage->getName().c_str(), getResultCode(ret));
|
const auto str = ostream->str();
|
||||||
|
ostream->str("");
|
||||||
|
*ostream << getResultCode(ret) << " in decode";
|
||||||
|
if (!str.empty()) {
|
||||||
|
*ostream << ": " << str;
|
||||||
}
|
}
|
||||||
|
return RESULT_OK;
|
||||||
|
}
|
||||||
|
if (ret > RESULT_OK) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
logInfo(lf_main, "read %s %s cached: %s", cacheMessage->getCircuit().c_str(), cacheMessage->getName().c_str(),
|
logInfo(lf_main, "read %s %s cached: %s", cacheMessage->getCircuit().c_str(), cacheMessage->getName().c_str(),
|
||||||
@@ -900,8 +907,12 @@ result_t MainLoop::executeRead(const vector<string>& args, const string& levels,
|
|||||||
if (ret < RESULT_OK) {
|
if (ret < RESULT_OK) {
|
||||||
logError(lf_main, "read %s %s: decode %s", message->getCircuit().c_str(), message->getName().c_str(),
|
logError(lf_main, "read %s %s: decode %s", message->getCircuit().c_str(), message->getName().c_str(),
|
||||||
getResultCode(ret));
|
getResultCode(ret));
|
||||||
|
const auto str = ostream->str();
|
||||||
ostream->str("");
|
ostream->str("");
|
||||||
*ostream << getResultCode(ret) << " in decode";
|
*ostream << getResultCode(ret) << " in decode";
|
||||||
|
if (!str.empty()) {
|
||||||
|
*ostream << ": " << str;
|
||||||
|
}
|
||||||
return RESULT_OK;
|
return RESULT_OK;
|
||||||
}
|
}
|
||||||
if (ret > RESULT_OK) {
|
if (ret > RESULT_OK) {
|
||||||
@@ -1077,32 +1088,26 @@ result_t MainLoop::executeWrite(const vector<string>& args, const string levels,
|
|||||||
getResultCode(ret));
|
getResultCode(ret));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
dstAddress = message->getLastMasterData().dataAt(1);
|
dstAddress = message->getLastMasterData()[1];
|
||||||
if (dstAddress == BROADCAST || isMaster(dstAddress)) {
|
|
||||||
logNotice(lf_main, "write %s %s: %s", message->getCircuit().c_str(), message->getName().c_str(),
|
|
||||||
getResultCode(ret));
|
|
||||||
if (dstAddress == BROADCAST) {
|
|
||||||
*ostream << "done broadcast";
|
|
||||||
}
|
|
||||||
return RESULT_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = message->decodeLastData(pt_any, false, nullptr, -1, OF_NONE, ostream); // decode data
|
ret = message->decodeLastData(pt_any, false, nullptr, -1, OF_NONE, ostream); // decode data
|
||||||
if (ret >= RESULT_OK && ostream->str().empty()) {
|
if (ret < RESULT_OK) {
|
||||||
logNotice(lf_main, "write %s %s: decode %s", message->getCircuit().c_str(), message->getName().c_str(),
|
|
||||||
getResultCode(ret));
|
|
||||||
return RESULT_OK;
|
|
||||||
}
|
|
||||||
if (ret != RESULT_OK) {
|
|
||||||
logError(lf_main, "write %s %s: decode %s", message->getCircuit().c_str(), message->getName().c_str(),
|
logError(lf_main, "write %s %s: decode %s", message->getCircuit().c_str(), message->getName().c_str(),
|
||||||
getResultCode(ret));
|
getResultCode(ret));
|
||||||
ostream->str("");
|
ostream->str("");
|
||||||
*ostream << getResultCode(ret) << " in decode";
|
*ostream << getResultCode(ret) << " in decode";
|
||||||
return RESULT_OK;
|
return RESULT_OK;
|
||||||
}
|
}
|
||||||
logNotice(lf_main, "write %s %s: %s", message->getCircuit().c_str(), message->getName().c_str(),
|
if (dstAddress == BROADCAST && ostream->tellp() == 0) {
|
||||||
ostream->str().c_str());
|
if (ret == RESULT_OK) {
|
||||||
return RESULT_OK;
|
*ostream << getResultCode(ret) << " ";
|
||||||
|
}
|
||||||
|
*ostream << "broadcast";
|
||||||
|
}
|
||||||
|
string code = ret == RESULT_OK ? "" : (string(getResultCode(ret)) + " ");
|
||||||
|
logNotice(lf_main, "write %s %s: %s%s", message->getCircuit().c_str(), message->getName().c_str(),
|
||||||
|
code.c_str(), ostream->str().c_str());
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
result_t MainLoop::parseHexAndSend(const vector<string>& args, size_t& argPos, bool isDirectMode,
|
result_t MainLoop::parseHexAndSend(const vector<string>& args, size_t& argPos, bool isDirectMode,
|
||||||
|
|||||||
Reference in New Issue
Block a user