EIVE upstream #29
@ -1,6 +1,7 @@
|
||||
#ifndef FSFW_TIMEMANAGER_TIMEREADERIF_H
|
||||
#define FSFW_TIMEMANAGER_TIMEREADERIF_H
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "fsfw/platform.h"
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "SerialComIF.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <fsfw_hal/linux/serial/SerialComIF.h>
|
||||
@ -21,7 +23,7 @@ ReturnValue_t SerialComIF::initializeInterface(CookieIF* cookie) {
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
SerialCookie* uartCookie = dynamic_cast<SerialCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "UartComIF::initializeInterface: Invalid UART Cookie!" << std::endl;
|
||||
@ -58,7 +60,7 @@ ReturnValue_t SerialComIF::initializeInterface(CookieIF* cookie) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
int SerialComIF::configureUartPort(UartCookie* uartCookie) {
|
||||
int SerialComIF::configureUartPort(SerialCookie* uartCookie) {
|
||||
struct termios options = {};
|
||||
|
||||
std::string deviceFile = uartCookie->getDeviceFile();
|
||||
@ -113,7 +115,7 @@ int SerialComIF::configureUartPort(UartCookie* uartCookie) {
|
||||
return fd;
|
||||
}
|
||||
|
||||
void SerialComIF::setStopBitOptions(struct termios* options, UartCookie* uartCookie) {
|
||||
void SerialComIF::setStopBitOptions(struct termios* options, SerialCookie* uartCookie) {
|
||||
/* Clear stop field. Sets stop bit to one bit */
|
||||
options->c_cflag &= ~CSTOPB;
|
||||
switch (uartCookie->getStopBits()) {
|
||||
@ -125,7 +127,7 @@ void SerialComIF::setStopBitOptions(struct termios* options, UartCookie* uartCoo
|
||||
}
|
||||
}
|
||||
|
||||
void SerialComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCookie) {
|
||||
void SerialComIF::setDatasizeOptions(struct termios* options, SerialCookie* uartCookie) {
|
||||
/* Clear size bits */
|
||||
options->c_cflag &= ~CSIZE;
|
||||
switch (uartCookie->getBitsPerWord()) {
|
||||
@ -187,7 +189,7 @@ ReturnValue_t SerialComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
SerialCookie* uartCookie = dynamic_cast<SerialCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::sendMessasge: Invalid UART Cookie!" << std::endl;
|
||||
@ -223,7 +225,7 @@ ReturnValue_t SerialComIF::getSendSuccess(CookieIF* cookie) { return returnvalue
|
||||
ReturnValue_t SerialComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) {
|
||||
std::string deviceFile;
|
||||
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
SerialCookie* uartCookie = dynamic_cast<SerialCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "UartComIF::requestReceiveMessage: Invalid Uart Cookie!" << std::endl;
|
||||
@ -256,7 +258,7 @@ ReturnValue_t SerialComIF::requestReceiveMessage(CookieIF* cookie, size_t reques
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t SerialComIF::handleCanonicalRead(UartCookie& uartCookie,
|
||||
ReturnValue_t SerialComIF::handleCanonicalRead(SerialCookie& uartCookie,
|
||||
UartDeviceMap::iterator& iter, size_t requestLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
uint8_t maxReadCycles = uartCookie.getReadCycles();
|
||||
@ -314,7 +316,7 @@ ReturnValue_t SerialComIF::handleCanonicalRead(UartCookie& uartCookie,
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t SerialComIF::handleNoncanonicalRead(UartCookie& uartCookie,
|
||||
ReturnValue_t SerialComIF::handleNoncanonicalRead(SerialCookie& uartCookie,
|
||||
UartDeviceMap::iterator& iter,
|
||||
size_t requestLen) {
|
||||
int fd = iter->second.fileDescriptor;
|
||||
@ -352,7 +354,7 @@ ReturnValue_t SerialComIF::handleNoncanonicalRead(UartCookie& uartCookie,
|
||||
ReturnValue_t SerialComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
|
||||
std::string deviceFile;
|
||||
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
SerialCookie* uartCookie = dynamic_cast<SerialCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "UartComIF::readReceivedMessage: Invalid uart cookie!" << std::endl;
|
||||
@ -381,7 +383,7 @@ ReturnValue_t SerialComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffe
|
||||
|
||||
ReturnValue_t SerialComIF::flushUartRxBuffer(CookieIF* cookie) {
|
||||
std::string deviceFile;
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
SerialCookie* uartCookie = dynamic_cast<SerialCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::flushUartRxBuffer: Invalid uart cookie!" << std::endl;
|
||||
@ -400,7 +402,7 @@ ReturnValue_t SerialComIF::flushUartRxBuffer(CookieIF* cookie) {
|
||||
|
||||
ReturnValue_t SerialComIF::flushUartTxBuffer(CookieIF* cookie) {
|
||||
std::string deviceFile;
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
SerialCookie* uartCookie = dynamic_cast<SerialCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::flushUartTxBuffer: Invalid uart cookie!" << std::endl;
|
||||
@ -419,7 +421,7 @@ ReturnValue_t SerialComIF::flushUartTxBuffer(CookieIF* cookie) {
|
||||
|
||||
ReturnValue_t SerialComIF::flushUartTxAndRxBuf(CookieIF* cookie) {
|
||||
std::string deviceFile;
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
SerialCookie* uartCookie = dynamic_cast<SerialCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::flushUartTxAndRxBuf: Invalid uart cookie!" << std::endl;
|
||||
|
@ -75,9 +75,9 @@ class SerialComIF : public DeviceCommunicationIF, public SystemObject {
|
||||
* uart device file, baudrate, parity, stopbits etc.
|
||||
* @return The file descriptor of the configured uart.
|
||||
*/
|
||||
int configureUartPort(UartCookie* uartCookie);
|
||||
int configureUartPort(SerialCookie* uartCookie);
|
||||
|
||||
void setStopBitOptions(struct termios* options, UartCookie* uartCookie);
|
||||
void setStopBitOptions(struct termios* options, SerialCookie* uartCookie);
|
||||
|
||||
/**
|
||||
* @brief This function sets options which are not configurable by the uartCookie.
|
||||
@ -87,11 +87,11 @@ class SerialComIF : public DeviceCommunicationIF, public SystemObject {
|
||||
/**
|
||||
* @brief With this function the datasize settings are added to the termios options struct.
|
||||
*/
|
||||
void setDatasizeOptions(struct termios* options, UartCookie* uartCookie);
|
||||
void setDatasizeOptions(struct termios* options, SerialCookie* uartCookie);
|
||||
|
||||
ReturnValue_t handleCanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter,
|
||||
ReturnValue_t handleCanonicalRead(SerialCookie& uartCookie, UartDeviceMap::iterator& iter,
|
||||
size_t requestLen);
|
||||
ReturnValue_t handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter,
|
||||
ReturnValue_t handleNoncanonicalRead(SerialCookie& uartCookie, UartDeviceMap::iterator& iter,
|
||||
size_t requestLen);
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include <fsfw/serviceinterface.h>
|
||||
#include <fsfw_hal/linux/serial/SerialCookie.h>
|
||||
#include "SerialCookie.h"
|
||||
|
||||
UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate,
|
||||
#include <fsfw/serviceinterface.h>
|
||||
|
||||
SerialCookie::SerialCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate,
|
||||
size_t maxReplyLen, UartModes uartMode)
|
||||
: handlerId(handlerId),
|
||||
deviceFile(deviceFile),
|
||||
@ -9,42 +10,42 @@ UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartBaudRa
|
||||
baudrate(baudrate),
|
||||
maxReplyLen(maxReplyLen) {}
|
||||
|
||||
UartCookie::~UartCookie() {}
|
||||
SerialCookie::~SerialCookie() {}
|
||||
|
||||
UartBaudRate UartCookie::getBaudrate() const { return baudrate; }
|
||||
UartBaudRate SerialCookie::getBaudrate() const { return baudrate; }
|
||||
|
||||
size_t UartCookie::getMaxReplyLen() const { return maxReplyLen; }
|
||||
size_t SerialCookie::getMaxReplyLen() const { return maxReplyLen; }
|
||||
|
||||
std::string UartCookie::getDeviceFile() const { return deviceFile; }
|
||||
std::string SerialCookie::getDeviceFile() const { return deviceFile; }
|
||||
|
||||
void UartCookie::setParityOdd() { parity = Parity::ODD; }
|
||||
void SerialCookie::setParityOdd() { parity = Parity::ODD; }
|
||||
|
||||
void UartCookie::setParityEven() { parity = Parity::EVEN; }
|
||||
void SerialCookie::setParityEven() { parity = Parity::EVEN; }
|
||||
|
||||
Parity UartCookie::getParity() const { return parity; }
|
||||
Parity SerialCookie::getParity() const { return parity; }
|
||||
|
||||
void UartCookie::setBitsPerWord(BitsPerWord bitsPerWord_) { bitsPerWord = bitsPerWord_; }
|
||||
void SerialCookie::setBitsPerWord(BitsPerWord bitsPerWord_) { bitsPerWord = bitsPerWord_; }
|
||||
|
||||
BitsPerWord UartCookie::getBitsPerWord() const { return bitsPerWord; }
|
||||
BitsPerWord SerialCookie::getBitsPerWord() const { return bitsPerWord; }
|
||||
|
||||
StopBits UartCookie::getStopBits() const { return stopBits; }
|
||||
StopBits SerialCookie::getStopBits() const { return stopBits; }
|
||||
|
||||
void UartCookie::setTwoStopBits() { stopBits = StopBits::TWO_STOP_BITS; }
|
||||
void SerialCookie::setTwoStopBits() { stopBits = StopBits::TWO_STOP_BITS; }
|
||||
|
||||
void UartCookie::setOneStopBit() { stopBits = StopBits::ONE_STOP_BIT; }
|
||||
void SerialCookie::setOneStopBit() { stopBits = StopBits::ONE_STOP_BIT; }
|
||||
|
||||
UartModes UartCookie::getUartMode() const { return uartMode; }
|
||||
UartModes SerialCookie::getUartMode() const { return uartMode; }
|
||||
|
||||
void UartCookie::setReadCycles(uint8_t readCycles) { this->readCycles = readCycles; }
|
||||
void SerialCookie::setReadCycles(uint8_t readCycles) { this->readCycles = readCycles; }
|
||||
|
||||
void UartCookie::setToFlushInput(bool enable) { this->flushInput = enable; }
|
||||
void SerialCookie::setToFlushInput(bool enable) { this->flushInput = enable; }
|
||||
|
||||
uint8_t UartCookie::getReadCycles() const { return readCycles; }
|
||||
uint8_t SerialCookie::getReadCycles() const { return readCycles; }
|
||||
|
||||
bool UartCookie::getInputShouldBeFlushed() { return this->flushInput; }
|
||||
bool SerialCookie::getInputShouldBeFlushed() { return this->flushInput; }
|
||||
|
||||
object_id_t UartCookie::getHandlerId() const { return this->handlerId; }
|
||||
object_id_t SerialCookie::getHandlerId() const { return this->handlerId; }
|
||||
|
||||
void UartCookie::setNoFixedSizeReply() { replySizeFixed = false; }
|
||||
void SerialCookie::setNoFixedSizeReply() { replySizeFixed = false; }
|
||||
|
||||
bool UartCookie::isReplySizeFixed() { return replySizeFixed; }
|
||||
bool SerialCookie::isReplySizeFixed() { return replySizeFixed; }
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* @author J. Meier
|
||||
*/
|
||||
class UartCookie : public CookieIF {
|
||||
class SerialCookie : public CookieIF {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor for the uart cookie.
|
||||
@ -29,10 +29,10 @@ class UartCookie : public CookieIF {
|
||||
* 8 databits (number of bits transfered with one uart frame)
|
||||
* One stop bit
|
||||
*/
|
||||
UartCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate,
|
||||
SerialCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate,
|
||||
size_t maxReplyLen, UartModes uartMode = UartModes::NON_CANONICAL);
|
||||
|
||||
virtual ~UartCookie();
|
||||
virtual ~SerialCookie();
|
||||
|
||||
UartBaudRate getBaudrate() const;
|
||||
size_t getMaxReplyLen() const;
|
||||
|
Loading…
Reference in New Issue
Block a user