selftest bug behoben

This commit is contained in:
devfix 2019-05-09 15:06:38 +02:00
parent 4f62b06209
commit 7791bfd5c9
4 changed files with 25 additions and 15 deletions

Binary file not shown.

View file

@ -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()

View file

@ -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;

View file

@ -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)