introduce error counter to avoid spam

This commit is contained in:
Robin Müller 2022-12-06 10:05:23 +01:00
parent 5b0ea91222
commit 05cad893a2
2 changed files with 9 additions and 4 deletions

View File

@ -109,14 +109,17 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
}
if (write(fd, sendData, sendLen) != static_cast<int>(sendLen)) {
i2cCookie->errorCounter++;
if (i2cCookie->errorCounter < 3) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "I2cComIF::sendMessage: Failed to send data to I2C "
"device with error code "
<< errno << ". Error description: " << strerror(errno) << std::endl;
#endif
}
return returnvalue::FAILED;
}
i2cCookie->errorCounter = 0;
#if FSFW_HAL_I2C_WIRETAPPING == 1
sif::info << "Sent I2C data to bus " << deviceFile << ":" << std::endl;
arrayprinter::print(sendData, sendLen);

View File

@ -27,6 +27,8 @@ class I2cCookie : public CookieIF {
size_t getMaxReplyLen() const;
std::string getDeviceFile() const;
uint8_t errorCounter = 0;
private:
address_t i2cAddress = 0;
size_t maxReplyLen = 0;