diff --git a/driver/cli b/driver/cli index c291f80..1b2738d 100755 Binary files a/driver/cli and b/driver/cli differ diff --git a/driver/drv/b15f.cpp b/driver/drv/b15f.cpp index 59dbf72..3d5de24 100644 --- a/driver/drv/b15f.cpp +++ b/driver/drv/b15f.cpp @@ -57,15 +57,13 @@ void B15F::init() void B15F::reconnect() { uint8_t tries = RECONNECT_TRIES; - while(tries-- && false) + while(tries--) { delay_ms(RECONNECT_TIMEOUT); - - discard(); + discard(); if(testConnection()) return; - } abort("Verbindung kann nicht repariert werden"); @@ -73,13 +71,20 @@ void B15F::reconnect() void B15F::discard(void) { - usart.clearOutputBuffer(); - for(uint8_t i = 0; i < 16; i++) + try { - usart.writeByte(RQ_DISC); // sende discard Befehl (verwerfe input) - delay_ms(4); + usart.clearOutputBuffer(); + for(uint8_t i = 0; i < 16; i++) + { + usart.writeByte(RQ_DISC); // sende discard Befehl (verwerfe input) + delay_ms(4); + } + usart.clearInputBuffer(); + } + catch(std::exception& ex) + { + abort(ex); } - usart.clearInputBuffer(); } bool B15F::testConnection() diff --git a/driver/drv/b15f.h b/driver/drv/b15f.h index 9cfed2d..d183644 100644 --- a/driver/drv/b15f.h +++ b/driver/drv/b15f.h @@ -201,20 +201,21 @@ public: /*************************/ -private: - - USART usart; - static B15F* instance; - static errorhandler_t errorhandler; - // CONSTANTS const std::string PRE = "[B15F] "; constexpr static uint8_t MSG_OK = 0xFF; constexpr static uint8_t MSG_FAIL = 0xFE; constexpr static uint16_t RECONNECT_TIMEOUT = 64; // ms + constexpr static uint16_t WDT_TIMEOUT = 15; // ms constexpr static uint8_t RECONNECT_TRIES = 3; constexpr static uint32_t BAUDRATE = 57600; + +private: + + USART usart; + static B15F* instance; + static errorhandler_t errorhandler; // REQUESTS constexpr static uint8_t RQ_DISC = 0; diff --git a/driver/ui/ui.cpp b/driver/ui/ui.cpp index 57b5ba4..f1c1556 100644 --- a/driver/ui/ui.cpp +++ b/driver/ui/ui.cpp @@ -262,6 +262,10 @@ void stop_selftest(int) { B15F& drv = B15F::getInstance(); drv.discard(); + drv.delay_ms(B15F::WDT_TIMEOUT); + drv.reconnect(); + drv.digitalWrite0(0); + drv.digitalWrite1(0); } void show_selftest_info(int)