1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-14 22:43:07 +01:00

intermediate: recovery

This commit is contained in:
andreas
2023-08-24 21:04:28 +02:00
parent 41d8578681
commit 475652ff6e
3 changed files with 57 additions and 2 deletions

View File

@@ -844,12 +844,17 @@ void loop() {
if (now > (lastCanRecovery + CAN_RECOVERY_PERIOD)){
lastCanRecovery=now;
Nmea2kTwai::STATE canState=NMEA2000.getState();
Nmea2kTwai::ERRORS canErrors=NMEA2000.getErrors();
logger.logDebug(GwLog::DEBUG,"can state %s, rxerr %d, txerr %d, txfail %d",NMEA2000.stateStr(canState),canErrors.rx_errors,canErrors.tx_errors,canErrors.tx_failed);
if (canState != Nmea2kTwai::ST_RUNNING){
logger.logDebug(GwLog::DEBUG,"can state: %d",canState);
if (canState == Nmea2kTwai::ST_BUS_OFF){
bool rt=NMEA2000.startRecovery();
logger.logDebug(GwLog::LOG,"start can recovery - result %d",(int)rt);
}
if (canState == Nmea2kTwai::ST_STOPPED){
bool rt=NMEA2000.CANOpen();
logger.logDebug(GwLog::LOG,"restart can driver - result %d",(int)rt);
}
}
}
monitor.setTime(3);