Fixed autodetect

This commit is contained in:
Gunnar Skjold
2024-11-06 18:10:38 +01:00
parent fa5985f60b
commit 118c633878
7 changed files with 15 additions and 2 deletions

View File

@@ -32,6 +32,7 @@ public:
AmsData* getData(AmsData& meterState);
int getLastError();
bool isConfigChanged() { return false; }
void ackConfigChanged() {}
void getCurrentConfig(MeterConfig& meterConfig) {
meterConfig = this->meterConfig;
}

View File

@@ -22,6 +22,7 @@ public:
virtual AmsData* getData(AmsData& meterState);
virtual int getLastError();
virtual bool isConfigChanged();
virtual void ackConfigChanged();
virtual void getCurrentConfig(MeterConfig& meterConfig);
};

View File

@@ -34,6 +34,7 @@ public:
AmsData* getData(AmsData& meterState);
int getLastError();
bool isConfigChanged();
void ackConfigChanged();
void getCurrentConfig(MeterConfig& meterConfig);
void setPassthroughMqttHandler(PassthroughMqttHandler*);

View File

@@ -27,6 +27,7 @@ public:
AmsData* getData(AmsData& meterState);
int getLastError();
bool isConfigChanged();
void ackConfigChanged();
void getCurrentConfig(MeterConfig& meterConfig);
void onPulse(uint8_t pulses);

View File

@@ -306,11 +306,14 @@ bool PassiveMeterCommunicator::isConfigChanged() {
return configChanged;
}
void PassiveMeterCommunicator::ackConfigChanged() {
configChanged = false;
}
void PassiveMeterCommunicator::getCurrentConfig(MeterConfig& meterConfig) {
meterConfig = this->meterConfig;
}
int16_t PassiveMeterCommunicator::unwrapData(uint8_t *buf, DataParserContext &context) {
int16_t ret = 0;
bool doRet = false;
@@ -578,7 +581,7 @@ void PassiveMeterCommunicator::setupHanPort(uint32_t baud, uint8_t parityOrdinal
int8_t txpin = passive ? -1 : meterConfig.txPin;
if(baud == 0) {
baud = 2400;
autodetectBaud = baud = 2400;
}
#if defined(AMS_REMOTE_DEBUG)

View File

@@ -47,6 +47,10 @@ bool PulseMeterCommunicator::isConfigChanged() {
return this->configChanged;
}
void PulseMeterCommunicator::ackConfigChanged() {
configChanged = false;
}
void PulseMeterCommunicator::getCurrentConfig(MeterConfig& meterConfig) {
meterConfig = this->meterConfig;
}

View File

@@ -1307,6 +1307,7 @@ bool readHanPort() {
if(mc->isConfigChanged()) {
mc->getCurrentConfig(meterConfig);
config.setMeterConfig(meterConfig);
mc->ackConfigChanged();
}
meterState.setLastError(mc->getLastError());
@@ -1667,6 +1668,7 @@ void configFileParse() {
meter.baud = String(buf+10).toInt();
} else if(strncmp_P(buf, PSTR("meterParity "), 12) == 0) {
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
meter.parity = 0;
if(strncmp_P(buf+12, PSTR("7N1"), 3) == 0) meter.parity = 2;
if(strncmp_P(buf+12, PSTR("8N1"), 3) == 0) meter.parity = 3;
if(strncmp_P(buf+12, PSTR("8N2"), 3) == 0) meter.parity = 7;