Compare commits
55 Commits
bugfix_dhb
...
a8167f5431
Author | SHA1 | Date | |
---|---|---|---|
a8167f5431 | |||
41f3d7cf9a | |||
e6e1936293 | |||
15f35f200a | |||
6b20bb197a | |||
215d01b3ca | |||
dfe49cc1e5 | |||
73eb11f4f1 | |||
924c150af2 | |||
469eba3ce2 | |||
fd2916af11 | |||
afd375a7f8 | |||
5454169e20 | |||
7d0377845b | |||
882da68a2f | |||
b6aebb3061 | |||
04a1fe7f10 | |||
845c00044e | |||
5f79f987ae | |||
1183e5739d | |||
e3697d6d8c | |||
406b77ea81 | |||
8a9eb27458 | |||
1ac372cb89 | |||
fb36dc4501 | |||
ba5e2ad8bb | |||
5a6c81130d | |||
22e29144b6 | |||
52bff3985f | |||
133820f463 | |||
8d3fceea8f | |||
3704d2b829 | |||
6073abb12d | |||
47bec654a0 | |||
b2c102b2c1 | |||
4202205182 | |||
c8472beb5f | |||
1a4a85ceb2 | |||
7922bf76da | |||
bb88490cc6 | |||
296c587e3d | |||
0ff81294e7 | |||
b6e243b8b3 | |||
3bbcc42d39 | |||
fc4324a2fa | |||
54c028f913 | |||
1f6a5e635f | |||
c5b4b01362 | |||
c5420c7b53 | |||
3e422f51bd | |||
d1be0f9843 | |||
b83259592a | |||
a7a4e0f219 | |||
bdc5f593e2 | |||
10f7185e81 |
@ -1,5 +1,10 @@
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "fsfw_hal/linux/UnixFileGuard.h"
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
UnixFileGuard::UnixFileGuard(std::string device, int* fileDescriptor, int flags,
|
||||
std::string diagnosticPrefix):
|
||||
fileDescriptor(fileDescriptor) {
|
||||
@ -10,12 +15,11 @@ UnixFileGuard::UnixFileGuard(std::string device, int* fileDescriptor, int flags,
|
||||
if (*fileDescriptor < 0) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << diagnosticPrefix <<"Opening device failed with error code " << errno <<
|
||||
"." << std::endl;
|
||||
sif::warning << "Error description: " << strerror(errno) << std::endl;
|
||||
sif::warning << diagnosticPrefix << ": Opening device failed with error code " <<
|
||||
errno << ": " << strerror(errno) << std::endl;
|
||||
#else
|
||||
sif::printError("%sOpening device failed with error code %d.\n", diagnosticPrefix);
|
||||
sif::printWarning("Error description: %s\n", strerror(errno));
|
||||
sif::printWarning("%s: Opening device failed with error code %d: %s\n",
|
||||
diagnosticPrefix, errno, strerror(errno));
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
openStatus = OPEN_FILE_FAILED;
|
||||
|
@ -15,11 +15,6 @@
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
/* Can be used for low-level debugging of the SPI bus */
|
||||
#ifndef FSFW_HAL_LINUX_SPI_WIRETAPPING
|
||||
#define FSFW_HAL_LINUX_SPI_WIRETAPPING 0
|
||||
#endif
|
||||
|
||||
SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF):
|
||||
SystemObject(objectId), gpioComIF(gpioComIF) {
|
||||
if(gpioComIF == nullptr) {
|
||||
@ -90,7 +85,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) {
|
||||
|
||||
int fileDescriptor = 0;
|
||||
UnixFileGuard fileHelper(spiCookie->getSpiDevice(), &fileDescriptor, O_RDWR,
|
||||
"SpiComIF::initializeInterface: ");
|
||||
"SpiComIF::initializeInterface");
|
||||
if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||
return fileHelper.getOpenResult();
|
||||
}
|
||||
@ -184,7 +179,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie *spiCookie, const
|
||||
/* Prepare transfer */
|
||||
int fileDescriptor = 0;
|
||||
std::string device = spiCookie->getSpiDevice();
|
||||
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage: ");
|
||||
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage");
|
||||
if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||
return OPENING_FILE_FAILED;
|
||||
}
|
||||
@ -273,7 +268,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
|
||||
std::string device = spiCookie->getSpiDevice();
|
||||
int fileDescriptor = 0;
|
||||
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR,
|
||||
"SpiComIF::requestReceiveMessage: ");
|
||||
"SpiComIF::requestReceiveMessage");
|
||||
if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||
return OPENING_FILE_FAILED;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef LINUX_SPI_SPICOMIF_H_
|
||||
#define LINUX_SPI_SPICOMIF_H_
|
||||
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "spiDefinitions.h"
|
||||
#include "returnvalues/classIds.h"
|
||||
#include "fsfw_hal/common/gpio/GpioIF.h"
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "fsfw_hal/linux/uart/UartComIF.h"
|
||||
#include "UartComIF.h"
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
#include "fsfw_hal/linux/utility.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <cstring>
|
||||
@ -60,7 +61,13 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) {
|
||||
struct termios options = {};
|
||||
|
||||
std::string deviceFile = uartCookie->getDeviceFile();
|
||||
int fd = open(deviceFile.c_str(), O_RDWR);
|
||||
int flags = O_RDWR;
|
||||
if(uartCookie->getUartMode() == UartModes::CANONICAL) {
|
||||
// In non-canonical mode, don't specify O_NONBLOCK because these properties will be
|
||||
// controlled by the VTIME and VMIN parameters and O_NONBLOCK would override this
|
||||
flags |= O_NONBLOCK;
|
||||
}
|
||||
int fd = open(deviceFile.c_str(), flags);
|
||||
|
||||
if (fd < 0) {
|
||||
sif::warning << "UartComIF::configureUartPort: Failed to open uart " << deviceFile <<
|
||||
@ -259,23 +266,22 @@ void UartComIF::configureBaudrate(struct termios* options, UartCookie* uartCooki
|
||||
|
||||
ReturnValue_t UartComIF::sendMessage(CookieIF *cookie,
|
||||
const uint8_t *sendData, size_t sendLen) {
|
||||
|
||||
int fd = 0;
|
||||
std::string deviceFile;
|
||||
UartDeviceMapIter uartDeviceMapIter;
|
||||
|
||||
if(sendData == nullptr) {
|
||||
sif::debug << "UartComIF::sendMessage: Send Data is nullptr" << std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
if(sendLen == 0) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
if(sendData == nullptr) {
|
||||
sif::warning << "UartComIF::sendMessage: Send data is nullptr" << std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if(uartCookie == nullptr) {
|
||||
sif::debug << "UartComIF::sendMessasge: Invalid UART Cookie!" << std::endl;
|
||||
sif::warning << "UartComIF::sendMessasge: Invalid UART Cookie!" << std::endl;
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
@ -347,12 +353,13 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
|
||||
size_t maxReplySize = uartCookie.getMaxReplyLen();
|
||||
int fd = iter->second.fileDescriptor;
|
||||
auto bufferPtr = iter->second.replyBuffer.data();
|
||||
iter->second.replyLen = 0;
|
||||
do {
|
||||
size_t allowedReadSize = 0;
|
||||
if(currentBytesRead >= maxReplySize) {
|
||||
// Overflow risk. Emit warning, trigger event and break. If this happens,
|
||||
// the reception buffer is not large enough or data is not polled often enough.
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::requestReceiveMessage: Next read would cause overflow!"
|
||||
<< std::endl;
|
||||
@ -370,8 +377,21 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
|
||||
|
||||
bytesRead = read(fd, bufferPtr, allowedReadSize);
|
||||
if (bytesRead < 0) {
|
||||
// EAGAIN: No data available in non-blocking mode
|
||||
if(errno != EAGAIN) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::handleCanonicalRead: read failed with code" <<
|
||||
errno << ": " << strerror(errno) << std::endl;
|
||||
#else
|
||||
sif::printWarning("UartComIF::handleCanonicalRead: read failed with code %d: %s\n",
|
||||
errno, strerror(errno));
|
||||
#endif
|
||||
#endif
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
}
|
||||
else if(bytesRead > 0) {
|
||||
iter->second.replyLen += bytesRead;
|
||||
bufferPtr += bytesRead;
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartModes uartMode,
|
||||
uint32_t baudrate, size_t maxReplyLen):
|
||||
handlerId(handlerId), deviceFile(deviceFile), uartMode(uartMode), baudrate(baudrate),
|
||||
maxReplyLen(maxReplyLen) {
|
||||
handlerId(handlerId), deviceFile(deviceFile), uartMode(uartMode),
|
||||
baudrate(baudrate), maxReplyLen(maxReplyLen) {
|
||||
}
|
||||
|
||||
UartCookie::~UartCookie() {}
|
||||
|
@ -11,6 +11,15 @@
|
||||
#cmakedefine FSFW_ADD_MONITORING
|
||||
#cmakedefine FSFW_ADD_SGP4_PROPAGATOR
|
||||
|
||||
#ifndef FSFW_TCP_RECV_WIRETAPPING_ENABLED
|
||||
#define FSFW_TCP_RECV_WIRETAPPING_ENABLED 0
|
||||
#endif
|
||||
|
||||
/* Can be used for low-level debugging of the SPI bus */
|
||||
#ifndef FSFW_HAL_LINUX_SPI_WIRETAPPING
|
||||
#define FSFW_HAL_LINUX_SPI_WIRETAPPING 0
|
||||
#endif
|
||||
|
||||
#ifndef FSFW_HAL_L3GD20_GYRO_DEBUG
|
||||
#define FSFW_HAL_L3GD20_GYRO_DEBUG 0
|
||||
#endif /* FSFW_HAL_L3GD20_GYRO_DEBUG */
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef FSFW_DEFAULTCFG_VERSION_H_
|
||||
#define FSFW_DEFAULTCFG_VERSION_H_
|
||||
#ifndef FSFW_VERSION_H_
|
||||
#define FSFW_VERSION_H_
|
||||
|
||||
const char* const FSFW_VERSION_NAME = "ASTP";
|
||||
|
||||
#define FSFW_VERSION 1
|
||||
#define FSFW_SUBVERSION 0
|
||||
#define FSFW_SUBVERSION 3
|
||||
#define FSFW_REVISION 0
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_DEFAULTCFG_VERSION_H_ */
|
||||
#endif /* FSFW_VERSION_H_ */
|
||||
|
@ -85,9 +85,10 @@ public:
|
||||
* Called by DHB in the GET_WRITE doGetWrite().
|
||||
* Get send confirmation that the data in sendMessage() was sent successfully.
|
||||
* @param cookie
|
||||
* @return - @c RETURN_OK if data was sent successfull
|
||||
* - Everything else triggers falure event with
|
||||
* returnvalue as parameter 1
|
||||
* @return
|
||||
* - @c RETURN_OK if data was sent successfully but a reply is expected
|
||||
* - NO_REPLY_EXPECTED if data was sent successfully and no reply is expected
|
||||
* - Everything else to indicate failure
|
||||
*/
|
||||
virtual ReturnValue_t getSendSuccess(CookieIF *cookie) = 0;
|
||||
|
||||
|
@ -654,9 +654,10 @@ void DeviceHandlerBase::doGetWrite() {
|
||||
}
|
||||
|
||||
// We need to distinguish here, because a raw command never expects a reply.
|
||||
//(Could be done in eRIRM, but then child implementations need to be careful.
|
||||
// This could be done in the #enableReplyInReplyMap call,
|
||||
// but then child implementations would need to be careful.
|
||||
result = enableReplyInReplyMap(cookieInfo.pendingCommand);
|
||||
} else {
|
||||
} else if (result != NO_REPLY_EXPECTED) {
|
||||
// always generate a failure event, so that FDIR knows what's up
|
||||
triggerEvent(DEVICE_SENDING_COMMAND_FAILED, result,
|
||||
cookieInfo.pendingCommand->first);
|
||||
@ -1341,10 +1342,20 @@ void DeviceHandlerBase::buildInternalCommand(void) {
|
||||
DeviceCommandMap::iterator iter = deviceCommandMap.find(
|
||||
deviceCommandId);
|
||||
if (iter == deviceCommandMap.end()) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
char output[36];
|
||||
sprintf(output, "Command 0x%08x unknown",
|
||||
static_cast<unsigned int>(deviceCommandId));
|
||||
// so we can track misconfigurations
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING,
|
||||
"buildInternalCommand",
|
||||
COMMAND_NOT_SUPPORTED,
|
||||
output);
|
||||
#endif
|
||||
result = COMMAND_NOT_SUPPORTED;
|
||||
}
|
||||
else if (iter->second.isExecuting) {
|
||||
#if FSFW_DISABLE_PRINTOUT == 0
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
char output[36];
|
||||
sprintf(output, "Command 0x%08x is executing",
|
||||
static_cast<unsigned int>(deviceCommandId));
|
||||
@ -1555,10 +1566,18 @@ LocalDataPoolManager* DeviceHandlerBase::getHkManagerHandle() {
|
||||
return &poolManager;
|
||||
}
|
||||
|
||||
MessageQueueId_t DeviceHandlerBase::getCommanderId(DeviceCommandId_t replyId) const {
|
||||
MessageQueueId_t DeviceHandlerBase::getCommanderQueueId(DeviceCommandId_t replyId) const {
|
||||
auto commandIter = deviceCommandMap.find(replyId);
|
||||
if(commandIter == deviceCommandMap.end()) {
|
||||
return MessageQueueIF::NO_QUEUE;
|
||||
}
|
||||
return commandIter->second.sendReplyTo;
|
||||
}
|
||||
|
||||
void DeviceHandlerBase::finishCommandExecution(DeviceCommandId_t replyId) {
|
||||
auto commandIter = deviceCommandMap.find(replyId);
|
||||
if(commandIter == deviceCommandMap.end()) {
|
||||
return;
|
||||
}
|
||||
commandIter->second.isExecuting = false;
|
||||
}
|
||||
|
@ -327,15 +327,20 @@ protected:
|
||||
* The existence of the command in the command map and the command size check against 0 are
|
||||
* done by the base class.
|
||||
*
|
||||
* The base class will generate a finish reply or a step automatically as long as the
|
||||
* send success is confirmed in the #getSendSuccess function call of the communication
|
||||
* interface. NO_REPLY_EXPECTED should be returned for a finish reply, RETURN_OK should be
|
||||
* returned for a step reply and everything else will trigger a step failure.
|
||||
*
|
||||
* If the commander ID is required for generating a finish reply immediately, it can be
|
||||
* retrieved using the #getCommanderQueueId function.
|
||||
*
|
||||
* @param deviceCommand The command to build, already checked against deviceCommandMap
|
||||
* @param commandData Pointer to the data from the direct command
|
||||
* @param commandDataLen Length of commandData
|
||||
* @return
|
||||
* - @c RETURN_OK to send command after #rawPacket and #rawPacketLen
|
||||
* have been set.
|
||||
* - @c HasActionsIF::EXECUTION_COMPLETE to generate a finish reply immediately. This can
|
||||
* be used if no reply is expected. Otherwise, the developer can call #actionHelper.finish
|
||||
* to finish the command handling.
|
||||
* - Anything else triggers an event with the return code as a parameter as well as a
|
||||
* step reply failed with the return code
|
||||
*/
|
||||
@ -399,7 +404,9 @@ protected:
|
||||
*/
|
||||
virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
|
||||
const uint8_t *packet) = 0;
|
||||
MessageQueueId_t getCommanderId(DeviceCommandId_t replyId) const;
|
||||
MessageQueueId_t getCommanderQueueId(DeviceCommandId_t replyId) const;
|
||||
void finishCommandExecution(DeviceCommandId_t replyId);
|
||||
|
||||
/**
|
||||
* Helper function to get pending command. This is useful for devices
|
||||
* like SPI sensors to identify the last sent command.
|
||||
|
@ -120,7 +120,8 @@ public:
|
||||
static const ReturnValue_t WRONG_MODE_FOR_COMMAND = MAKE_RETURN_CODE(0xA5);
|
||||
static const ReturnValue_t TIMEOUT = MAKE_RETURN_CODE(0xA6);
|
||||
static const ReturnValue_t BUSY = MAKE_RETURN_CODE(0xA7);
|
||||
static const ReturnValue_t NO_REPLY_EXPECTED = MAKE_RETURN_CODE(0xA8); //!< Used to indicate that this is a command-only command.
|
||||
//!< Used to indicate that this is a command-only command.
|
||||
static const ReturnValue_t NO_REPLY_EXPECTED = MAKE_RETURN_CODE(0xA8);
|
||||
static const ReturnValue_t NON_OP_TEMPERATURE = MAKE_RETURN_CODE(0xA9);
|
||||
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xAA);
|
||||
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
* @param args Any other arguments which an implementation might require
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t deleteFile(const char* repositoryPath,
|
||||
virtual ReturnValue_t removeFile(const char* repositoryPath,
|
||||
const char* filename, void* args = nullptr) = 0;
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "fsfw/platform.h"
|
||||
#include "fsfw/osal/common/TcpTmTcBridge.h"
|
||||
#include "fsfw/osal/common/tcpipHelpers.h"
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/ipc/MutexGuard.h"
|
||||
@ -17,8 +16,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
const std::string TcpTmTcBridge::DEFAULT_UDP_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT;
|
||||
|
||||
TcpTmTcBridge::TcpTmTcBridge(object_id_t objectId, object_id_t tcDestination,
|
||||
object_id_t tmStoreId, object_id_t tcStoreId):
|
||||
TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define FSFW_OSAL_COMMON_TCPTMTCBRIDGE_H_
|
||||
|
||||
#include "TcpIpBase.h"
|
||||
#include "../../tmtcservices/TmTcBridge.h"
|
||||
#include "fsfw/tmtcservices/TmTcBridge.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@ -29,8 +29,6 @@ class TcpTmTcBridge:
|
||||
public TmTcBridge {
|
||||
friend class TcpTmTcServer;
|
||||
public:
|
||||
/* The ports chosen here should not be used by any other process. */
|
||||
static const std::string DEFAULT_UDP_SERVER_PORT;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -1,8 +1,10 @@
|
||||
#include "fsfw/osal/common/TcpTmTcServer.h"
|
||||
#include "fsfw/osal/common/TcpTmTcBridge.h"
|
||||
#include "fsfw/osal/common/tcpipHelpers.h"
|
||||
|
||||
#include "fsfw/platform.h"
|
||||
#include "fsfw/FSFW.h"
|
||||
|
||||
#include "TcpTmTcServer.h"
|
||||
#include "TcpTmTcBridge.h"
|
||||
#include "tcpipHelpers.h"
|
||||
|
||||
#include "fsfw/container/SharedRingBuffer.h"
|
||||
#include "fsfw/ipc/MessageQueueSenderIF.h"
|
||||
#include "fsfw/ipc/MutexGuard.h"
|
||||
@ -18,18 +20,14 @@
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#ifndef FSFW_TCP_RECV_WIRETAPPING_ENABLED
|
||||
#define FSFW_TCP_RECV_WIRETAPPING_ENABLED 0
|
||||
#endif
|
||||
|
||||
const std::string TcpTmTcServer::DEFAULT_TCP_SERVER_PORT = "7303";
|
||||
const std::string TcpTmTcServer::DEFAULT_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT;
|
||||
|
||||
TcpTmTcServer::TcpTmTcServer(object_id_t objectId, object_id_t tmtcTcpBridge,
|
||||
size_t receptionBufferSize, std::string customTcpServerPort):
|
||||
SystemObject(objectId), tmtcBridgeId(tmtcTcpBridge),
|
||||
tcpPort(customTcpServerPort), receptionBuffer(receptionBufferSize) {
|
||||
if(tcpPort == "") {
|
||||
tcpPort = DEFAULT_TCP_SERVER_PORT;
|
||||
tcpPort = DEFAULT_SERVER_PORT;
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,6 +198,10 @@ void TcpTmTcServer::setTcpBacklog(uint8_t tcpBacklog) {
|
||||
this->tcpBacklog = tcpBacklog;
|
||||
}
|
||||
|
||||
std::string TcpTmTcServer::getTcpPort() const {
|
||||
return tcpPort;
|
||||
}
|
||||
|
||||
ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket) {
|
||||
// Access to the FIFO is mutex protected because it is filled by the bridge
|
||||
MutexGuard(tmtcBridge->mutex, tmtcBridge->timeoutType, tmtcBridge->mutexTimeoutMs);
|
||||
|
@ -3,13 +3,14 @@
|
||||
|
||||
#include "TcpIpBase.h"
|
||||
|
||||
#include "../../platform.h"
|
||||
#include "../../ipc/messageQueueDefinitions.h"
|
||||
#include "../../ipc/MessageQueueIF.h"
|
||||
#include "../../objectmanager/frameworkObjects.h"
|
||||
#include "../../objectmanager/SystemObject.h"
|
||||
#include "../../storagemanager/StorageManagerIF.h"
|
||||
#include "../../tasks/ExecutableObjectIF.h"
|
||||
#include "fsfw/platform.h"
|
||||
#include "fsfw/osal/common/tcpipHelpers.h"
|
||||
#include "fsfw/ipc/messageQueueDefinitions.h"
|
||||
#include "fsfw/ipc/MessageQueueIF.h"
|
||||
#include "fsfw/objectmanager/frameworkObjects.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||
|
||||
#ifdef PLATFORM_UNIX
|
||||
#include <sys/socket.h>
|
||||
@ -41,8 +42,7 @@ class TcpTmTcServer:
|
||||
public TcpIpBase,
|
||||
public ExecutableObjectIF {
|
||||
public:
|
||||
/* The ports chosen here should not be used by any other process. */
|
||||
static const std::string DEFAULT_TCP_SERVER_PORT;
|
||||
static const std::string DEFAULT_SERVER_PORT;
|
||||
|
||||
static constexpr size_t ETHERNET_MTU_SIZE = 1500;
|
||||
|
||||
@ -65,6 +65,8 @@ public:
|
||||
ReturnValue_t performOperation(uint8_t opCode) override;
|
||||
ReturnValue_t initializeAfterTaskCreation() override;
|
||||
|
||||
std::string getTcpPort() const;
|
||||
|
||||
protected:
|
||||
StorageManagerIF* tcStore = nullptr;
|
||||
StorageManagerIF* tmStore = nullptr;
|
||||
|
@ -17,13 +17,13 @@
|
||||
#define FSFW_UDP_SEND_WIRETAPPING_ENABLED 0
|
||||
#endif
|
||||
|
||||
const std::string UdpTmTcBridge::DEFAULT_UDP_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT;
|
||||
const std::string UdpTmTcBridge::DEFAULT_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT;
|
||||
|
||||
UdpTmTcBridge::UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination,
|
||||
std::string udpServerPort, object_id_t tmStoreId, object_id_t tcStoreId):
|
||||
TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) {
|
||||
if(udpServerPort == "") {
|
||||
this->udpServerPort = DEFAULT_UDP_SERVER_PORT;
|
||||
this->udpServerPort = DEFAULT_SERVER_PORT;
|
||||
}
|
||||
else {
|
||||
this->udpServerPort = udpServerPort;
|
||||
@ -108,6 +108,10 @@ UdpTmTcBridge::~UdpTmTcBridge() {
|
||||
}
|
||||
}
|
||||
|
||||
std::string UdpTmTcBridge::getUdpPort() const {
|
||||
return udpServerPort;
|
||||
}
|
||||
|
||||
ReturnValue_t UdpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) {
|
||||
int flags = 0;
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
#define FSFW_OSAL_COMMON_TMTCUDPBRIDGE_H_
|
||||
|
||||
#include "TcpIpBase.h"
|
||||
#include "../../platform.h"
|
||||
#include "../../tmtcservices/TmTcBridge.h"
|
||||
#include "fsfw/platform.h"
|
||||
#include "fsfw/tmtcservices/TmTcBridge.h"
|
||||
|
||||
#ifdef PLATFORM_WIN
|
||||
#include <ws2tcpip.h>
|
||||
@ -28,7 +28,7 @@ class UdpTmTcBridge:
|
||||
friend class UdpTcPollingTask;
|
||||
public:
|
||||
/* The ports chosen here should not be used by any other process. */
|
||||
static const std::string DEFAULT_UDP_SERVER_PORT;
|
||||
static const std::string DEFAULT_SERVER_PORT;
|
||||
|
||||
UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination,
|
||||
std::string udpServerPort = "", object_id_t tmStoreId = objects::TM_STORE,
|
||||
@ -44,6 +44,8 @@ public:
|
||||
|
||||
void checkAndSetClientAddress(sockaddr& clientAddress);
|
||||
|
||||
std::string getUdpPort() const;
|
||||
|
||||
protected:
|
||||
virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) override;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef FSFW_OSAL_COMMON_TCPIPCOMMON_H_
|
||||
#define FSFW_OSAL_COMMON_TCPIPCOMMON_H_
|
||||
|
||||
#include "../../timemanager/clockDefinitions.h"
|
||||
#include "fsfw/timemanager/clockDefinitions.h"
|
||||
#include <string>
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
namespace tcpip {
|
||||
|
||||
const char* const DEFAULT_SERVER_PORT = "7301";
|
||||
static constexpr char DEFAULT_SERVER_PORT[] = "7301";
|
||||
|
||||
enum class Protocol {
|
||||
UDP,
|
||||
|
@ -16,6 +16,7 @@ target_sources(${LIB_FSFW_NAME}
|
||||
Timer.cpp
|
||||
tcpipHelpers.cpp
|
||||
unixUtility.cpp
|
||||
CommandExecutor.cpp
|
||||
)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
185
src/fsfw/osal/linux/CommandExecutor.cpp
Normal file
185
src/fsfw/osal/linux/CommandExecutor.cpp
Normal file
@ -0,0 +1,185 @@
|
||||
#include "CommandExecutor.h"
|
||||
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "fsfw/container/SimpleRingBuffer.h"
|
||||
#include "fsfw/container/DynamicFIFO.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
CommandExecutor::CommandExecutor(const size_t maxSize):
|
||||
readVec(maxSize) {
|
||||
waiter.events = POLLIN;
|
||||
}
|
||||
|
||||
ReturnValue_t CommandExecutor::load(std::string command, bool blocking, bool printOutput) {
|
||||
if(state == States::PENDING) {
|
||||
return COMMAND_PENDING;
|
||||
}
|
||||
|
||||
currentCmd = command;
|
||||
this->blocking = blocking;
|
||||
this->printOutput = printOutput;
|
||||
if(state == States::IDLE) {
|
||||
state = States::COMMAND_LOADED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CommandExecutor::execute() {
|
||||
if(state == States::IDLE) {
|
||||
return NO_COMMAND_LOADED_OR_PENDING;
|
||||
}
|
||||
else if(state == States::PENDING) {
|
||||
return COMMAND_PENDING;
|
||||
}
|
||||
currentCmdFile = popen(currentCmd.c_str(), "r");
|
||||
if(currentCmdFile == nullptr) {
|
||||
lastError = errno;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if(blocking) {
|
||||
return executeBlocking();
|
||||
}
|
||||
else {
|
||||
currentFd = fileno(currentCmdFile);
|
||||
waiter.fd = currentFd;
|
||||
}
|
||||
state = States::PENDING;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CommandExecutor::close() {
|
||||
if(state == States::PENDING) {
|
||||
// Attempt to close process, irrespective of if it is running or not
|
||||
if(currentCmdFile != nullptr) {
|
||||
pclose(currentCmdFile);
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void CommandExecutor::printLastError(std::string funcName) const {
|
||||
if(lastError != 0) {
|
||||
sif::error << funcName << " pclose failed with code " <<
|
||||
lastError << ": " << strerror(lastError) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void CommandExecutor::setRingBuffer(SimpleRingBuffer *ringBuffer,
|
||||
DynamicFIFO<uint16_t>* sizesFifo) {
|
||||
this->ringBuffer = ringBuffer;
|
||||
this->sizesFifo = sizesFifo;
|
||||
}
|
||||
|
||||
ReturnValue_t CommandExecutor::check(bool& bytesRead) {
|
||||
if(blocking) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
switch(state) {
|
||||
case(States::IDLE):
|
||||
case(States::COMMAND_LOADED): {
|
||||
return NO_COMMAND_LOADED_OR_PENDING;
|
||||
}
|
||||
case(States::PENDING): {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int result = poll(&waiter, 1, 0);
|
||||
switch(result) {
|
||||
case(0): {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
break;
|
||||
}
|
||||
case(1): {
|
||||
if (waiter.revents & POLLIN) {
|
||||
ssize_t readBytes = read(currentFd, readVec.data(), readVec.size());
|
||||
if(readBytes == 0) {
|
||||
// Should not happen
|
||||
sif::warning << "CommandExecutor::check: "
|
||||
"No bytes read after poll event.." << std::endl;
|
||||
break;
|
||||
}
|
||||
else if(readBytes > 0) {
|
||||
bytesRead = true;
|
||||
if(printOutput) {
|
||||
// It is assumed the command output is line terminated
|
||||
sif::info << currentCmd << " | " << readVec.data();
|
||||
}
|
||||
if(ringBuffer != nullptr) {
|
||||
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(
|
||||
readVec.data()), readBytes);
|
||||
}
|
||||
if(sizesFifo != nullptr) {
|
||||
if(not sizesFifo->full()) {
|
||||
sizesFifo->insert(readBytes);
|
||||
}
|
||||
}
|
||||
return BYTES_READ;
|
||||
}
|
||||
else {
|
||||
// Should also not happen
|
||||
sif::warning << "CommandExecutor::check: Error " << errno << ": " <<
|
||||
strerror(errno) << std::endl;
|
||||
}
|
||||
}
|
||||
else if(waiter.revents & POLLERR) {
|
||||
sif::warning << "CommandExecuter::check: Poll error" << std::endl;
|
||||
return COMMAND_ERROR;
|
||||
}
|
||||
else if(waiter.revents & POLLHUP) {
|
||||
int result = pclose(currentCmdFile);
|
||||
if(result != 0) {
|
||||
lastError = result;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
state = States::IDLE;
|
||||
currentCmdFile = nullptr;
|
||||
currentFd = 0;
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void CommandExecutor::reset() {
|
||||
CommandExecutor::close();
|
||||
currentCmdFile = nullptr;
|
||||
currentFd = 0;
|
||||
state = States::IDLE;
|
||||
}
|
||||
|
||||
int CommandExecutor::getLastError() const {
|
||||
return this->lastError;
|
||||
}
|
||||
|
||||
CommandExecutor::States CommandExecutor::getCurrentState() const {
|
||||
return state;
|
||||
}
|
||||
|
||||
ReturnValue_t CommandExecutor::executeBlocking() {
|
||||
while(fgets(readVec.data(), readVec.size(), currentCmdFile) != nullptr) {
|
||||
std::string output(readVec.data());
|
||||
if(printOutput) {
|
||||
sif::info << currentCmd << " | " << output;
|
||||
}
|
||||
if(ringBuffer != nullptr) {
|
||||
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(output.data()), output.size());
|
||||
}
|
||||
if(sizesFifo != nullptr) {
|
||||
if(not sizesFifo->full()) {
|
||||
sizesFifo->insert(output.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
int result = pclose(currentCmdFile);
|
||||
if(result != 0) {
|
||||
lastError = result;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
134
src/fsfw/osal/linux/CommandExecutor.h
Normal file
134
src/fsfw/osal/linux/CommandExecutor.h
Normal file
@ -0,0 +1,134 @@
|
||||
#ifndef FSFW_SRC_FSFW_OSAL_LINUX_COMMANDEXECUTOR_H_
|
||||
#define FSFW_SRC_FSFW_OSAL_LINUX_COMMANDEXECUTOR_H_
|
||||
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/returnvalues/FwClassIds.h"
|
||||
|
||||
#include <poll.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class SimpleRingBuffer;
|
||||
template <typename T> class DynamicFIFO;
|
||||
|
||||
/**
|
||||
* @brief Helper class to execute shell commands in blocking and non-blocking mode
|
||||
* @details
|
||||
* This class is able to execute processes by using the Linux popen call. It also has the
|
||||
* capability of writing the read output of a process into a provided ring buffer.
|
||||
*
|
||||
* The executor works by first loading the command which should be executed and specifying
|
||||
* whether it should be executed blocking or non-blocking. After that, execution can be started
|
||||
* with the execute command. In blocking mode, the execute command will block until the command
|
||||
* has finished
|
||||
*/
|
||||
class CommandExecutor {
|
||||
public:
|
||||
enum class States {
|
||||
IDLE,
|
||||
COMMAND_LOADED,
|
||||
PENDING
|
||||
};
|
||||
|
||||
static constexpr uint8_t CLASS_ID = CLASS_ID::LINUX_OSAL;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Execution of the current command has finished
|
||||
static constexpr ReturnValue_t EXECUTION_FINISHED =
|
||||
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0);
|
||||
|
||||
//! [EXPORT] : [COMMENT] Command is pending. This will also be returned if the user tries
|
||||
//! to load another command but a command is still pending
|
||||
static constexpr ReturnValue_t COMMAND_PENDING =
|
||||
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1);
|
||||
//! [EXPORT] : [COMMENT] Some bytes have been read from the executing process
|
||||
static constexpr ReturnValue_t BYTES_READ =
|
||||
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2);
|
||||
//! [EXPORT] : [COMMENT] Command execution failed
|
||||
static constexpr ReturnValue_t COMMAND_ERROR =
|
||||
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3);
|
||||
//! [EXPORT] : [COMMENT]
|
||||
static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING =
|
||||
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4);
|
||||
static constexpr ReturnValue_t PCLOSE_CALL_ERROR =
|
||||
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 6);
|
||||
|
||||
/**
|
||||
* Constructor. Is initialized with maximum size of internal buffer to read data from the
|
||||
* executed process.
|
||||
* @param maxSize
|
||||
*/
|
||||
CommandExecutor(const size_t maxSize);
|
||||
|
||||
/**
|
||||
* Load a new command which should be executed
|
||||
* @param command
|
||||
* @param blocking
|
||||
* @param printOutput
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t load(std::string command, bool blocking, bool printOutput = true);
|
||||
/**
|
||||
* Execute the loaded command.
|
||||
* @return
|
||||
* - In blocking mode, it will return RETURN_FAILED if
|
||||
* the result of the system call was not 0. The error value can be accessed using
|
||||
* getLastError
|
||||
* - In non-blocking mode, this call will start
|
||||
* the execution and then return RETURN_OK
|
||||
*/
|
||||
ReturnValue_t execute();
|
||||
/**
|
||||
* Only used in non-blocking mode. Checks the currently running command.
|
||||
* @param bytesRead Will be set to the number of bytes read, if bytes have been read
|
||||
* @return
|
||||
* - BYTES_READ if bytes have been read from the executing process. It is recommended to call
|
||||
* check again after this
|
||||
* - RETURN_OK execution is pending, but no bytes have been read from the executing process
|
||||
* - RETURN_FAILED if execution has failed, error value can be accessed using getLastError
|
||||
* - EXECUTION_FINISHED if the process was executed successfully
|
||||
* - COMMAND_ERROR internal poll error
|
||||
*/
|
||||
ReturnValue_t check(bool& bytesRead);
|
||||
/**
|
||||
* Abort the current command. Should normally not be necessary, check can be used to find
|
||||
* out whether command execution was successful
|
||||
* @return RETURN_OK
|
||||
*/
|
||||
ReturnValue_t close();
|
||||
|
||||
States getCurrentState() const;
|
||||
int getLastError() const;
|
||||
void printLastError(std::string funcName) const;
|
||||
|
||||
/**
|
||||
* Assign a ring buffer and a FIFO which will be filled by the executor with the output
|
||||
* read from the started process
|
||||
* @param ringBuffer
|
||||
* @param sizesFifo
|
||||
*/
|
||||
void setRingBuffer(SimpleRingBuffer* ringBuffer, DynamicFIFO<uint16_t>* sizesFifo);
|
||||
|
||||
/**
|
||||
* Reset the executor. This calls close internally and then reset the state machine so new
|
||||
* commands can be loaded and executed
|
||||
*/
|
||||
void reset();
|
||||
private:
|
||||
std::string currentCmd;
|
||||
bool blocking = true;
|
||||
FILE* currentCmdFile = nullptr;
|
||||
int currentFd = 0;
|
||||
bool printOutput = true;
|
||||
std::vector<char> readVec;
|
||||
struct pollfd waiter {};
|
||||
SimpleRingBuffer* ringBuffer = nullptr;
|
||||
DynamicFIFO<uint16_t>* sizesFifo = nullptr;
|
||||
|
||||
States state = States::IDLE;
|
||||
int lastError = 0;
|
||||
|
||||
ReturnValue_t executeBlocking();
|
||||
};
|
||||
|
||||
#endif /* FSFW_SRC_FSFW_OSAL_LINUX_COMMANDEXECUTOR_H_ */
|
@ -27,6 +27,7 @@ int Timer::setTimer(uint32_t intervalMs) {
|
||||
timer.it_value.tv_nsec = (intervalMs * 1000000) % (1000000000);
|
||||
timer.it_interval.tv_sec = 0;
|
||||
timer.it_interval.tv_nsec = 0;
|
||||
set = true;
|
||||
return timer_settime(timerId, 0, &timer, NULL);
|
||||
}
|
||||
|
||||
@ -43,3 +44,14 @@ int Timer::getTimer(uint32_t* remainingTimeMs){
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Timer::isSet() const {
|
||||
return this->set;
|
||||
}
|
||||
|
||||
void Timer::resetTimer() {
|
||||
if(not this->set) {
|
||||
set = false;
|
||||
}
|
||||
setTimer(0);
|
||||
}
|
||||
|
@ -38,7 +38,11 @@ public:
|
||||
*/
|
||||
int getTimer(uint32_t* remainingTimeMs);
|
||||
|
||||
bool isSet() const;
|
||||
void resetTimer();
|
||||
|
||||
private:
|
||||
bool set = true;
|
||||
timer_t timerId;
|
||||
};
|
||||
|
||||
|
@ -33,8 +33,8 @@ ReturnValue_t Service8FunctionManagement::getMessageQueueAndObject(
|
||||
if(tcDataLen < sizeof(object_id_t)) {
|
||||
return CommandingServiceBase::INVALID_TC;
|
||||
}
|
||||
SerializeAdapter::deSerialize(objectId, &tcData,
|
||||
&tcDataLen, SerializeIF::Endianness::BIG);
|
||||
// Can't fail, size was checked before
|
||||
SerializeAdapter::deSerialize(objectId, &tcData, &tcDataLen, SerializeIF::Endianness::BIG);
|
||||
|
||||
return checkInterfaceAndAcquireMessageQueue(id,objectId);
|
||||
}
|
||||
|
@ -13,10 +13,10 @@
|
||||
|
||||
/**
|
||||
* @brief FailureReport class to serialize a failure report
|
||||
* @brief Subservice 1, 3, 5, 7
|
||||
* @brief Subservice 2, 4, 6, 8
|
||||
* @ingroup spacepackets
|
||||
*/
|
||||
class FailureReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5, 7
|
||||
class FailureReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6, 8
|
||||
public:
|
||||
FailureReport(uint8_t failureSubtype_, uint16_t packetId_,
|
||||
uint16_t packetSequenceControl_, uint8_t stepNumber_,
|
||||
@ -108,10 +108,10 @@ private:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Subservices 2, 4, 6, 8
|
||||
* @brief Subservices 1, 3, 5, 7
|
||||
* @ingroup spacepackets
|
||||
*/
|
||||
class SuccessReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6, 8
|
||||
class SuccessReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5, 7
|
||||
public:
|
||||
SuccessReport(uint8_t subtype_, uint16_t packetId_,
|
||||
uint16_t packetSequenceControl_,uint8_t stepNumber_) :
|
||||
|
@ -72,6 +72,7 @@ enum: uint8_t {
|
||||
PUS_SERVICE_3, //PUS3
|
||||
PUS_SERVICE_9, //PUS9
|
||||
FILE_SYSTEM, //FILS
|
||||
LINUX_OSAL, //UXOS
|
||||
HAL_SPI, //HSPI
|
||||
HAL_UART, //HURT
|
||||
HAL_I2C, //HI2C
|
||||
|
@ -22,9 +22,9 @@ public:
|
||||
* @param number
|
||||
* @return
|
||||
*/
|
||||
static constexpr ReturnValue_t makeReturnCode(uint8_t interfaceId,
|
||||
static constexpr ReturnValue_t makeReturnCode(uint8_t classId,
|
||||
uint8_t number) {
|
||||
return (static_cast<ReturnValue_t>(interfaceId) << 8) + number;
|
||||
return (static_cast<ReturnValue_t>(classId) << 8) + number;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
#ifndef FRAMEWORK_TASKS_TYPEDEF_H_
|
||||
#define FRAMEWORK_TASKS_TYPEDEF_H_
|
||||
#ifndef FSFW_TASKS_TYPEDEF_H_
|
||||
#define FSFW_TASKS_TYPEDEF_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
typedef const char* TaskName;
|
||||
typedef uint32_t TaskPriority;
|
||||
@ -7,4 +10,4 @@ typedef size_t TaskStackSize;
|
||||
typedef double TaskPeriod;
|
||||
typedef void (*TaskDeadlineMissedFunction)();
|
||||
|
||||
#endif /* FRAMEWORK_TASKS_TYPEDEF_H_ */
|
||||
#endif /* FSFW_TASKS_TYPEDEF_H_ */
|
||||
|
@ -54,6 +54,11 @@ void SpacePacketBase::setAPID( uint16_t new_apid ) {
|
||||
this->data->header.packet_id_l = ( new_apid & 0x00FF );
|
||||
}
|
||||
|
||||
void SpacePacketBase::setSequenceFlags( uint8_t sequenceflags ) {
|
||||
this->data->header.sequence_control_h &= 0x3F;
|
||||
this->data->header.sequence_control_h |= sequenceflags << 6;
|
||||
}
|
||||
|
||||
uint16_t SpacePacketBase::getPacketSequenceControl( void ) {
|
||||
return ( (this->data->header.sequence_control_h) << 8 )
|
||||
+ this->data->header.sequence_control_l;
|
||||
|
@ -109,6 +109,13 @@ public:
|
||||
* ignored.
|
||||
*/
|
||||
void setAPID( uint16_t setAPID );
|
||||
|
||||
/**
|
||||
* Sets the sequence flags of a packet, which are bit 17 and 18 in the space packet header.
|
||||
* @param The sequence flags to set
|
||||
*/
|
||||
void setSequenceFlags( uint8_t sequenceflags );
|
||||
|
||||
/**
|
||||
* Returns the CCSDS packet sequence control field, which are the third and
|
||||
* the fourth byte of the CCSDS primary header.
|
||||
|
@ -19,7 +19,7 @@ class TmTcBridge : public AcceptsTelemetryIF,
|
||||
public:
|
||||
static constexpr uint8_t TMTC_RECEPTION_QUEUE_DEPTH = 20;
|
||||
static constexpr uint8_t LIMIT_STORED_DATA_SENT_PER_CYCLE = 15;
|
||||
static constexpr uint8_t LIMIT_DOWNLINK_PACKETS_STORED = 20;
|
||||
static constexpr uint8_t LIMIT_DOWNLINK_PACKETS_STORED = 200;
|
||||
|
||||
static constexpr uint8_t DEFAULT_STORED_DATA_SENT_PER_CYCLE = 5;
|
||||
static constexpr uint8_t DEFAULT_DOWNLINK_PACKETS_STORED = 10;
|
||||
|
Reference in New Issue
Block a user