EIVE upstream #29
@ -7,7 +7,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface.h"
|
||||||
|
|
||||||
UioMapper::UioMapper(std::string uioFile, int mapNum) : uioFile(uioFile), mapNum(mapNum) {}
|
UioMapper::UioMapper(std::string uioFile, int mapNum) : uioFile(uioFile), mapNum(mapNum) {}
|
||||||
|
|
||||||
@ -17,7 +17,9 @@ ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permiss
|
|||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
int fd = open(uioFile.c_str(), O_RDWR);
|
int fd = open(uioFile.c_str(), O_RDWR);
|
||||||
if (fd < 1) {
|
if (fd < 1) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl;
|
sif::warning << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl;
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
@ -29,8 +31,10 @@ ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permiss
|
|||||||
mmap(NULL, size, static_cast<int>(permissions), MAP_SHARED, fd, mapNum * getpagesize()));
|
mmap(NULL, size, static_cast<int>(permissions), MAP_SHARED, fd, mapNum * getpagesize()));
|
||||||
|
|
||||||
if (*address == MAP_FAILED) {
|
if (*address == MAP_FAILED) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "UioMapper::getMappedAdress: Failed to map physical address of uio device "
|
sif::warning << "UioMapper::getMappedAdress: Failed to map physical address of uio device "
|
||||||
<< uioFile.c_str() << " and map" << static_cast<int>(mapNum) << std::endl;
|
<< uioFile.c_str() << " and map" << static_cast<int>(mapNum) << std::endl;
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
@ -43,22 +47,28 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) {
|
|||||||
FILE* fp;
|
FILE* fp;
|
||||||
fp = fopen(namestream.str().c_str(), "r");
|
fp = fopen(namestream.str().c_str(), "r");
|
||||||
if (fp == nullptr) {
|
if (fp == nullptr) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "UioMapper::getMapSize: Failed to open file " << namestream.str() << std::endl;
|
sif::warning << "UioMapper::getMapSize: Failed to open file " << namestream.str() << std::endl;
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
char hexstring[SIZE_HEX_STRING] = "";
|
char hexstring[SIZE_HEX_STRING] = "";
|
||||||
int items = fscanf(fp, "%s", hexstring);
|
int items = fscanf(fp, "%s", hexstring);
|
||||||
if (items != 1) {
|
if (items != 1) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "UioMapper::getMapSize: Failed with error code " << errno
|
sif::warning << "UioMapper::getMapSize: Failed with error code " << errno
|
||||||
<< " to read size "
|
<< " to read size "
|
||||||
"string from file "
|
"string from file "
|
||||||
<< namestream.str() << std::endl;
|
<< namestream.str() << std::endl;
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
items = sscanf(hexstring, "%x", size);
|
items = sscanf(hexstring, "%lx", size);
|
||||||
if (items != 1) {
|
if (items != 1) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "UioMapper::getMapSize: Failed with error code " << errno << "to convert "
|
sif::warning << "UioMapper::getMapSize: Failed with error code " << errno << "to convert "
|
||||||
<< "size of map" << mapNum << " to integer" << std::endl;
|
<< "size of map" << mapNum << " to integer" << std::endl;
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
Loading…
Reference in New Issue
Block a user