Code Refactoring: Use internal inverter instance in handleResponse method
This commit is contained in:
parent
6d6d62bb77
commit
90711ddd76
@ -62,24 +62,24 @@ void ActivePowerControlCommand::setActivePowerLimit(const float limit, const Pow
|
|||||||
udpateCRC(CRC_SIZE);
|
udpateCRC(CRC_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ActivePowerControlCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
|
bool ActivePowerControlCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||||
{
|
{
|
||||||
if (!DevControlCommand::handleResponse(inverter, fragment, max_fragment_id)) {
|
if (!DevControlCommand::handleResponse(fragment, max_fragment_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((getType() == PowerLimitControlType::RelativNonPersistent) || (getType() == PowerLimitControlType::RelativPersistent)) {
|
if ((getType() == PowerLimitControlType::RelativNonPersistent) || (getType() == PowerLimitControlType::RelativPersistent)) {
|
||||||
inverter.SystemConfigPara()->setLimitPercent(getLimit());
|
_inv->SystemConfigPara()->setLimitPercent(getLimit());
|
||||||
} else {
|
} else {
|
||||||
const uint16_t max_power = inverter.DevInfo()->getMaxPower();
|
const uint16_t max_power = _inv->DevInfo()->getMaxPower();
|
||||||
if (max_power > 0) {
|
if (max_power > 0) {
|
||||||
inverter.SystemConfigPara()->setLimitPercent(static_cast<float>(getLimit()) / max_power * 100);
|
_inv->SystemConfigPara()->setLimitPercent(static_cast<float>(getLimit()) / max_power * 100);
|
||||||
} else {
|
} else {
|
||||||
// TODO(tbnobody): Not implemented yet because we only can publish the percentage value
|
// TODO(tbnobody): Not implemented yet because we only can publish the percentage value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inverter.SystemConfigPara()->setLastUpdateCommand(millis());
|
_inv->SystemConfigPara()->setLastUpdateCommand(millis());
|
||||||
inverter.SystemConfigPara()->setLastLimitCommandSuccess(CMD_OK);
|
_inv->SystemConfigPara()->setLastLimitCommandSuccess(CMD_OK);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ public:
|
|||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
virtual void gotTimeout();
|
virtual void gotTimeout();
|
||||||
|
|
||||||
void setActivePowerLimit(const float limit, const PowerLimitControlType type = RelativNonPersistent);
|
void setActivePowerLimit(const float limit, const PowerLimitControlType type = RelativNonPersistent);
|
||||||
|
|||||||
@ -36,24 +36,24 @@ String AlarmDataCommand::getCommandName() const
|
|||||||
return "AlarmData";
|
return "AlarmData";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AlarmDataCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
|
bool AlarmDataCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||||
{
|
{
|
||||||
// Check CRC of whole payload
|
// Check CRC of whole payload
|
||||||
if (!MultiDataCommand::handleResponse(inverter, fragment, max_fragment_id)) {
|
if (!MultiDataCommand::handleResponse(fragment, max_fragment_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move all fragments into target buffer
|
// Move all fragments into target buffer
|
||||||
uint8_t offs = 0;
|
uint8_t offs = 0;
|
||||||
inverter.EventLog()->beginAppendFragment();
|
_inv->EventLog()->beginAppendFragment();
|
||||||
inverter.EventLog()->clearBuffer();
|
_inv->EventLog()->clearBuffer();
|
||||||
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
||||||
inverter.EventLog()->appendFragment(offs, fragment[i].fragment, fragment[i].len);
|
_inv->EventLog()->appendFragment(offs, fragment[i].fragment, fragment[i].len);
|
||||||
offs += (fragment[i].len);
|
offs += (fragment[i].len);
|
||||||
}
|
}
|
||||||
inverter.EventLog()->endAppendFragment();
|
_inv->EventLog()->endAppendFragment();
|
||||||
inverter.EventLog()->setLastAlarmRequestSuccess(CMD_OK);
|
_inv->EventLog()->setLastAlarmRequestSuccess(CMD_OK);
|
||||||
inverter.EventLog()->setLastUpdate(millis());
|
_inv->EventLog()->setLastUpdate(millis());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,6 @@ public:
|
|||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
virtual void gotTimeout();
|
virtual void gotTimeout();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -67,7 +67,7 @@ void ChannelChangeCommand::setCountryMode(const CountryModeId_t mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChannelChangeCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
|
bool ChannelChangeCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ public:
|
|||||||
|
|
||||||
void setCountryMode(const CountryModeId_t mode);
|
void setCountryMode(const CountryModeId_t mode);
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
|
|
||||||
virtual uint8_t getMaxResendCount();
|
virtual uint8_t getMaxResendCount();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public:
|
|||||||
|
|
||||||
virtual CommandAbstract* getRequestFrameCommand(const uint8_t frame_no);
|
virtual CommandAbstract* getRequestFrameCommand(const uint8_t frame_no);
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id) = 0;
|
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id) = 0;
|
||||||
virtual void gotTimeout();
|
virtual void gotTimeout();
|
||||||
|
|
||||||
// Sets the amount how often the specific command is resent if all fragments where missing
|
// Sets the amount how often the specific command is resent if all fragments where missing
|
||||||
|
|||||||
@ -39,7 +39,7 @@ void DevControlCommand::udpateCRC(const uint8_t len)
|
|||||||
_payload[10 + len + 1] = (uint8_t)(crc);
|
_payload[10 + len + 1] = (uint8_t)(crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DevControlCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
|
bool DevControlCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||||
{
|
{
|
||||||
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
||||||
if (fragment[i].mainCmd != (_payload[0] | 0x80)) {
|
if (fragment[i].mainCmd != (_payload[0] | 0x80)) {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ class DevControlCommand : public CommandAbstract {
|
|||||||
public:
|
public:
|
||||||
explicit DevControlCommand(InverterAbstract* inv, const uint64_t router_address = 0);
|
explicit DevControlCommand(InverterAbstract* inv, const uint64_t router_address = 0);
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void udpateCRC(const uint8_t len);
|
void udpateCRC(const uint8_t len);
|
||||||
|
|||||||
@ -34,22 +34,22 @@ String DevInfoAllCommand::getCommandName() const
|
|||||||
return "DevInfoAll";
|
return "DevInfoAll";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DevInfoAllCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
|
bool DevInfoAllCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||||
{
|
{
|
||||||
// Check CRC of whole payload
|
// Check CRC of whole payload
|
||||||
if (!MultiDataCommand::handleResponse(inverter, fragment, max_fragment_id)) {
|
if (!MultiDataCommand::handleResponse(fragment, max_fragment_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move all fragments into target buffer
|
// Move all fragments into target buffer
|
||||||
uint8_t offs = 0;
|
uint8_t offs = 0;
|
||||||
inverter.DevInfo()->beginAppendFragment();
|
_inv->DevInfo()->beginAppendFragment();
|
||||||
inverter.DevInfo()->clearBufferAll();
|
_inv->DevInfo()->clearBufferAll();
|
||||||
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
||||||
inverter.DevInfo()->appendFragmentAll(offs, fragment[i].fragment, fragment[i].len);
|
_inv->DevInfo()->appendFragmentAll(offs, fragment[i].fragment, fragment[i].len);
|
||||||
offs += (fragment[i].len);
|
offs += (fragment[i].len);
|
||||||
}
|
}
|
||||||
inverter.DevInfo()->endAppendFragment();
|
_inv->DevInfo()->endAppendFragment();
|
||||||
inverter.DevInfo()->setLastUpdateAll(millis());
|
_inv->DevInfo()->setLastUpdateAll(millis());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,5 +9,5 @@ public:
|
|||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -34,22 +34,22 @@ String DevInfoSimpleCommand::getCommandName() const
|
|||||||
return "DevInfoSimple";
|
return "DevInfoSimple";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DevInfoSimpleCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
|
bool DevInfoSimpleCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||||
{
|
{
|
||||||
// Check CRC of whole payload
|
// Check CRC of whole payload
|
||||||
if (!MultiDataCommand::handleResponse(inverter, fragment, max_fragment_id)) {
|
if (!MultiDataCommand::handleResponse(fragment, max_fragment_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move all fragments into target buffer
|
// Move all fragments into target buffer
|
||||||
uint8_t offs = 0;
|
uint8_t offs = 0;
|
||||||
inverter.DevInfo()->beginAppendFragment();
|
_inv->DevInfo()->beginAppendFragment();
|
||||||
inverter.DevInfo()->clearBufferSimple();
|
_inv->DevInfo()->clearBufferSimple();
|
||||||
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
||||||
inverter.DevInfo()->appendFragmentSimple(offs, fragment[i].fragment, fragment[i].len);
|
_inv->DevInfo()->appendFragmentSimple(offs, fragment[i].fragment, fragment[i].len);
|
||||||
offs += (fragment[i].len);
|
offs += (fragment[i].len);
|
||||||
}
|
}
|
||||||
inverter.DevInfo()->endAppendFragment();
|
_inv->DevInfo()->endAppendFragment();
|
||||||
inverter.DevInfo()->setLastUpdateSimple(millis());
|
_inv->DevInfo()->setLastUpdateSimple(millis());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,5 +9,5 @@ public:
|
|||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -35,22 +35,22 @@ String GridOnProFilePara::getCommandName() const
|
|||||||
return "GridOnProFilePara";
|
return "GridOnProFilePara";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GridOnProFilePara::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
|
bool GridOnProFilePara::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||||
{
|
{
|
||||||
// Check CRC of whole payload
|
// Check CRC of whole payload
|
||||||
if (!MultiDataCommand::handleResponse(inverter, fragment, max_fragment_id)) {
|
if (!MultiDataCommand::handleResponse(fragment, max_fragment_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move all fragments into target buffer
|
// Move all fragments into target buffer
|
||||||
uint8_t offs = 0;
|
uint8_t offs = 0;
|
||||||
inverter.GridProfile()->beginAppendFragment();
|
_inv->GridProfile()->beginAppendFragment();
|
||||||
inverter.GridProfile()->clearBuffer();
|
_inv->GridProfile()->clearBuffer();
|
||||||
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
||||||
inverter.GridProfile()->appendFragment(offs, fragment[i].fragment, fragment[i].len);
|
_inv->GridProfile()->appendFragment(offs, fragment[i].fragment, fragment[i].len);
|
||||||
offs += (fragment[i].len);
|
offs += (fragment[i].len);
|
||||||
}
|
}
|
||||||
inverter.GridProfile()->endAppendFragment();
|
_inv->GridProfile()->endAppendFragment();
|
||||||
inverter.GridProfile()->setLastUpdate(millis());
|
_inv->GridProfile()->setLastUpdate(millis());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,5 +9,5 @@ public:
|
|||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -85,7 +85,7 @@ CommandAbstract* MultiDataCommand::getRequestFrameCommand(const uint8_t frame_no
|
|||||||
return &_cmdRequestFrame;
|
return &_cmdRequestFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiDataCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
|
bool MultiDataCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||||
{
|
{
|
||||||
// All fragments are available --> Check CRC
|
// All fragments are available --> Check CRC
|
||||||
uint16_t crc = 0xffff, crcRcv = 0;
|
uint16_t crc = 0xffff, crcRcv = 0;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ public:
|
|||||||
|
|
||||||
CommandAbstract* getRequestFrameCommand(const uint8_t frame_no);
|
CommandAbstract* getRequestFrameCommand(const uint8_t frame_no);
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setDataType(const uint8_t data_type);
|
void setDataType(const uint8_t data_type);
|
||||||
|
|||||||
@ -44,14 +44,14 @@ String PowerControlCommand::getCommandName() const
|
|||||||
return "PowerControl";
|
return "PowerControl";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PowerControlCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
|
bool PowerControlCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||||
{
|
{
|
||||||
if (!DevControlCommand::handleResponse(inverter, fragment, max_fragment_id)) {
|
if (!DevControlCommand::handleResponse(fragment, max_fragment_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inverter.PowerCommand()->setLastUpdateCommand(millis());
|
_inv->PowerCommand()->setLastUpdateCommand(millis());
|
||||||
inverter.PowerCommand()->setLastPowerCommandSuccess(CMD_OK);
|
_inv->PowerCommand()->setLastPowerCommandSuccess(CMD_OK);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ public:
|
|||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
virtual void gotTimeout();
|
virtual void gotTimeout();
|
||||||
|
|
||||||
void setPowerOn(const bool state);
|
void setPowerOn(const bool state);
|
||||||
|
|||||||
@ -35,10 +35,10 @@ String RealTimeRunDataCommand::getCommandName() const
|
|||||||
return "RealTimeRunData";
|
return "RealTimeRunData";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RealTimeRunDataCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
|
bool RealTimeRunDataCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||||
{
|
{
|
||||||
// Check CRC of whole payload
|
// Check CRC of whole payload
|
||||||
if (!MultiDataCommand::handleResponse(inverter, fragment, max_fragment_id)) {
|
if (!MultiDataCommand::handleResponse(fragment, max_fragment_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ bool RealTimeRunDataCommand::handleResponse(InverterAbstract& inverter, const fr
|
|||||||
// In case of low power in the inverter it occours that some incomplete fragments
|
// In case of low power in the inverter it occours that some incomplete fragments
|
||||||
// with a valid CRC are received.
|
// with a valid CRC are received.
|
||||||
const uint8_t fragmentsSize = getTotalFragmentSize(fragment, max_fragment_id);
|
const uint8_t fragmentsSize = getTotalFragmentSize(fragment, max_fragment_id);
|
||||||
const uint8_t expectedSize = inverter.Statistics()->getExpectedByteCount();
|
const uint8_t expectedSize = _inv->Statistics()->getExpectedByteCount();
|
||||||
if (fragmentsSize < expectedSize) {
|
if (fragmentsSize < expectedSize) {
|
||||||
Hoymiles.getMessageOutput()->printf("ERROR in %s: Received fragment size: %d, min expected size: %d\r\n",
|
Hoymiles.getMessageOutput()->printf("ERROR in %s: Received fragment size: %d, min expected size: %d\r\n",
|
||||||
getCommandName().c_str(), fragmentsSize, expectedSize);
|
getCommandName().c_str(), fragmentsSize, expectedSize);
|
||||||
@ -56,15 +56,15 @@ bool RealTimeRunDataCommand::handleResponse(InverterAbstract& inverter, const fr
|
|||||||
|
|
||||||
// Move all fragments into target buffer
|
// Move all fragments into target buffer
|
||||||
uint8_t offs = 0;
|
uint8_t offs = 0;
|
||||||
inverter.Statistics()->beginAppendFragment();
|
_inv->Statistics()->beginAppendFragment();
|
||||||
inverter.Statistics()->clearBuffer();
|
_inv->Statistics()->clearBuffer();
|
||||||
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
||||||
inverter.Statistics()->appendFragment(offs, fragment[i].fragment, fragment[i].len);
|
_inv->Statistics()->appendFragment(offs, fragment[i].fragment, fragment[i].len);
|
||||||
offs += (fragment[i].len);
|
offs += (fragment[i].len);
|
||||||
}
|
}
|
||||||
inverter.Statistics()->endAppendFragment();
|
_inv->Statistics()->endAppendFragment();
|
||||||
inverter.Statistics()->resetRxFailureCount();
|
_inv->Statistics()->resetRxFailureCount();
|
||||||
inverter.Statistics()->setLastUpdate(millis());
|
_inv->Statistics()->setLastUpdate(millis());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,6 @@ public:
|
|||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
virtual void gotTimeout();
|
virtual void gotTimeout();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -47,7 +47,7 @@ uint8_t RequestFrameCommand::getFrameNo() const
|
|||||||
return _payload[9] & (~0x80);
|
return _payload[9] & (~0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RequestFrameCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
|
bool RequestFrameCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,5 +12,5 @@ public:
|
|||||||
void setFrameNo(const uint8_t frame_no);
|
void setFrameNo(const uint8_t frame_no);
|
||||||
uint8_t getFrameNo() const;
|
uint8_t getFrameNo() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -35,10 +35,10 @@ String SystemConfigParaCommand::getCommandName() const
|
|||||||
return "SystemConfigPara";
|
return "SystemConfigPara";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemConfigParaCommand::handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id)
|
bool SystemConfigParaCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||||
{
|
{
|
||||||
// Check CRC of whole payload
|
// Check CRC of whole payload
|
||||||
if (!MultiDataCommand::handleResponse(inverter, fragment, max_fragment_id)) {
|
if (!MultiDataCommand::handleResponse(fragment, max_fragment_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ bool SystemConfigParaCommand::handleResponse(InverterAbstract& inverter, const f
|
|||||||
// In case of low power in the inverter it occours that some incomplete fragments
|
// In case of low power in the inverter it occours that some incomplete fragments
|
||||||
// with a valid CRC are received.
|
// with a valid CRC are received.
|
||||||
const uint8_t fragmentsSize = getTotalFragmentSize(fragment, max_fragment_id);
|
const uint8_t fragmentsSize = getTotalFragmentSize(fragment, max_fragment_id);
|
||||||
const uint8_t expectedSize = inverter.SystemConfigPara()->getExpectedByteCount();
|
const uint8_t expectedSize = _inv->SystemConfigPara()->getExpectedByteCount();
|
||||||
if (fragmentsSize < expectedSize) {
|
if (fragmentsSize < expectedSize) {
|
||||||
Hoymiles.getMessageOutput()->printf("ERROR in %s: Received fragment size: %d, min expected size: %d\r\n",
|
Hoymiles.getMessageOutput()->printf("ERROR in %s: Received fragment size: %d, min expected size: %d\r\n",
|
||||||
getCommandName().c_str(), fragmentsSize, expectedSize);
|
getCommandName().c_str(), fragmentsSize, expectedSize);
|
||||||
@ -56,15 +56,15 @@ bool SystemConfigParaCommand::handleResponse(InverterAbstract& inverter, const f
|
|||||||
|
|
||||||
// Move all fragments into target buffer
|
// Move all fragments into target buffer
|
||||||
uint8_t offs = 0;
|
uint8_t offs = 0;
|
||||||
inverter.SystemConfigPara()->beginAppendFragment();
|
_inv->SystemConfigPara()->beginAppendFragment();
|
||||||
inverter.SystemConfigPara()->clearBuffer();
|
_inv->SystemConfigPara()->clearBuffer();
|
||||||
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
for (uint8_t i = 0; i < max_fragment_id; i++) {
|
||||||
inverter.SystemConfigPara()->appendFragment(offs, fragment[i].fragment, fragment[i].len);
|
_inv->SystemConfigPara()->appendFragment(offs, fragment[i].fragment, fragment[i].len);
|
||||||
offs += (fragment[i].len);
|
offs += (fragment[i].len);
|
||||||
}
|
}
|
||||||
inverter.SystemConfigPara()->endAppendFragment();
|
_inv->SystemConfigPara()->endAppendFragment();
|
||||||
inverter.SystemConfigPara()->setLastUpdateRequest(millis());
|
_inv->SystemConfigPara()->setLastUpdateRequest(millis());
|
||||||
inverter.SystemConfigPara()->setLastLimitRequestSuccess(CMD_OK);
|
_inv->SystemConfigPara()->setLastLimitRequestSuccess(CMD_OK);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,6 @@ public:
|
|||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
virtual void gotTimeout();
|
virtual void gotTimeout();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -255,7 +255,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract& cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmd.handleResponse(*this, _rxFragmentBuffer, _rxFragmentMaxPacketId)) {
|
if (!cmd.handleResponse(_rxFragmentBuffer, _rxFragmentMaxPacketId)) {
|
||||||
cmd.gotTimeout();
|
cmd.gotTimeout();
|
||||||
return FRAGMENT_HANDLE_ERROR;
|
return FRAGMENT_HANDLE_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user