Print id for ignored telegrams when verbose logging.

pull/156/head
Fredrik Öhrström 2020-09-25 19:14:34 +02:00
rodzic 27bda218fb
commit 0e076fce24
3 zmienionych plików z 10 dodań i 5 usunięć

Wyświetl plik

@ -79,14 +79,15 @@ struct MeterManagerImplementation : public virtual MeterManager
bool handled = false;
string id;
for (auto &m : meters_)
{
bool h = m->handleTelegram(data, simulated);
bool h = m->handleTelegram(data, simulated, &id);
if (h) handled = true;
}
if (isVerboseEnabled() && !handled)
{
verbose("(wmbus) telegram ignored by all configured meters!\n");
verbose("(wmbus) telegram from %s ignored by all configured meters!\n", id.c_str());
}
return handled;
}
@ -427,19 +428,23 @@ string concatFields(Meter *m, Telegram *t, char c, vector<Print> &prints, vector
return s;
}
bool MeterCommonImplementation::handleTelegram(vector<uchar> input_frame, bool simulated)
bool MeterCommonImplementation::handleTelegram(vector<uchar> input_frame, bool simulated, string *id)
{
Telegram t;
bool ok = t.parseHeader(input_frame);
if (simulated) t.markAsSimulated();
*id = t.id;
if (!ok || !isTelegramForMe(&t))
{
// This telegram is not intended for this meter.
return false;
}
verbose("(meter) %s %s handling telegram from %s\n", name().c_str(), meterName().c_str(), t.id.c_str());
if (isDebugEnabled())
{
string msg = bin2hex(input_frame);

Wyświetl plik

@ -222,7 +222,7 @@ struct Meter
// The handleTelegram expects an input_frame where the DLL crcs have been removed.
// Returns true of this meter handled this telegram!
virtual bool handleTelegram(vector<uchar> input_frame, bool simulated) = 0;
virtual bool handleTelegram(vector<uchar> input_frame, bool simulated, string *id) = 0;
virtual bool isTelegramForMe(Telegram *t) = 0;
virtual MeterKeys *meterKeys() = 0;

Wyświetl plik

@ -74,7 +74,7 @@ protected:
// Print the dimensionless Text quantity, no unit is needed.
void addPrint(string vname, Quantity vquantity,
function<std::string()> getValueFunc, string help, bool field, bool json);
bool handleTelegram(vector<uchar> frame, bool simulated);
bool handleTelegram(vector<uchar> frame, bool simulated, string *id);
void printMeter(Telegram *t,
string *human_readable,
string *fields, char separator,