Skip to content

Commit

Permalink
MI - some small fixes (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
rejoe2 authored Mar 22, 2023
1 parent 6fc2f2d commit 0535117
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/hm/hmInverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ class Inverter {
}

void clearCmdQueue() {
DPRINTLN(DBG_INFO, F("clearCmdQueue"));
DPRINTHEAD(DBG_INFO, id);
DBGPRINTLN_TXT(TXT_CLRQUE);
while (!_commandQueue.empty()) {
// Will destroy CommandAbstract Class Object (?)
_commandQueue.pop();
Expand Down
40 changes: 24 additions & 16 deletions src/hm/miPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ class MiPayload {

void add(Inverter<> *iv, packet_t *p) {
//DPRINTLN(DBG_INFO, F("MI got data [0]=") + String(p->packet[0], HEX));

if (p->packet[0] == (0x08 + ALL_FRAMES)) { // 0x88; MI status response to 0x09
miStsDecode(iv, p);
}
Expand Down Expand Up @@ -261,20 +260,26 @@ const byteAssign_t InfoAssignment[] = {
mStat->rxSuccess++;
}

} else if (p->packet[0] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command
} else if ( p->packet[0] == (TX_REQ_INFO + ALL_FRAMES) || p->packet[0] == 0xB6 ) { // response from get information command
// atm, we just do nothing else than print out what we got...
// for decoding see xls- Data collection instructions - #147ff
mPayload[iv->id].txId = p->packet[0];
DPRINTLN(DBG_DEBUG, F("Response from info request received"));
//mPayload[iv->id].txId = p->packet[0];
//DPRINTLN(DBG_DEBUG, F("Response from info request received"));
DBGPRINTLN_TXT(TXT_RXDIREQ);
uint8_t *pid = &p->packet[9];
if (*pid == 0x00) {
DPRINT(DBG_DEBUG, F("fragment number zero received"));

//DPRINT(DBG_DEBUG, F("fragment number zero received"));
DBGPRINTLN_TXT(TXT_FRAGM0);
iv->setQueuedCmdFinished();
} else if (p->packet[9] == 0x81) {
DPRINTHEAD(DBG_WARN, iv->id);
DBGPRINTLN_TXT(TXT_NO2NDG);
iv->ivGen = IV_HM;
iv->setQueuedCmdFinished();
} //else {
DPRINTLN(DBG_DEBUG, "PID: 0x" + String(*pid, HEX));
/*
if ((*pid & 0x7F) < MAX_PAYLOAD_ENTRIES) {
iv->clearCmdQueue();
//DPRINTLN(DBG_DEBUG, "PID: 0x" + String(*pid, HEX));
/* (old else-tree)
if ((*pid & 0x7F) < MAX_PAYLOAD_ENTRIES) {^
memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->packet[10], p->len - 11);
mPayload[iv->id].len[(*pid & 0x7F) - 1] = p->len - 11;
mPayload[iv->id].gotFragment = true;
Expand All @@ -286,13 +291,14 @@ const byteAssign_t InfoAssignment[] = {
if (*pid > 0x81)
mPayload[iv->id].lastFound = true;
}
}
}*/
}
} */
//}
} else if (p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES ) // response from dev control command
|| p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES -1)) { // response from DRED instruction
|| p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES -1)) { // response from DRED instruction
DPRINTHEAD(DBG_DEBUG, iv->id);
DBGPRINTLN(F("Response from devcontrol request received"));
DBGPRINTLN_TXT(TXT_RXCTRREQ);
//DBGPRINTLN(F("Response from devcontrol request received"));

mPayload[iv->id].txId = p->packet[0];
iv->clearDevControlRequest();
Expand All @@ -313,7 +319,8 @@ const byteAssign_t InfoAssignment[] = {
//DPRINTLN(DBG_INFO, F("procPyld: cmd: 0x") + String(mPayload[iv->id].txCmd, HEX));
//DPRINTLN(DBG_INFO, F("procPyld: txid: 0x") + String(mPayload[iv->id].txId, HEX));
//DPRINTLN(DBG_DEBUG, F("procPyld: max: ") + String(mPayload[iv->id].maxPackId));
DPRINT_INIT(DBG_INFO,TXT_PPYDCMD);
DPRINTHEAD(DBG_INFO, iv->id);
DBGPRINT_TXT(TXT_PPYDCMD);
DBGHEXLN(mPayload[iv->id].txCmd);
DBGPRINT_TXT(TXT_PPYDTXI);
DBGHEXLN(mPayload[iv->id].txId);
Expand Down Expand Up @@ -718,7 +725,8 @@ const byteAssign_t InfoAssignment[] = {
}

bool build(uint8_t id, bool *complete) {
DPRINTLN_TXT(DBG_VERBOSE, TXT_BUILD);
DPRINTLN(DBG_VERBOSE, F("build"));
//DPRINTLN_TXT(DBG_VERBOSE, TXT_BUILD);
/*uint16_t crc = 0xffff, crcRcv = 0x0000;
if (mPayload[id].maxPackId > MAX_PAYLOAD_ENTRIES)
mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES;
Expand Down
22 changes: 14 additions & 8 deletions src/utils/dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@
#define TXT_REQRETR 7
#define TXT_PPYDMAX 10
#define TXT_NOPYLD 1

#define TXT_GDEVINF 3
#define TXT_DEVCTRL 4
#define TXT_INCRALM 5
Expand All @@ -194,7 +193,6 @@
DPRINTLN(DBG_DEBUG, F("Response from info request received"));
DBGPRINTLN(F("Response from devcontrol request received"));
DPRINT(DBG_DEBUG, F("fragment number zero received"));
DBGPRINT(F("has accepted power limit set point "));
DBGPRINT(F(" with PowerLimitControl "));
DPRINT(DBG_INFO, F("Payload (") + String(payloadLen) + "): ");
Expand Down Expand Up @@ -228,22 +226,30 @@ DBGPRINTLN(F("Response from devcontrol request received"));
#define TXT_NOPYLD2 3
#define TXT_CRCERR 4
#define TXT_RSTPYLD 5
#define TXT_NULLREC 7
#define TXT_PREVSND 8
#define TXT_RESPLIM 9

//resetPayload
#define TXT_RXDIREQ 6
#define TXT_CLRQUE 7
#define TXT_RXCTRREQ 8
#define TXT_NULLREC 9
#define TXT_PREVSND 10
#define TXT_RESPLIM 11
#define TXT_FRAGM0 20
#define TXT_NO2NDG 100

#define DBGPRINTLN_TXT(text) ({\
switch(text) {\
case TXT_TIMEOUT: DBGPRINTLN(F("enqueued cmd failed/timeout")); break; \
case TXT_BUILD: DBGPRINTLN(F("build")); break; \
case TXT_NOPYLD2: DBGPRINTLN(F("nothing received")); break; \
case TXT_RSTPYLD: DBGPRINTLN(F("resetPayload"));break; \
case TXT_CRCERR: DBGPRINTLN(F("CRC Error: Request Complete Retransmit")); break; \
case TXT_RSTPYLD: DBGPRINTLN(F("resetPayload"));break; \
case TXT_RXDIREQ: DBGPRINTLN(F("Response from info request received")); break; \
case TXT_CLRQUE: DBGPRINTLN(F("clearCmdQueue")); break; \
case TXT_RXCTRREQ: DBGPRINTLN(F("Response from devcontrol request received")); break; \
case TXT_NULLREC: DBGPRINTLN(F("record is NULL!")); break; \
case TXT_PREVSND: DBGPRINTLN(F("Prevent retransmit on Restart / CleanState_LockAndAlarm...")); break; \
case TXT_RESPLIM: DBGPRINTLN(F("retransmit power limit")); break; \
case TXT_FRAGM0: DBGPRINTLN(F("fragment number zero received")); break; \
case TXT_NO2NDG: DBGPRINTLN(F("seems to use 3rd gen. protocol - switching ivGen!")); break; \
default: ; break; \
}\
})
Expand Down

0 comments on commit 0535117

Please sign in to comment.