small fixes and refactoring

This commit is contained in:
2021-06-05 14:42:20 +02:00
parent 5ff344eee2
commit a35fdbc5dc
7 changed files with 35 additions and 29 deletions

View File

@ -49,7 +49,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) {
case(gpio::GpioTypes::NONE): {
return GPIO_INVALID_INSTANCE;
}
case(gpio::GpioTypes::GPIOD_REGULAR): {
case(gpio::GpioTypes::GPIO_REGULAR): {
GpiodRegular* regularGpio = dynamic_cast<GpiodRegular*>(gpioConfig.second);
if(regularGpio == nullptr) {
return GPIO_INVALID_INSTANCE;
@ -145,7 +145,7 @@ ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) {
return UNKNOWN_GPIO_ID;
}
if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) {
if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIO_REGULAR) {
return driveGpio(gpioId, dynamic_cast<GpiodRegular*>(gpioMapIter->second), 1);
}
else {
@ -166,7 +166,7 @@ ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) {
return UNKNOWN_GPIO_ID;
}
if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) {
if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIO_REGULAR) {
return driveGpio(gpioId, dynamic_cast<GpiodRegular*>(gpioMapIter->second), 0);
}
else {
@ -203,7 +203,7 @@ ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) {
return UNKNOWN_GPIO_ID;
}
if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) {
if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIO_REGULAR) {
GpiodRegular* regularGpio = dynamic_cast<GpiodRegular*>(gpioMapIter->second);
if(regularGpio == nullptr) {
return GPIO_TYPE_FAILURE;
@ -223,7 +223,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd){
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
for(auto& gpioConfig: mapToAdd) {
switch(gpioConfig.second->gpioType) {
case(gpio::GpioTypes::GPIOD_REGULAR): {
case(gpio::GpioTypes::GPIO_REGULAR): {
auto regularGpio = dynamic_cast<GpiodRegular*>(gpioConfig.second);
if(regularGpio == nullptr) {
return GPIO_TYPE_FAILURE;
@ -261,7 +261,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflictsRegularGpio(gpioId_t gpioIdToChec
/* Cross check with private map */
gpioMapIter = gpioMap.find(gpioIdToCheck);
if(gpioMapIter != gpioMap.end()) {
if(gpioMapIter->second->gpioType != gpio::GpioTypes::GPIOD_REGULAR) {
if(gpioMapIter->second->gpioType != gpio::GpioTypes::GPIO_REGULAR) {
sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different "
"GPIO type" << gpioIdToCheck << ". Removing duplicate." << std::endl;
mapToAdd.erase(gpioIdToCheck);

View File

@ -38,8 +38,8 @@ public:
private:
/* Holds the information and configuration of all used GPIOs */
GpioMap gpioMap;
GpioMapIter gpioMapIter;
GpioUnorderedMap gpioMap;
GpioUnorderedMapIter gpioMapIter;
/**
* @brief This functions drives line of a GPIO specified by the GPIO ID.

View File

@ -38,15 +38,15 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF * cookie) {
}
size_t maxReplyLen = uartCookie->getMaxReplyLen();
UartElements_t uartElements = {fileDescriptor, std::vector<uint8_t>(maxReplyLen), 0};
std::pair status = uartDeviceMap.emplace(deviceFile, uartElements);
auto status = uartDeviceMap.emplace(deviceFile, uartElements);
if (status.second == false) {
sif::debug << "UartComIF::initializeInterface: Failed to insert device " << deviceFile
<< "to Uart device map" << std::endl;
sif::debug << "UartComIF::initializeInterface: Failed to insert device " << deviceFile
<< "to UART device map" << std::endl;
return RETURN_FAILED;
}
}
else {
sif::debug << "UartComIF::initializeInterface: Uart device " << deviceFile << "already in "
sif::debug << "UartComIF::initializeInterface: UART device " << deviceFile << " already in "
<< "use" << std::endl;
return RETURN_FAILED;
}