error logging
This commit is contained in:
@ -167,31 +167,41 @@ static void parseAndPrintFrame() {
|
|||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
mbus_data_variable *data_var = &(frame_data.data_var);
|
mbus_data_variable *data_var = &(frame_data.data_var);
|
||||||
if (data_var->header.status) {
|
if (data_var->header.status) {
|
||||||
coloredMsg(LOG_RED, true, "mbc papf [%d] sts: %02x", mbusCommHandle.requestId, data_var->header.status);
|
coloredMsg(LOG_RED, true, "mbc papf [%d %d] sts: %02x",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address,
|
||||||
|
data_var->header.status);
|
||||||
}
|
}
|
||||||
if ((data_var->header.status & 0x01)) {
|
if ((data_var->header.status & 0x01)) {
|
||||||
coloredMsg(LOG_RED, true, "mbc papf [%d] sts: Application Busy", mbusCommHandle.requestId);
|
coloredMsg(LOG_RED, true, "mbc papf [%d %d] sts: Application Busy",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address);
|
||||||
}
|
}
|
||||||
if ((data_var->header.status & 0x02)) {
|
if ((data_var->header.status & 0x02)) {
|
||||||
coloredMsg(LOG_RED, true, "mbc papf [%d] sts: Any Application Error", mbusCommHandle.requestId);
|
coloredMsg(LOG_RED, true, "mbc papf [%d %d] sts: Any Application Error",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address);
|
||||||
}
|
}
|
||||||
if ((data_var->header.status & 0x04)) {
|
if ((data_var->header.status & 0x04)) {
|
||||||
coloredMsg(LOG_RED, true, "mbc papf [%d] sts: Power Low", mbusCommHandle.requestId);
|
coloredMsg(LOG_RED, true, "mbc papf [%d %d] sts: Power Low",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address);
|
||||||
}
|
}
|
||||||
if ((data_var->header.status & 0x08)) {
|
if ((data_var->header.status & 0x08)) {
|
||||||
coloredMsg(LOG_RED, true, "mbc papf [%d] sts: Permanent Error", mbusCommHandle.requestId);
|
coloredMsg(LOG_RED, true, "mbc papf [%d %d] sts: Permanent Error",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address);
|
||||||
}
|
}
|
||||||
if ((data_var->header.status & 0x10)) {
|
if ((data_var->header.status & 0x10)) {
|
||||||
coloredMsg(LOG_RED, true, "mbc papf [%d] sts: Temporary Error", mbusCommHandle.requestId);
|
coloredMsg(LOG_RED, true, "mbc papf [%d %d] sts: Temporary Error",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address);
|
||||||
}
|
}
|
||||||
if ((data_var->header.status & 0x20)) {
|
if ((data_var->header.status & 0x20)) {
|
||||||
coloredMsg(LOG_RED, true, "mbc papf [%d] sts: Specific to manufacturer Error 1", mbusCommHandle.requestId);
|
coloredMsg(LOG_RED, true, "mbc papf [%d %d] sts: Specific to manufacturer Error 1",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address);
|
||||||
}
|
}
|
||||||
if ((data_var->header.status & 0x40)) {
|
if ((data_var->header.status & 0x40)) {
|
||||||
coloredMsg(LOG_RED, true, "mbc papf [%d] sts: Specific to manufacturer Error 2", mbusCommHandle.requestId);
|
coloredMsg(LOG_RED, true, "mbc papf [%d %d] sts: Specific to manufacturer Error 2",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address);
|
||||||
}
|
}
|
||||||
if ((data_var->header.status & 0x80)) {
|
if ((data_var->header.status & 0x80)) {
|
||||||
coloredMsg(LOG_RED, true, "mbc papf [%d] sts: Specific to manufacturer Error 3", mbusCommHandle.requestId);
|
coloredMsg(LOG_RED, true, "mbc papf [%d %d] sts: Specific to manufacturer Error 3",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address);
|
||||||
}
|
}
|
||||||
mbus_data_record *record;
|
mbus_data_record *record;
|
||||||
int i;
|
int i;
|
||||||
@ -260,7 +270,8 @@ static void parseAndPrintFrame() {
|
|||||||
oledPrintf(OLED_SCREEN0, "Ok:%d/%d %.2f", mbusCommHandle.device->failures, mbusCommHandle.device->requests, errorRatio);
|
oledPrintf(OLED_SCREEN0, "Ok:%d/%d %.2f", mbusCommHandle.device->failures, mbusCommHandle.device->requests, errorRatio);
|
||||||
mbus_data_record_free(data_var->record);
|
mbus_data_record_free(data_var->record);
|
||||||
} else {
|
} else {
|
||||||
coloredMsg(LOG_RED, true, "mbc papf [%d] err: unable to parse frame", mbusCommHandle.requestId);
|
coloredMsg(LOG_RED, true, "mbc papf [%d %d] err: unable to parse frame",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,7 +373,9 @@ void mbusCommExec() {
|
|||||||
// coloredMsg(LOG_YELLOW, false, "mbc hre [%d] state SEND_CONTINUED", mbusCommHandle.requestId);
|
// coloredMsg(LOG_YELLOW, false, "mbc hre [%d] state SEND_CONTINUED", mbusCommHandle.requestId);
|
||||||
show(LED_RED, OFF);
|
show(LED_RED, OFF);
|
||||||
if (! loopActive) {
|
if (! loopActive) {
|
||||||
coloredMsg(LOG_YELLOW, true, "mbc hre [%d] enabling loop, try %d", mbusCommHandle.requestId, mbusCommHandle.retryCnt);
|
coloredMsg(LOG_YELLOW, true, "mbc hre [%d %d] enabling loop, try %d",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address,
|
||||||
|
mbusCommHandle.retryCnt);
|
||||||
mbusCommHandle.retryCnt++;
|
mbusCommHandle.retryCnt++;
|
||||||
loopEnable();
|
loopEnable();
|
||||||
} else {
|
} else {
|
||||||
@ -410,7 +423,9 @@ void mbusCommExec() {
|
|||||||
mbusCommHandle.waitForOctet = true;
|
mbusCommHandle.waitForOctet = true;
|
||||||
mbusCommHandle.state = MBCS_LENGTH1;
|
mbusCommHandle.state = MBCS_LENGTH1;
|
||||||
} else {
|
} else {
|
||||||
coloredMsg(LOG_RED, true, "mbc hre [%d] err: invalid start1 symbol %02x", mbusCommHandle.requestId, receivedOctet);
|
coloredMsg(LOG_RED, true, "mbc hre [%d %d] err: invalid start1 symbol %02x",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address,
|
||||||
|
receivedOctet);
|
||||||
mbusCommHandle.result = MBCR_ERROR_STATE_ENGINE__START1;
|
mbusCommHandle.result = MBCR_ERROR_STATE_ENGINE__START1;
|
||||||
mbusCommHandle.state = MBCS_ERROR;
|
mbusCommHandle.state = MBCS_ERROR;
|
||||||
}
|
}
|
||||||
@ -418,14 +433,17 @@ void mbusCommExec() {
|
|||||||
|
|
||||||
case MBCS_LENGTH1:
|
case MBCS_LENGTH1:
|
||||||
if (receivedOctet <= 3) {
|
if (receivedOctet <= 3) {
|
||||||
coloredMsg(LOG_RED, true, "mbc hre [%d] err: length to small %02x", mbusCommHandle.requestId, receivedOctet);
|
coloredMsg(LOG_RED, true, "mbc hre [%d %d] err: length to small %02x",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address,
|
||||||
|
receivedOctet);
|
||||||
mbusCommHandle.result = MBCR_ERROR_STATE_ENGINE__LENGTH1;
|
mbusCommHandle.result = MBCR_ERROR_STATE_ENGINE__LENGTH1;
|
||||||
mbusCommHandle.state = MBCS_ERROR;
|
mbusCommHandle.state = MBCS_ERROR;
|
||||||
} else {
|
} else {
|
||||||
mbusCommHandle.frame.length1 = receivedOctet;
|
mbusCommHandle.frame.length1 = receivedOctet;
|
||||||
mbusCommHandle.frame.userdata = (uint8_t*) malloc(mbusCommHandle.frame.length1 - 3);
|
mbusCommHandle.frame.userdata = (uint8_t*) malloc(mbusCommHandle.frame.length1 - 3);
|
||||||
if (! mbusCommHandle.frame.userdata) {
|
if (! mbusCommHandle.frame.userdata) {
|
||||||
coloredMsg(LOG_RED, true, "mbc hre [%d] err: unable to allocate memory for userdata", mbusCommHandle.requestId);
|
coloredMsg(LOG_RED, true, "mbc hre [%d %d] err: unable to allocate memory for userdata",
|
||||||
|
mbusCommHandle.requestId, mbusCommHandle.device->address);
|
||||||
mbusCommHandle.result = MBCR_ERROR_OUT_OF_MEMORY__USERDATA;
|
mbusCommHandle.result = MBCR_ERROR_OUT_OF_MEMORY__USERDATA;
|
||||||
mbusCommHandle.state = MBCS_ERROR;
|
mbusCommHandle.state = MBCS_ERROR;
|
||||||
} else {
|
} else {
|
||||||
@ -437,8 +455,9 @@ void mbusCommExec() {
|
|||||||
|
|
||||||
case MBCS_LENGTH2:
|
case MBCS_LENGTH2:
|
||||||
if (mbusCommHandle.frame.length1 != receivedOctet) {
|
if (mbusCommHandle.frame.length1 != receivedOctet) {
|
||||||
coloredMsg(LOG_RED, true, "mbc hre [%d] err: invalid length2 %02x vs. %02x",
|
coloredMsg(LOG_RED, true, "mbc hre [%d %d] err: invalid length2 %02x vs. %02x",
|
||||||
mbusCommHandle.requestId, mbusCommHandle.frame.length1, receivedOctet);
|
mbusCommHandle.requestId, mbusCommHandle.device->address,
|
||||||
|
mbusCommHandle.frame.length1, receivedOctet);
|
||||||
mbusCommHandle.result = MBCR_ERROR_STATE_ENGINE__LENGTH2;
|
mbusCommHandle.result = MBCR_ERROR_STATE_ENGINE__LENGTH2;
|
||||||
mbusCommHandle.state = MBCS_ERROR;
|
mbusCommHandle.state = MBCS_ERROR;
|
||||||
} else {
|
} else {
|
||||||
@ -454,8 +473,8 @@ void mbusCommExec() {
|
|||||||
mbusCommHandle.waitForOctet = true;
|
mbusCommHandle.waitForOctet = true;
|
||||||
mbusCommHandle.state = MBCS_C_FIELD;
|
mbusCommHandle.state = MBCS_C_FIELD;
|
||||||
} else {
|
} else {
|
||||||
coloredMsg(LOG_RED, true, "mbc hre [%d] err: invalid start2 symbol %02x",
|
coloredMsg(LOG_RED, true, "mbc hre [%d %d] err: invalid start2 symbol %02x",
|
||||||
mbusCommHandle.requestId, receivedOctet);
|
mbusCommHandle.requestId, mbusCommHandle.device->address, receivedOctet);
|
||||||
mbusCommHandle.result = MBCR_ERROR_STATE_ENGINE__START2;
|
mbusCommHandle.result = MBCR_ERROR_STATE_ENGINE__START2;
|
||||||
mbusCommHandle.state = MBCS_ERROR;
|
mbusCommHandle.state = MBCS_ERROR;
|
||||||
}
|
}
|
||||||
@ -494,8 +513,9 @@ void mbusCommExec() {
|
|||||||
|
|
||||||
case MBCS_CHKSUM:
|
case MBCS_CHKSUM:
|
||||||
if (receivedOctet != calculatedChksum) {
|
if (receivedOctet != calculatedChksum) {
|
||||||
coloredMsg(LOG_RED, true, "mbc hre [%d] err: invalid checksum %02x vs %02x",
|
coloredMsg(LOG_RED, true, "mbc hre [%d %d] err: invalid checksum %02x vs %02x",
|
||||||
mbusCommHandle.requestId, calculatedChksum, receivedOctet);
|
mbusCommHandle.requestId, mbusCommHandle.device->address,
|
||||||
|
calculatedChksum, receivedOctet);
|
||||||
mbusCommHandle.result = MBCR_ERROR_STATE_ENGINE__INVALID_CHKSUM;
|
mbusCommHandle.result = MBCR_ERROR_STATE_ENGINE__INVALID_CHKSUM;
|
||||||
mbusCommHandle.state = MBCS_ERROR;
|
mbusCommHandle.state = MBCS_ERROR;
|
||||||
} else {
|
} else {
|
||||||
@ -510,8 +530,8 @@ void mbusCommExec() {
|
|||||||
mbusCommHandle.frame.stop = receivedOctet;
|
mbusCommHandle.frame.stop = receivedOctet;
|
||||||
mbusCommHandle.state = MBCS_DONE;
|
mbusCommHandle.state = MBCS_DONE;
|
||||||
} else {
|
} else {
|
||||||
coloredMsg(LOG_RED, true, "mbc hre [%d] err: invalid stop symbol %02x",
|
coloredMsg(LOG_RED, true, "mbc hre [%d %d] err: invalid stop symbol %02x",
|
||||||
mbusCommHandle.requestId, receivedOctet);
|
mbusCommHandle.requestId, mbusCommHandle.device->address, receivedOctet);
|
||||||
mbusCommHandle.result = MBCR_ERROR_STATE_ENGINE__STOP;
|
mbusCommHandle.result = MBCR_ERROR_STATE_ENGINE__STOP;
|
||||||
mbusCommHandle.state = MBCS_ERROR;
|
mbusCommHandle.state = MBCS_ERROR;
|
||||||
}
|
}
|
||||||
@ -530,7 +550,7 @@ void mbusCommExec() {
|
|||||||
|
|
||||||
case MBCS_ERROR:
|
case MBCS_ERROR:
|
||||||
// coloredMsg(LOG_RED, false, "mbc hre [%d] state ERROR", mbusCommHandle.requestId);
|
// coloredMsg(LOG_RED, false, "mbc hre [%d] state ERROR", mbusCommHandle.requestId);
|
||||||
coloredMsg(LOG_RED, true, "mbc hre [%d] error", mbusCommHandle.requestId);
|
coloredMsg(LOG_RED, true, "mbc hre [%d %d] error", mbusCommHandle.requestId, mbusCommHandle.device->address);
|
||||||
show(LED_RED, ON);
|
show(LED_RED, ON);
|
||||||
// disable frontend immediately in case of error since no more data in relevant
|
// disable frontend immediately in case of error since no more data in relevant
|
||||||
// this avoids strange noise on RX line/led
|
// this avoids strange noise on RX line/led
|
||||||
@ -545,7 +565,7 @@ void mbusCommExec() {
|
|||||||
|
|
||||||
case MBCS_TIMEOUT:
|
case MBCS_TIMEOUT:
|
||||||
// coloredMsg(LOG_RED, false, "mbc hre [%d] state TIMEOUT", mbusCommHandle.requestId);
|
// coloredMsg(LOG_RED, false, "mbc hre [%d] state TIMEOUT", mbusCommHandle.requestId);
|
||||||
coloredMsg(LOG_RED, true, "mbc hre [%d] timeout", mbusCommHandle.requestId);
|
coloredMsg(LOG_RED, true, "mbc hre [%d %d] timeout", mbusCommHandle.requestId, mbusCommHandle.device->address);
|
||||||
mbusCommStats.mbusErrorCnt += 1;
|
mbusCommStats.mbusErrorCnt += 1;
|
||||||
mbusCommHandle.device->failures += 1;
|
mbusCommHandle.device->failures += 1;
|
||||||
mbusCommHandle.startTime = 0; // disable timeout
|
mbusCommHandle.startTime = 0; // disable timeout
|
||||||
@ -588,7 +608,7 @@ static e_mbusCommRequestResult mbusCommRequest(t_mbusDevice *mbusDevice) {
|
|||||||
mbusCommHandle.device = mbusDevice;
|
mbusCommHandle.device = mbusDevice;
|
||||||
mbusDevice->requests += 1;
|
mbusDevice->requests += 1;
|
||||||
|
|
||||||
coloredMsg(LOG_YELLOW, true, "mbc mcr [%d] new request %s (%d)",
|
coloredMsg(LOG_YELLOW, false, "mbc mcr [%d] new request %s (%d)",
|
||||||
mbusCommHandle.requestId,
|
mbusCommHandle.requestId,
|
||||||
mbusDevice->deviceName, mbusDevice->address);
|
mbusDevice->deviceName, mbusDevice->address);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user