UIO mapper can handle symlinks now
This commit is contained in:
parent
1b7e94d718
commit
226dc4d8b7
@ -11,8 +11,7 @@ DleParser::DleParser(SimpleRingBuffer& decodeRingBuf, DleEncoder& decoder, BufPa
|
|||||||
: decodeRingBuf(decodeRingBuf),
|
: decodeRingBuf(decodeRingBuf),
|
||||||
decoder(decoder),
|
decoder(decoder),
|
||||||
encodedBuf(encodedBuf),
|
encodedBuf(encodedBuf),
|
||||||
decodedBuf(decodedBuf) {
|
decodedBuf(decodedBuf) {}
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t DleParser::passData(const uint8_t* data, size_t len) {
|
ReturnValue_t DleParser::passData(const uint8_t* data, size_t len) {
|
||||||
if (data == nullptr or len == 0) {
|
if (data == nullptr or len == 0) {
|
||||||
@ -126,7 +125,8 @@ void DleParser::defaultErrorHandler() {
|
|||||||
case (ErrorTypes::ENCODED_BUF_TOO_SMALL):
|
case (ErrorTypes::ENCODED_BUF_TOO_SMALL):
|
||||||
case (ErrorTypes::DECODING_BUF_TOO_SMALL): {
|
case (ErrorTypes::DECODING_BUF_TOO_SMALL): {
|
||||||
char opt[64];
|
char opt[64];
|
||||||
snprintf(opt, sizeof(opt), ": Too small for packet with length %zu", ctx.decodedPacket.second);
|
snprintf(opt, sizeof(opt), ": Too small for packet with length %zu",
|
||||||
|
ctx.decodedPacket.second);
|
||||||
if (ctx.error.first == ErrorTypes::ENCODED_BUF_TOO_SMALL) {
|
if (ctx.error.first == ErrorTypes::ENCODED_BUF_TOO_SMALL) {
|
||||||
errorPrinter("Encoded buf too small", opt);
|
errorPrinter("Encoded buf too small", opt);
|
||||||
} else {
|
} else {
|
||||||
@ -168,10 +168,6 @@ ReturnValue_t DleParser::confirmBytesRead(size_t bytesRead) {
|
|||||||
return decodeRingBuf.deleteData(bytesRead);
|
return decodeRingBuf.deleteData(bytesRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
const DleParser::Context& DleParser::getContext() {
|
const DleParser::Context& DleParser::getContext() { return ctx; }
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DleParser::reset() {
|
void DleParser::reset() { decodeRingBuf.clear(); }
|
||||||
decodeRingBuf.clear();
|
|
||||||
}
|
|
||||||
|
@ -23,7 +23,9 @@ class AcceptsTelemetryIF {
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const = 0;
|
[[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const = 0;
|
||||||
|
|
||||||
[[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue() const { return getReportReceptionQueue(0); }
|
[[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue() const {
|
||||||
|
return getReportReceptionQueue(0);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_ */
|
#endif /* FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_ */
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "UartComIF.h"
|
#include "UartComIF.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
@ -331,8 +332,8 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter,
|
ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie,
|
||||||
size_t requestLen) {
|
UartDeviceMap::iterator& iter, size_t requestLen) {
|
||||||
int fd = iter->second.fileDescriptor;
|
int fd = iter->second.fileDescriptor;
|
||||||
auto bufferPtr = iter->second.replyBuffer.data();
|
auto bufferPtr = iter->second.replyBuffer.data();
|
||||||
// Size check to prevent buffer overflow
|
// Size check to prevent buffer overflow
|
||||||
@ -451,5 +452,3 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) {
|
|||||||
}
|
}
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
#ifndef BSP_Q7S_COMIF_UARTCOMIF_H_
|
#ifndef BSP_Q7S_COMIF_UARTCOMIF_H_
|
||||||
#define BSP_Q7S_COMIF_UARTCOMIF_H_
|
#define BSP_Q7S_COMIF_UARTCOMIF_H_
|
||||||
|
|
||||||
#include "UartCookie.h"
|
|
||||||
#include "helper.h"
|
|
||||||
|
|
||||||
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
|
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
|
||||||
#include <fsfw/objectmanager/SystemObject.h>
|
#include <fsfw/objectmanager/SystemObject.h>
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "UartCookie.h"
|
||||||
|
#include "helper.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This is the communication interface to access serial ports on linux based operating
|
* @brief This is the communication interface to access serial ports on linux based operating
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
#ifndef SAM9G20_COMIF_COOKIES_UART_COOKIE_H_
|
#ifndef SAM9G20_COMIF_COOKIES_UART_COOKIE_H_
|
||||||
#define SAM9G20_COMIF_COOKIES_UART_COOKIE_H_
|
#define SAM9G20_COMIF_COOKIES_UART_COOKIE_H_
|
||||||
|
|
||||||
#include "helper.h"
|
|
||||||
|
|
||||||
#include <fsfw/devicehandlers/CookieIF.h>
|
#include <fsfw/devicehandlers/CookieIF.h>
|
||||||
#include <fsfw/objectmanager/SystemObjectIF.h>
|
#include <fsfw/objectmanager/SystemObjectIF.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "helper.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Cookie for the UartComIF. There are many options available to configure the UART driver.
|
* @brief Cookie for the UartComIF. There are many options available to configure the UART driver.
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
#include "fsfw/serviceinterface.h"
|
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
#include "fsfw/serviceinterface.h"
|
||||||
|
|
||||||
void uart::setMode(struct termios& options, UartModes mode) {
|
void uart::setMode(struct termios& options, UartModes mode) {
|
||||||
if (mode == UartModes::NON_CANONICAL) {
|
if (mode == UartModes::NON_CANONICAL) {
|
||||||
/* Disable canonical mode */
|
/* Disable canonical mode */
|
||||||
@ -145,4 +146,3 @@ void uart::setBaudrate(struct termios& options, UartBaudRate baud) {
|
|||||||
int uart::readCountersAndErrors(int serialPort, serial_icounter_struct& icounter) {
|
int uart::readCountersAndErrors(int serialPort, serial_icounter_struct& icounter) {
|
||||||
return ioctl(serialPort, TIOCGICOUNT, &icounter);
|
return ioctl(serialPort, TIOCGICOUNT, &icounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef FSFW_HAL_LINUX_UART_HELPER_H_
|
#ifndef FSFW_HAL_LINUX_UART_HELPER_H_
|
||||||
#define FSFW_HAL_LINUX_UART_HELPER_H_
|
#define FSFW_HAL_LINUX_UART_HELPER_H_
|
||||||
|
|
||||||
#include <termios.h>
|
|
||||||
#include <linux/serial.h>
|
#include <linux/serial.h>
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
enum class Parity { NONE, EVEN, ODD };
|
enum class Parity { NONE, EVEN, ODD };
|
||||||
|
|
||||||
@ -56,7 +56,6 @@ void setBaudrate(struct termios& options, UartBaudRate baud);
|
|||||||
|
|
||||||
int readCountersAndErrors(int serialPort, serial_icounter_struct& icounter);
|
int readCountersAndErrors(int serialPort, serial_icounter_struct& icounter);
|
||||||
|
|
||||||
}
|
} // namespace uart
|
||||||
|
|
||||||
|
|
||||||
#endif /* FSFW_HAL_LINUX_UART_HELPER_H_ */
|
#endif /* FSFW_HAL_LINUX_UART_HELPER_H_ */
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "UioMapper.h"
|
#include "UioMapper.h"
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
@ -13,7 +14,21 @@ const char UioMapper::UIO_PATH_PREFIX[] = "/sys/class/uio/";
|
|||||||
const char UioMapper::MAP_SUBSTR[] = "/maps/map";
|
const char UioMapper::MAP_SUBSTR[] = "/maps/map";
|
||||||
const char UioMapper::SIZE_FILE_PATH[] = "/size";
|
const char UioMapper::SIZE_FILE_PATH[] = "/size";
|
||||||
|
|
||||||
UioMapper::UioMapper(std::string uioFile, int mapNum) : uioFile(uioFile), mapNum(mapNum) {}
|
UioMapper::UioMapper(std::string uioFile, int mapNum) : mapNum(mapNum) {
|
||||||
|
struct stat buf;
|
||||||
|
lstat(uioFile.c_str(), &buf);
|
||||||
|
if (S_ISLNK(buf.st_mode)) {
|
||||||
|
char* res = realpath(uioFile.c_str(), nullptr);
|
||||||
|
if (res) {
|
||||||
|
this->uioFile = res;
|
||||||
|
} else {
|
||||||
|
sif::error << "Could not resolve real path of UIO file " << uioFile << std::endl;
|
||||||
|
}
|
||||||
|
free(res);
|
||||||
|
} else {
|
||||||
|
this->uioFile = std::move(uioFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UioMapper::~UioMapper() {}
|
UioMapper::~UioMapper() {}
|
||||||
|
|
||||||
@ -22,7 +37,7 @@ ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permiss
|
|||||||
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
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl;
|
sif::error << "UioMapper::getMappedAdress: Invalid UIO device file " << uioFile << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user