error handling
This commit is contained in:
parent
737a2ce3ac
commit
8c6af80a11
@ -58,7 +58,8 @@ typedef enum {
|
||||
MBCS_DONE,
|
||||
MBCS_TIMEOUT,
|
||||
MBCS_DISABLE_FRONTEND,
|
||||
MBCS_ERROR
|
||||
MBCS_ERROR,
|
||||
MBCS_ERROR_CONTINUED
|
||||
} e_mbusCommState;
|
||||
|
||||
typedef struct {
|
||||
@ -105,6 +106,16 @@ t_mbusCommStats *mbusCommGetStats() {
|
||||
return &mbusCommStats;
|
||||
}
|
||||
|
||||
|
||||
static void printError(t_mbusCommHandle *localMbusCommHandle) {
|
||||
float errorRatio = ((float) localMbusCommHandle->device->failures) / ((float) localMbusCommHandle->device->requests);
|
||||
coloredMsg(LOG_YELLOW, true, "mbc pe [%d] Error ratio is %.2f",
|
||||
localMbusCommHandle->requestId,
|
||||
errorRatio);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void parseAndPrintFrame(t_mbusCommHandle *localMbusCommHandle) {
|
||||
t_longframe *frame = &(localMbusCommHandle->frame);
|
||||
|
||||
@ -405,6 +416,11 @@ static void handleRequestEngine(void *handle) {
|
||||
show(LED_RED, ON);
|
||||
coloredMsg(LOG_RED, true, "mbc hre [%d] err: already error, read the rest (now: %02x) until timeout",
|
||||
localMbusCommHandle->requestId, localMbusCommHandle->receivedOctet);
|
||||
printError(localMbusCommHandle);
|
||||
localMbusCommHandle->state = MBCS_ERROR_CONTINUED;
|
||||
// no break
|
||||
|
||||
case MBCS_ERROR_CONTINUED;
|
||||
receiveNext(localMbusCommHandle);
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user