EIVE upstream #29
@ -41,7 +41,7 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) {
|
|||||||
|
|
||||||
i2cAddress = i2cCookie->getAddress();
|
i2cAddress = i2cCookie->getAddress();
|
||||||
|
|
||||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||||
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
||||||
size_t maxReplyLen = i2cCookie->getMaxReplyLen();
|
size_t maxReplyLen = i2cCookie->getMaxReplyLen();
|
||||||
I2cInstance i2cInstance = {std::vector<uint8_t>(maxReplyLen), 0};
|
I2cInstance i2cInstance = {std::vector<uint8_t>(maxReplyLen), 0};
|
||||||
@ -89,7 +89,7 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
address_t i2cAddress = i2cCookie->getAddress();
|
address_t i2cAddress = i2cCookie->getAddress();
|
||||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||||
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not "
|
sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not "
|
||||||
@ -140,20 +140,19 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
|||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "I2cComIF::requestReceiveMessage: Invalid I2C Cookie!" << std::endl;
|
sif::error << "I2cComIF::requestReceiveMessage: Invalid I2C Cookie!" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
i2cDeviceMapIter->second.replyLen = 0;
|
|
||||||
return NULLPOINTER;
|
return NULLPOINTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
address_t i2cAddress = i2cCookie->getAddress();
|
address_t i2cAddress = i2cCookie->getAddress();
|
||||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||||
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "I2cComIF::requestReceiveMessage: i2cAddress of Cookie not "
|
sif::error << "I2cComIF::requestReceiveMessage: i2cAddress of Cookie not "
|
||||||
<< "registered in i2cDeviceMap" << std::endl;
|
<< "registered in i2cDeviceMap" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
i2cDeviceMapIter->second.replyLen = 0;
|
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
|
i2cDeviceMapIter->second.replyLen = 0;
|
||||||
|
|
||||||
deviceFile = i2cCookie->getDeviceFile();
|
deviceFile = i2cCookie->getDeviceFile();
|
||||||
UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::requestReceiveMessage");
|
UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::requestReceiveMessage");
|
||||||
@ -162,7 +161,6 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
|||||||
}
|
}
|
||||||
result = openDevice(deviceFile, i2cAddress, &fd);
|
result = openDevice(deviceFile, i2cAddress, &fd);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
i2cDeviceMapIter->second.replyLen = 0;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +181,10 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
|||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
i2cDeviceMapIter->second.replyLen = 0;
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen
|
||||||
|
<< " bytes" << std::endl;
|
||||||
|
#endif
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +207,7 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
address_t i2cAddress = i2cCookie->getAddress();
|
address_t i2cAddress = i2cCookie->getAddress();
|
||||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||||
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "I2cComIF::readReceivedMessage: i2cAddress of Cookie not "
|
sif::error << "I2cComIF::readReceivedMessage: i2cAddress of Cookie not "
|
||||||
|
@ -36,12 +36,10 @@ class I2cComIF : public DeviceCommunicationIF, public SystemObject {
|
|||||||
};
|
};
|
||||||
|
|
||||||
using I2cDeviceMap = std::unordered_map<address_t, I2cInstance>;
|
using I2cDeviceMap = std::unordered_map<address_t, I2cInstance>;
|
||||||
using I2cDeviceMapIter = I2cDeviceMap::iterator;
|
|
||||||
|
|
||||||
/* In this map all i2c devices will be registered with their address and
|
/* In this map all i2c devices will be registered with their address and
|
||||||
* the appropriate file descriptor will be stored */
|
* the appropriate file descriptor will be stored */
|
||||||
I2cDeviceMap i2cDeviceMap;
|
I2cDeviceMap i2cDeviceMap;
|
||||||
I2cDeviceMapIter i2cDeviceMapIter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function opens an I2C device and binds the opened file
|
* @brief This function opens an I2C device and binds the opened file
|
||||||
|
Loading…
Reference in New Issue
Block a user