Fixed queue handling and added event log count

This commit is contained in:
Thomas Basler 2022-07-04 19:36:58 +02:00
parent a9879c2f14
commit 56f764d10f
7 changed files with 26 additions and 13 deletions

View File

@ -118,6 +118,8 @@ void HoymilesRadio::loop()
// Currently in idle mode --> send packet if one is in the queue
if (!_txBuffer.empty()) {
inverter_transaction_t* t = _txBuffer.getBack();
auto inv = Hoymiles.getInverterBySerial(t->target.u64);
inv->setLastRequest(t->requestType);
sendEsbPacket(t->target, t->mainCmd, t->subCmd, t->payload, t->len, t->timeout);
_txBuffer.popBack();
}

View File

@ -11,7 +11,7 @@ public:
const uint8_t getAssignmentCount();
private:
const byteAssign_t byteAssignment[21] = {
const byteAssign_t byteAssignment[22] = {
{ FLD_UDC, UNIT_V, CH1, 2, 2, 10 },
{ FLD_IDC, UNIT_A, CH1, 4, 2, 100 },
{ FLD_PDC, UNIT_W, CH1, 6, 2, 10 },
@ -31,6 +31,7 @@ private:
{ FLD_PAC, UNIT_W, CH0, 30, 2, 10 },
{ FLD_F, UNIT_HZ, CH0, 28, 2, 100 },
{ FLD_T, UNIT_C, CH0, 38, 2, 10 },
{ FLD_EVT_LOG, UNIT_CNT, CH0, 40, 2, 1},
{ FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC },
{ FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC },
{ FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC },

View File

@ -11,7 +11,7 @@ public:
const uint8_t getAssignmentCount();
private:
const byteAssign_t byteAssignment[34] = {
const byteAssign_t byteAssignment[35] = {
{ FLD_UDC, UNIT_V, CH1, 2, 2, 10 },
{ FLD_IDC, UNIT_A, CH1, 4, 2, 100 },
{ FLD_PDC, UNIT_W, CH1, 8, 2, 10 },
@ -46,6 +46,7 @@ private:
{ FLD_F, UNIT_HZ, CH0, 48, 2, 100 },
{ FLD_PCT, UNIT_PCT, CH0, 56, 2, 10 },
{ FLD_T, UNIT_C, CH0, 58, 2, 10 },
{ FLD_EVT_LOG, UNIT_CNT, CH0, 60, 2, 1},
{ FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC },
{ FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC },
{ FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC },

View File

@ -35,8 +35,9 @@ bool HM_Abstract::sendStatsRequest(HoymilesRadio* radio)
payload.payload[14] = (crc >> 8) & 0xff;
payload.payload[15] = (crc)&0xff;
payload.requestType = RequestType::Stats;
clearRxFragmentBuffer();
radio->enqueTransaction(&payload);
setLastRequest(RequestType::Stats);
return true;
}

View File

@ -113,8 +113,11 @@ uint8_t InverterAbstract::verifyAllFragments()
offs += (_rxFragmentBuffer[i].len);
}
_lastStatsUpdate = millis();
} else {
Serial.println("Unkown response received");
}
setLastRequest(RequestType::None);
return FRAGMENT_OK;
}

View File

@ -16,9 +16,10 @@ enum {
UNIT_KWH,
UNIT_HZ,
UNIT_C,
UNIT_PCT
UNIT_PCT,
UNIT_CNT
};
const char* const units[] = { "V", "A", "W", "Wh", "kWh", "Hz", "°C", "%" };
const char* const units[] = { "V", "A", "W", "Wh", "kWh", "Hz", "°C", "%", "" };
// field types
enum {
@ -34,10 +35,11 @@ enum {
FLD_T,
FLD_PCT,
FLD_EFF,
FLD_IRR
FLD_IRR,
FLD_EVT_LOG
};
const char* const fields[] = { "Voltage", "Current", "Power", "YieldDay", "YieldTotal",
"Voltage", "Current", "Power", "Frequency", "Temperature", "PowerFactor", "Effiency", "Irradiation" };
"Voltage", "Current", "Power", "Frequency", "Temperature", "PowerFactor", "Effiency", "Irradiation", "EventLogCount" };
// indices to calculation functions, defined in hmInverter.h
enum {
@ -66,10 +68,6 @@ enum {
FRAGMENT_OK = 0
};
enum class RequestType {
Stats
};
typedef struct {
uint8_t fieldId; // field id
uint8_t unitId; // uint id
@ -134,8 +132,9 @@ public:
virtual bool sendStatsRequest(HoymilesRadio* radio) = 0;
uint32_t getLastStatsUpdate();
protected:
void setLastRequest(RequestType request);
protected:
RequestType getLastRequest();
private:
@ -150,5 +149,5 @@ private:
uint32_t _lastStatsUpdate = 0;
uint16_t _chanMaxPower[CH4];
RequestType _lastRequest;
RequestType _lastRequest = RequestType::None;
};

View File

@ -15,8 +15,14 @@ typedef struct {
uint8_t len;
} fragment_t;
enum class RequestType {
None,
Stats
};
typedef struct {
serial_u target;
RequestType requestType = RequestType::None;
uint8_t mainCmd;
uint8_t subCmd;
uint8_t payload[MAX_RF_PAYLOAD_SIZE];