Browse Source

various changes

might not all be correct...
pull/1219/head^2
rejoe2 12 months ago
committed by GitHub
parent
commit
06a1159d4f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      src/hm/Communication.h
  2. 10
      src/hm/hmInverter.h
  3. 5
      src/hm/radio.h

33
src/hm/Communication.h

@ -12,7 +12,8 @@
#define MI_TIMEOUT 250 #define MI_TIMEOUT 250
#define DEFAULT_TIMEOUT 500 #define DEFAULT_TIMEOUT 500
#define MAX_BUFFER 200 //was: 150 (hardcoded) #define SINGLEFR_TIMEOUT 60
#define MAX_BUFFER 250 //was: 150 (hardcoded)
typedef std::function<void(uint8_t, Inverter<> *)> payloadListenerType; typedef std::function<void(uint8_t, Inverter<> *)> payloadListenerType;
typedef std::function<void(Inverter<> *)> alarmListenerType; typedef std::function<void(Inverter<> *)> alarmListenerType;
@ -134,7 +135,8 @@ class Communication : public CommQueue<> {
yield(); yield();
} }
if(0 == q->attempts) { if(0 == q->attempts) {
cmdDone(q); //cmdDone(q);
cmdDone(true);
mState = States::RESET; mState = States::RESET;
} else } else
mState = nextState; mState = nextState;
@ -161,11 +163,12 @@ class Communication : public CommQueue<> {
if(q->attempts) { if(q->attempts) {
q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (SINGLE_FRAME + i), true); q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (SINGLE_FRAME + i), true);
q->iv->radioStatistics.retransmits++; q->iv->radioStatistics.retransmits++;
mWaitTimeout = millis() + timeout; mWaitTimeout = millis() + SINGLEFR_TIMEOUT; // timeout
mState = States::WAIT; mState = States::WAIT;
} else { } else {
add(q, true); add(q, true);
cmdDone(q); //cmdDone(q);
cmdDone(true);
mState = States::RESET; mState = States::RESET;
} }
return; return;
@ -185,11 +188,12 @@ class Communication : public CommQueue<> {
if(q->attempts) { if(q->attempts) {
q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (SINGLE_FRAME + i), true); q->iv->radio->sendCmdPacket(q->iv, TX_REQ_INFO, (SINGLE_FRAME + i), true);
q->iv->radioStatistics.retransmits++; q->iv->radioStatistics.retransmits++;
mWaitTimeout = millis() + timeout; mWaitTimeout = millis() + SINGLEFR_TIMEOUT; // timeout;
mState = States::WAIT; mState = States::WAIT;
} else { } else {
add(q, true); add(q, true);
cmdDone(q); //cmdDone(q);
cmdDone(true);
mState = States::RESET; mState = States::RESET;
} }
return; return;
@ -486,7 +490,7 @@ class Communication : public CommQueue<> {
multi_parts++; multi_parts++;
} }
if(multi_parts > 5) { if(multi_parts > 5) {
cmdDone(q); cmdDone(true);
mState = States::RESET; mState = States::RESET;
q->iv->radioStatistics.rxSuccess++; q->iv->radioStatistics.rxSuccess++;
} }
@ -558,7 +562,6 @@ class Communication : public CommQueue<> {
} else { // first data msg for 1ch, 2nd for 2ch } else { // first data msg for 1ch, 2nd for 2ch
miComplete(q->iv); miComplete(q->iv);
} }
//cmdDone(q);
} }
inline void miNextRequest(uint8_t cmd, const queue_s *q) { inline void miNextRequest(uint8_t cmd, const queue_s *q) {
@ -578,7 +581,7 @@ class Communication : public CommQueue<> {
mState = States::WAIT; mState = States::WAIT;
} else { } else {
add(q, true); add(q, true);
cmdDone(q); cmdDone();
mState = States::RESET; mState = States::RESET;
} }
} }
@ -607,17 +610,23 @@ class Communication : public CommQueue<> {
bool stsok = true; bool stsok = true;
if ( prntsts != rec->record[q->iv->getPosByChFld(0, FLD_EVT, rec)] ) { //sth.'s changed? if ( prntsts != rec->record[q->iv->getPosByChFld(0, FLD_EVT, rec)] ) { //sth.'s changed?
q->iv->alarmCnt = 1; // minimum... q->iv->alarmCnt = 1; // minimum...
stsok = false;
//sth is or was wrong? //sth is or was wrong?
if ( (q->iv->type != INV_TYPE_1CH) && ( (statusMi != 3) if ( (q->iv->type != INV_TYPE_1CH) && ( (statusMi != 3)
|| ((q->iv->lastAlarm[stschan].code) && (statusMi == 3) && (q->iv->lastAlarm[stschan].code != 1))) || ((q->iv->lastAlarm[stschan].code) && (statusMi == 3) && (q->iv->lastAlarm[stschan].code != 1)))
) { ) {
q->iv->lastAlarm[stschan+q->iv->type==INV_TYPE_2CH ? 2: 4] = alarm_t(q->iv->lastAlarm[stschan].code, q->iv->lastAlarm[stschan].start,q->ts);
q->iv->lastAlarm[stschan] = alarm_t(prntsts, q->ts,0); q->iv->lastAlarm[stschan] = alarm_t(prntsts, q->ts,0);
q->iv->alarmCnt = q->iv->type == INV_TYPE_2CH ? 3 : 5; q->iv->alarmCnt = q->iv->type == INV_TYPE_2CH ? 3 : 5;
} } else if ( (q->iv->type == INV_TYPE_1CH) && ( (statusMi != 3)
|| ((q->iv->lastAlarm[stschan].code) && (statusMi == 3) && (q->iv->lastAlarm[stschan].code != 1)))
) {
q->iv->lastAlarm[stschan] = alarm_t(q->iv->lastAlarm[0].code, q->iv->lastAlarm[0].start,q->ts);
} else if (q->iv->type == INV_TYPE_1CH)
stsok = true;
q->iv->alarmLastId = prntsts; //iv->alarmMesIndex; q->iv->alarmLastId = prntsts; //iv->alarmMesIndex;
stsok = false;
if (q->iv->alarmCnt > 1) { //more than one channel if (q->iv->alarmCnt > 1) { //more than one channel
for (uint8_t ch = 0; ch < (q->iv->alarmCnt); ++ch) { //start with 1 for (uint8_t ch = 0; ch < (q->iv->alarmCnt); ++ch) { //start with 1
if (q->iv->lastAlarm[ch].code == 1) { if (q->iv->lastAlarm[ch].code == 1) {
@ -679,7 +688,9 @@ class Communication : public CommQueue<> {
iv->doCalculations(); iv->doCalculations();
// update status state-machine, // update status state-machine,
if (ac_pow)
iv->isProducing(); iv->isProducing();
cmdDone(true);
} }
private: private:

10
src/hm/hmInverter.h

@ -182,11 +182,12 @@ class Inverter {
} }
void tickSend(std::function<void(uint8_t cmd, bool isDevControl)> cb) { void tickSend(std::function<void(uint8_t cmd, bool isDevControl)> cb) {
if (IV_MI != ivGen) {
if(mDevControlRequest) { if(mDevControlRequest) {
cb(devControlCmd, true); cb(devControlCmd, true);
mDevControlRequest = false; mDevControlRequest = false;
} else if((alarmLastId != alarmMesIndex) && (alarmMesIndex != 0)) }
else if (IV_MI != ivGen) {
if((alarmLastId != alarmMesIndex) && (alarmMesIndex != 0))
cb(AlarmData, false); // get last alarms cb(AlarmData, false); // get last alarms
else if(0 == getFwVersion()) else if(0 == getFwVersion())
cb(InverterDevInform_All, false); // get firmware version cb(InverterDevInform_All, false); // get firmware version
@ -197,10 +198,7 @@ class Inverter {
else else
cb(RealTimeRunData_Debug, false); // get live data cb(RealTimeRunData_Debug, false); // get live data
} else { } else {
if(mDevControlRequest) { if(0 == getFwVersion())
cb(devControlCmd, true);
mDevControlRequest = false;
} else if(0 == getFwVersion())
cb(0x0f, false); // get firmware version; for MI, this makes part of polling the device software and hardware version number cb(0x0f, false); // get firmware version; for MI, this makes part of polling the device software and hardware version number
else { else {
record_t<> *rec = getRecordStruct(InverterDevInform_Simple); record_t<> *rec = getRecordStruct(InverterDevInform_Simple);

5
src/hm/radio.h

@ -44,9 +44,8 @@ class Radio {
void prepareDevInformCmd(Inverter<> *iv, uint8_t cmd, uint32_t ts, uint16_t alarmMesId, bool isRetransmit, uint8_t reqfld=TX_REQ_INFO) { // might not be necessary to add additional arg. void prepareDevInformCmd(Inverter<> *iv, uint8_t cmd, uint32_t ts, uint16_t alarmMesId, bool isRetransmit, uint8_t reqfld=TX_REQ_INFO) { // might not be necessary to add additional arg.
if(IV_MI == getIvGen(iv)) { if(IV_MI == getIvGen(iv)) {
DPRINT_IVID(DBG_INFO, getIvId(iv)); DPRINT(DBG_DEBUG, F("legacy cmd 0x"));
DBGPRINT(F("legacy cmd 0x")); DPRINTLN(DBG_DEBUG,String(cmd, HEX));
DBGHEXLN(cmd);
sendCmdPacket(iv, cmd, cmd, false, false); sendCmdPacket(iv, cmd, cmd, false, false);
return; return;
} }

Loading…
Cancel
Save