I2C no close call #129
@ -67,6 +67,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## Changes
|
||||
|
||||
- Linux `I2cComIF`: No `close` call. Not done in any examples or in official docs. This should not
|
||||
be an issue, but let us do it like it is recommended officially.
|
||||
- `CService201HealthCommanding` renamed to `CServiceHealthCommanding`,
|
||||
service ID customizable now. `CServiceHealthCommanding` expects configuration struct
|
||||
`HealthServiceCfg` now
|
||||
|
@ -98,9 +98,9 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
||||
}
|
||||
|
||||
const auto& deviceFile = i2cCookie->getDeviceFile();
|
||||
UnixFileGuard fileHelper(deviceFile, fd, O_RDWR, "I2cComIF::sendMessage");
|
||||
if (fileHelper.getOpenResult() != returnvalue::OK) {
|
||||
return fileHelper.getOpenResult();
|
||||
result = openI2cDev(deviceFile, fd);
|
||||
if(result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = openI2cSlave(deviceFile, i2cAddress, fd);
|
||||
if (result != returnvalue::OK) {
|
||||
@ -156,9 +156,9 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
||||
i2cDeviceMapIter->second.replyLen = 0;
|
||||
|
||||
auto& deviceFile = i2cCookie->getDeviceFile();
|
||||
UnixFileGuard fileHelper(deviceFile, fd, O_RDWR, "I2cComIF::requestReceiveMessage");
|
||||
if (fileHelper.getOpenResult() != returnvalue::OK) {
|
||||
return fileHelper.getOpenResult();
|
||||
result = openI2cDev(deviceFile, fd);
|
||||
if(result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = openI2cSlave(deviceFile, i2cAddress, fd);
|
||||
if (result != returnvalue::OK) {
|
||||
@ -235,3 +235,20 @@ ReturnValue_t I2cComIF::openI2cSlave(const std::string& deviceFile, address_t i2
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t I2cComIF::openI2cDev(const std::string &dev, int &fd) {
|
||||
fd = open(dev.c_str(), O_RDWR);
|
||||
if(fd < 0) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "I2cComIF: Opening device failed with error code " << errno << ": "
|
||||
<< strerror(errno) << std::endl;
|
||||
#else
|
||||
sif::printWarning("I2cComIF: Opening device failed with error code %d: %s\n", errno,
|
||||
strerror(errno));
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ class I2cComIF : public DeviceCommunicationIF, public SystemObject {
|
||||
*/
|
||||
ReturnValue_t openI2cSlave(const std::string &deviceFile, address_t i2cAddress,
|
||||
int &fileDescriptor);
|
||||
ReturnValue_t openI2cDev(const std::string& dev, int&fd);
|
||||
|
||||
};
|
||||
|
||||
#endif /* LINUX_I2C_I2COMIF_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user