kopia lustrzana https://github.com/weetmuts/wmbusmeters
Make a distinction between not yet opened and not working serial devices.
rodzic
ecd60045d9
commit
0d9d856b6a
|
@ -39,7 +39,7 @@ constexpr uint8_t ERROR_CODE_FREQUENCY_OUT_OF_RANGE=0x40;
|
|||
|
||||
|
||||
struct MeterEM24 : public virtual ElectricityMeter, public virtual MeterCommonImplementation {
|
||||
MeterEM24(WMBus *bus, MeterInfo &mi);
|
||||
MeterEM24(MeterInfo &mi);
|
||||
|
||||
double totalEnergyConsumption(Unit u);
|
||||
double totalEnergyProduction(Unit u);
|
||||
|
@ -64,13 +64,13 @@ private:
|
|||
uint8_t error_codes_ {};
|
||||
};
|
||||
|
||||
unique_ptr<ElectricityMeter> createEM24(WMBus *bus, MeterInfo &mi)
|
||||
shared_ptr<ElectricityMeter> createEM24(MeterInfo &mi)
|
||||
{
|
||||
return unique_ptr<ElectricityMeter>(new MeterEM24(bus, mi));
|
||||
return shared_ptr<ElectricityMeter>(new MeterEM24(mi));
|
||||
}
|
||||
|
||||
MeterEM24::MeterEM24(WMBus *bus, MeterInfo &mi) :
|
||||
MeterCommonImplementation(bus, mi, MeterType::EM24)
|
||||
MeterEM24::MeterEM24(MeterInfo &mi) :
|
||||
MeterCommonImplementation(mi, MeterType::EM24)
|
||||
{
|
||||
setExpectedELLSecurityMode(ELLSecurityMode::AES_CTR);
|
||||
|
||||
|
@ -173,7 +173,7 @@ void MeterEM24::processContent(Telegram *t)
|
|||
// 75 vife (Cold / Warm Temperature Limit 10^-2 Celsius)
|
||||
extractDVdouble(&t->values, "04FB8275", &offset, &total_reactive_energy_consumption_kvarh_);
|
||||
t->addMoreExplanation(offset, " total reactive power (%f kvarh)", total_reactive_energy_consumption_kvarh_);
|
||||
|
||||
|
||||
// 04 dif (32 Bit Integer/Binary Instantaneous value)
|
||||
// 85 vif (Energy 10² Wh)
|
||||
// 3C vife (backward flow)
|
||||
|
@ -187,7 +187,7 @@ void MeterEM24::processContent(Telegram *t)
|
|||
// 3C vife (Reserved)
|
||||
extractDVdouble(&t->values, "04FB82F53C", &offset, &total_reactive_energy_production_kvarh_);
|
||||
t->addMoreExplanation(offset, " total reactive power (%f kvarh)", total_reactive_energy_production_kvarh_);
|
||||
|
||||
|
||||
// 01 dif (8 Bit Integer/Binary Instantaneous value)
|
||||
// FD vif (Second extension of VIF-codes)
|
||||
// 17 vife (Error flags (binary))
|
||||
|
|
|
@ -149,6 +149,7 @@ struct SerialDeviceImp : public SerialDevice
|
|||
void fill(vector<uchar> &data) {};
|
||||
int receive(vector<uchar> *data);
|
||||
bool working() { return fd_ != -1; }
|
||||
bool opened() { return fd_ != -2; }
|
||||
bool readonly() { return is_stdin_ || is_file_; }
|
||||
|
||||
void expectAscii() { expecting_ascii_ = true; }
|
||||
|
@ -174,7 +175,7 @@ protected:
|
|||
|
||||
function<void()> on_data_;
|
||||
function<void()> on_disappear_;
|
||||
int fd_ = -1;
|
||||
int fd_ = -2; // -2 not yet opened, -1 not working
|
||||
bool expecting_ascii_ {}; // If true, print using safeString instead if bin2hex
|
||||
bool is_file_ = false;
|
||||
bool is_stdin_ = false;
|
||||
|
|
|
@ -44,6 +44,7 @@ struct SerialDevice
|
|||
// Receive returns the number of bytes received.
|
||||
virtual int receive(std::vector<uchar> *data) = 0;
|
||||
virtual int fd() = 0;
|
||||
virtual bool opened() = 0;
|
||||
virtual bool working() = 0;
|
||||
// Used when connecting stdin to a tty driver for testing.
|
||||
virtual bool readonly() = 0;
|
||||
|
|
|
@ -3345,7 +3345,7 @@ bool WMBusCommonImplementation::reset()
|
|||
bool resetting = false;
|
||||
if (serial())
|
||||
{
|
||||
if (serial()->working())
|
||||
if (serial()->opened() && serial()->working())
|
||||
{
|
||||
// This is a reset, not an init. Close the serial device.
|
||||
resetting = true;
|
||||
|
|
Ładowanie…
Reference in New Issue