format
fsfw/fsfw/pipeline/head This commit looks good Details

This commit is contained in:
Ulrich Mohr 2023-01-26 13:40:44 +01:00
parent 941bf61f28
commit e37af4fe70
32 changed files with 94 additions and 104 deletions

View File

@ -1,8 +1,8 @@
#ifndef FSFW_MEMORY_HASFILESYSTEMIF_H_
#define FSFW_MEMORY_HASFILESYSTEMIF_H_
#include <filesystem>
#include <cstddef>
#include <filesystem>
#include "FileSystemArgsIF.h"
#include "fsfw/ipc/MessageQueueIF.h"

View File

@ -58,7 +58,7 @@ class Type : public SerializeIF {
template <typename T>
struct PodTypeConversion {
static_assert(! std::is_same<T, bool>::value,
static_assert(!std::is_same<T, bool>::value,
"Do not use boolean for the PoolEntry type, use uint8_t "
"instead! The ECSS standard defines a boolean as a one bit "
"field. Therefore it is preferred to store a boolean as an "

View File

@ -84,9 +84,9 @@ void arrayprinter::printDec(const uint8_t *data, size_t size, size_t maxCharPerL
#else
// General format: 32,243,-12 so it is number of chars times 4
// plus line break plus small safety margin.
for (size_t i = 0; i < size; i++) {
//TODO
// TODO
}
#endif
}

View File

@ -24,8 +24,8 @@
#else
#ifdef WIN32
#include <winsock2.h>
#include <windows.h>
#include <winsock2.h>
#if REG_DWORD == REG_DWORD_LITTLE_ENDIAN
#define BYTE_ORDER_SYSTEM LITTLE_ENDIAN
#else

View File

@ -40,6 +40,3 @@ timeval Clock::getUptime() {
// timeval uptime = getUptime();
// return uptime.tv_sec;
// }

View File

@ -78,4 +78,3 @@ timeval Clock::getUptime() {
#endif
return timeval;
}

View File

@ -10,7 +10,6 @@
#if defined(PLATFORM_WIN)
#include "fsfw/osal/windows/winTaskHelpers.h"
#elif defined(PLATFORM_UNIX)
#include <pthread.h>

View File

@ -3,8 +3,8 @@
#include <fsfw/returnvalues/returnvalue.h>
#include <thread>
#include <string>
#include <thread>
namespace tasks {

View File

@ -34,7 +34,7 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) {
}
timeval Clock::getUptime() {
timeval uptime{0,0};
timeval uptime{0, 0};
double uptimeSeconds;
if (std::ifstream("/proc/uptime", std::ios::in) >> uptimeSeconds) {
uptime.tv_sec = uptimeSeconds;

View File

@ -2,7 +2,7 @@
#include <rtems/rtems/sem.h>
//TODO
// TODO
BinarySemaphore::BinarySemaphore() {}

View File

@ -6,7 +6,6 @@
#include "fsfw/ipc/MutexGuard.h"
#include "fsfw/osal/rtems/RtemsBasic.h"
ReturnValue_t Clock::setClock(const timeval* time) {
TimeOfDay_t time_tod;
ReturnValue_t result = convertTimevalToTimeOfDay(time, &time_tod);
@ -20,7 +19,8 @@ ReturnValue_t Clock::setClock(const timeval* time) {
timeRtems.hour = time_tod.hour;
timeRtems.minute = time_tod.minute;
timeRtems.second = time_tod.second;
timeRtems.ticks = static_cast<uint64_t>(time_tod.usecond) * rtems_clock_get_ticks_per_second() / 1e6;
timeRtems.ticks =
static_cast<uint64_t>(time_tod.usecond) * rtems_clock_get_ticks_per_second() / 1e6;
rtems_status_code status = rtems_clock_set(&timeRtems);
switch (status) {
case RTEMS_SUCCESSFUL:

View File

@ -35,19 +35,19 @@ ReturnValue_t InternalErrorCodes::translate(uint8_t code) {
return OUT_OF_PROXIES;
case INTERNAL_ERROR_INVALID_GLOBAL_ID:
return INVALID_GLOBAL_ID;
//TODO this one is not there anymore in rtems-6 (5 as well?)
//case INTERNAL_ERROR_BAD_STACK_HOOK:
// return BAD_STACK_HOOK;
// case INTERNAL_ERROR_BAD_ATTRIBUTES:
// return BAD_ATTRIBUTES;
// case INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY:
// return IMPLEMENTATION_KEY_CREATE_INCONSISTENCY;
// case INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL:
// return IMPLEMENTATION_BLOCKING_OPERATION_CANCEL;
// case INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE:
// return MUTEX_OBTAIN_FROM_BAD_STATE;
// case INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0:
// return UNLIMITED_AND_MAXIMUM_IS_0;
// TODO this one is not there anymore in rtems-6 (5 as well?)
// case INTERNAL_ERROR_BAD_STACK_HOOK:
// return BAD_STACK_HOOK;
// case INTERNAL_ERROR_BAD_ATTRIBUTES:
// return BAD_ATTRIBUTES;
// case INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY:
// return IMPLEMENTATION_KEY_CREATE_INCONSISTENCY;
// case INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL:
// return IMPLEMENTATION_BLOCKING_OPERATION_CANCEL;
// case INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE:
// return MUTEX_OBTAIN_FROM_BAD_STATE;
// case INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0:
// return UNLIMITED_AND_MAXIMUM_IS_0;
default:
return returnvalue::FAILED;
}

View File

@ -1,5 +1,5 @@
#include "fsfw/osal/rtems/BinarySemaphore.h"
//#include "fsfw/osal/rtems/CountingSemaphore.h"
// #include "fsfw/osal/rtems/CountingSemaphore.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tasks/SemaphoreFactory.h"
@ -19,8 +19,8 @@ SemaphoreFactory* SemaphoreFactory::instance() {
SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t argument) {
return nullptr;
//TODO
//return new BinarySemaphore();
// TODO
// return new BinarySemaphore();
}
SemaphoreIF* SemaphoreFactory::createCountingSemaphore(uint8_t maxCount, uint8_t initCount,

View File

@ -5,8 +5,8 @@
#ifdef _WIN32
#include <windows.h>
#include <processthreadsapi.h>
#include <windows.h>
namespace tasks {

View File

@ -10,11 +10,11 @@
//////////////////////////////////////////////////////////////////////////////////
// RMAP command bits
//#define RMAP_COMMAND_BIT_INCREMENT 2
//#define RMAP_COMMAND_BIT_REPLY 3
//#define RMAP_COMMAND_BIT_WRITE 5
//#define RMAP_COMMAND_BIT_VERIFY 4
//#define RMAP_COMMAND_BIT 6
// #define RMAP_COMMAND_BIT_INCREMENT 2
// #define RMAP_COMMAND_BIT_REPLY 3
// #define RMAP_COMMAND_BIT_WRITE 5
// #define RMAP_COMMAND_BIT_VERIFY 4
// #define RMAP_COMMAND_BIT 6
namespace RMAPIds {
@ -32,14 +32,14 @@ static const uint8_t RMAP_COMMAND_READ = ((1 << RMAP_COMMAND_BIT) | (1 << RMAP_C
static const uint8_t RMAP_REPLY_WRITE =
((1 << RMAP_COMMAND_BIT_WRITE) | (1 << RMAP_COMMAND_BIT_REPLY));
static const uint8_t RMAP_REPLY_READ = ((1 << RMAP_COMMAND_BIT_REPLY));
//#define RMAP_COMMAND_WRITE ((1<<RMAP_COMMAND_BIT) | (1<<RMAP_COMMAND_BIT_WRITE)
// #define RMAP_COMMAND_WRITE ((1<<RMAP_COMMAND_BIT) | (1<<RMAP_COMMAND_BIT_WRITE)
//| (1<<RMAP_COMMAND_BIT_REPLY)) #define RMAP_COMMAND_WRITE_VERIFY ((1<<RMAP_COMMAND_BIT) |
//(1<<RMAP_COMMAND_BIT_WRITE) | (1<<RMAP_COMMAND_BIT_REPLY) | (1<<RMAP_COMMAND_BIT_VERIFY)) #define
// RMAP_COMMAND_READ ((1<<RMAP_COMMAND_BIT) | (1<<RMAP_COMMAND_BIT_REPLY))
// RMAP_COMMAND_READ ((1<<RMAP_COMMAND_BIT) | (1<<RMAP_COMMAND_BIT_REPLY))
//#define RMAP_REPLY_WRITE ((1<<RMAP_COMMAND_BIT_WRITE) |
// #define RMAP_REPLY_WRITE ((1<<RMAP_COMMAND_BIT_WRITE) |
//(1<<RMAP_COMMAND_BIT_REPLY))
//#define RMAP_REPLY_WRITE_VERIFY ((1<<RMAP_COMMAND_BIT_WRITE) |
// #define RMAP_REPLY_WRITE_VERIFY ((1<<RMAP_COMMAND_BIT_WRITE) |
//(1<<RMAP_COMMAND_BIT_REPLY) | (1<<RMAP_COMMAND_BIT_VERIFY)) #define RMAP_REPLY_READ
//((1<<RMAP_COMMAND_BIT_REPLY))
@ -49,9 +49,9 @@ static const uint8_t RMAP_COMMAND_HEADER_LEN = 16;
static const uint8_t RMAP_WRITE_REPLY_HEADER_LEN = 8;
static const uint8_t RMAP_READ_REPLY_HEADER_LEN = 12;
static const uint8_t RMAP_DATA_FOOTER_SIZE = 1; // SIZE OF CRC
//#define RMAP_COMMAND_HEADER_LEN 16
//#define RMAP_WRITE_REPLY_HEADER_LEN 8
//#define RMAP_READ_REPLY_HEADER_LEN 12
// #define RMAP_COMMAND_HEADER_LEN 16
// #define RMAP_WRITE_REPLY_HEADER_LEN 8
// #define RMAP_READ_REPLY_HEADER_LEN 12
} // namespace RMAPIds

View File

@ -14,10 +14,9 @@
#include <ctime>
#endif
class Clock {
public:
// https://xkcd.com/927/
// https://xkcd.com/927/
typedef struct {
uint32_t year; //!< Year, A.D.
uint32_t month; //!< Month, 1 .. 12.

View File

@ -1,5 +1,5 @@
#include <ctime>
#include <cstdlib>
#include <ctime>
#include "fsfw/ipc/MutexGuard.h"
#include "fsfw/timemanager/Clock.h"
@ -110,7 +110,7 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval*
to->tv_sec = seconds;
to->tv_usec = from->usecond;
if (seconds == (time_t) -1) {
if (seconds == (time_t)-1) {
return returnvalue::FAILED;
}

View File

@ -38,6 +38,4 @@ uint32_t Countdown::getRemainingMillis() const {
}
}
uint32_t Countdown::getCurrentTime() const {
return Clock::getUptime_ms();
}
uint32_t Countdown::getCurrentTime() const { return Clock::getUptime_ms(); }

View File

@ -1,17 +1,17 @@
#ifndef FSFW_TIMEMANAGER_TIMEREADERIF_H
#define FSFW_TIMEMANAGER_TIMEREADERIF_H
#include <cstdio>
#include <cstdlib>
#include <sys/time.h>
#include <cstdio>
#include <cstdlib>
#include "fsfw/platform.h"
#ifdef PLATFORM_WIN
// wtf? Required for timeval!
#include <winsock2.h>
#include <winsock.h>
#include <winsock2.h>
#endif
#include "TimeStampIF.h"

View File

@ -15,7 +15,8 @@ class HostFilesystem : public HasFileSystemIF {
ReturnValue_t readFromFile(FileOpParams fileOpInfo, uint8_t **buffer, size_t &readSize,
size_t maxSize) override;
ReturnValue_t createFile(FilesystemParams params, const uint8_t *data, size_t size) override;
ReturnValue_t removeFile(const std::filesystem::path::value_type *path, FileSystemArgsIF *args) override;
ReturnValue_t removeFile(const std::filesystem::path::value_type *path,
FileSystemArgsIF *args) override;
ReturnValue_t createDirectory(FilesystemParams params, bool createParentDirs) override;
ReturnValue_t removeDirectory(FilesystemParams params, bool deleteRecurively) override;
ReturnValue_t rename(const std::filesystem::path::value_type *oldPath,

View File

@ -20,9 +20,9 @@ add_subdirectory(globalfunctions)
add_subdirectory(timemanager)
add_subdirectory(tmtcpacket)
add_subdirectory(cfdp)
IF(NOT FSFW_OSAL MATCHES "rtems")
add_subdirectory(hal)
ENDIF()
if(NOT FSFW_OSAL MATCHES "rtems")
add_subdirectory(hal)
endif()
add_subdirectory(internalerror)
add_subdirectory(devicehandler)
add_subdirectory(tmtcservices)

View File

@ -51,31 +51,29 @@ extern "C" {
void exit_qemu_failing(int error) {
asm(/* 0x20026 == ADP_Stopped_ApplicationExit */
"mov x1, #0x26\n\t"
"movk x1, #2, lsl #16\n\t"
"str x1, [sp,#0]\n\t");
"mov x1, #0x26\n\t"
"movk x1, #2, lsl #16\n\t"
"str x1, [sp,#0]\n\t");
/* Exit status code. Host QEMU process exits with that status. */
asm("mov x0, %[error]\n\t" : : [error] "r" (error));
asm(
"str x0, [sp,#8]\n\t"
/* Exit status code. Host QEMU process exits with that status. */
asm("mov x0, %[error]\n\t" : : [error] "r"(error));
asm("str x0, [sp,#8]\n\t"
/* x1 contains the address of parameter block.
* Any memory address could be used. */
"mov x1, sp\n\t"
/* x1 contains the address of parameter block.
* Any memory address could be used. */
"mov x1, sp\n\t"
/* SYS_EXIT */
"mov w0, #0x18\n\t"
/* SYS_EXIT */
"mov w0, #0x18\n\t"
/* Do the semihosting call on A64. */
"hlt 0xf000\n\t"
);
/* Do the semihosting call on A64. */
"hlt 0xf000\n\t");
}
#include <rtemsConfig.h>
void user_handle_fatal(Internal_errors_Source source, bool internal, Internal_errors_t error_code){
if ( source == RTEMS_FATAL_SOURCE_EXIT ) {
void user_handle_fatal(Internal_errors_Source source, bool internal, Internal_errors_t error_code) {
if (source == RTEMS_FATAL_SOURCE_EXIT) {
if (error_code != 0) {
printk("*** EXIT STATUS NOT ZERO ***\n");
printk("Quitting qemu with exit code %i\n", error_code);

View File

@ -30,7 +30,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
CHECK(localSet.getSid() == lpool::testSid);
CHECK(localSet.getCreatorObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE);
size_t maxSize = localSet.getLocalPoolIdsSerializedSize(true);
uint8_t localPoolIdBuff[ 3 * sizeof(lp_id_t) + sizeof(uint8_t)];
uint8_t localPoolIdBuff[3 * sizeof(lp_id_t) + sizeof(uint8_t)];
/* Skip size field */
auto* lpIds = reinterpret_cast<lp_id_t*>(localPoolIdBuff + 1);
size_t serSize = 0;
@ -108,7 +108,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
CHECK(maxSize == sizeof(uint8_t) + sizeof(float) + sizeof(uint16_t) * 3);
serSize = 0;
/* Already reserve additional space for validity buffer, will be needed later */
std::vector<uint8_t> buffer(maxSize+1);
std::vector<uint8_t> buffer(maxSize + 1);
uint8_t* buffPtr = buffer.data();
CHECK(localSet.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) ==
returnvalue::OK);
@ -157,8 +157,8 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
CHECK(maxSize == sizeof(uint8_t) + sizeof(uint16_t) * 3 + sizeof(float) + 1);
serSize = 0;
buffPtr = buffer.data();
CHECK(localSet.serialize(&buffPtr, &serSize, buffer.size(), SerializeIF::Endianness::MACHINE) ==
returnvalue::OK);
CHECK(localSet.serialize(&buffPtr, &serSize, buffer.size(),
SerializeIF::Endianness::MACHINE) == returnvalue::OK);
CHECK(rawUint8 == 232);
std::memcpy(&rawFloat, buffer.data() + sizeof(uint8_t), sizeof(float));
CHECK(rawFloat == Catch::Approx(-2324.322));
@ -203,12 +203,12 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
}
/* Common fault test cases */
//LocalPoolObjectBase* variableHandle = poolOwner.getPoolObjectHandle(lpool::uint32VarId);
//CHECK(variableHandle != nullptr);
//CHECK(localSet.registerVariable(variableHandle) == static_cast<int>(DataSetIF::DATA_SET_FULL));
//variableHandle = nullptr;
//REQUIRE(localSet.registerVariable(variableHandle) ==
// static_cast<int>(DataSetIF::POOL_VAR_NULL));
// LocalPoolObjectBase* variableHandle = poolOwner.getPoolObjectHandle(lpool::uint32VarId);
// CHECK(variableHandle != nullptr);
// CHECK(localSet.registerVariable(variableHandle) ==
// static_cast<int>(DataSetIF::DATA_SET_FULL)); variableHandle = nullptr;
// REQUIRE(localSet.registerVariable(variableHandle) ==
// static_cast<int>(DataSetIF::POOL_VAR_NULL));
}
SECTION("MorePoolVariables") {

View File

@ -419,7 +419,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
CHECK(poolOwner.changedVariableCallbackWasCalled(gpidToCheck, storeId) == true);
CHECK(gpidToCheck == lpool::uint8VarGpid);
//poolOwner.poolManager.printPoolEntry(lpool::uint8VarId);
// poolOwner.poolManager.printPoolEntry(lpool::uint8VarId);
}
/* we need to reset the subscription list because the pool owner

View File

@ -1,10 +1,10 @@
#include <etl/crc32.h>
#include <array>
#include <catch2/catch_test_macros.hpp>
#include <filesystem>
#include <fstream>
#include <random>
#include <array>
#include "fsfw/serialize/SerializeIF.h"
#include "fsfw_hal/host/HostFilesystem.h"

View File

@ -5,9 +5,9 @@
#include "fsfw/serialize/SerializeIF.h"
ReturnValue_t FilesystemMock::feedFile(const std::string &filename, std::ifstream &file) {
//not multibyte encoding safe!
std::basic_string<std::filesystem::path::value_type> native_filename(filename.begin(), filename.end());
// not multibyte encoding safe!
std::basic_string<std::filesystem::path::value_type> native_filename(filename.begin(),
filename.end());
if (not std::filesystem::exists(native_filename)) {
return returnvalue::FAILED;

View File

@ -20,8 +20,9 @@
class FilesystemMock : public HasFileSystemIF {
public:
struct FileWriteInfo {
FileWriteInfo(std::basic_string<std::filesystem::path::value_type> filename, size_t offset, const uint8_t *data, size_t len)
: offset(offset) {
FileWriteInfo(std::basic_string<std::filesystem::path::value_type> filename, size_t offset,
const uint8_t *data, size_t len)
: offset(offset) {
this->filename = filename;
this->data.insert(this->data.end(), data, data + len);
}
@ -47,8 +48,8 @@ class FilesystemMock : public HasFileSystemIF {
std::map<std::basic_string<std::filesystem::path::value_type>, DirInfo> dirMap;
struct RenameInfo {
RenameInfo(std::basic_string < std::filesystem::path::value_type> oldName,
std::basic_string < std::filesystem::path::value_type> newName)
RenameInfo(std::basic_string<std::filesystem::path::value_type> oldName,
std::basic_string<std::filesystem::path::value_type> newName)
: oldName(std::move(oldName)), newName(std::move(newName)) {}
std::basic_string<std::filesystem::path::value_type> oldName;
@ -56,8 +57,7 @@ class FilesystemMock : public HasFileSystemIF {
};
std::queue<RenameInfo> renameQueue;
std::basic_string<std::filesystem::path::value_type> truncateCalledOnFile;
ReturnValue_t feedFile(const std::string &filename,
std::ifstream &file);
ReturnValue_t feedFile(const std::string &filename, std::ifstream &file);
bool fileExists(FilesystemParams params) override;
ReturnValue_t truncateFile(FilesystemParams params) override;

View File

@ -1,5 +1,5 @@
target_sources(${FSFW_TEST_TGT} PRIVATE testMq.cpp TestClock.cpp)
if(FSFW_OSAL MATCHES "linux" OR FSFW_OSAL MATCHES "freertos")
target_sources(${FSFW_TEST_TGT} PRIVATE TestSemaphore.cpp)
target_sources(${FSFW_TEST_TGT} PRIVATE TestSemaphore.cpp)
endif()

View File

@ -8,7 +8,7 @@
#include "CatchDefinitions.h"
//TODO setClock()
// TODO setClock()
TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") {
SECTION("Test getClock") {

View File

@ -4,7 +4,6 @@
#include <catch2/catch_test_macros.hpp>
TEST_CASE("Binary Semaphore Test", "[BinSemaphore]") {
// perform set-up here
SemaphoreIF* binSemaph = SemaphoreFactory::instance()->createBinarySemaphore();

View File

@ -63,7 +63,7 @@
#define configMAX_API_CALL_INTERRUPT_PRIORITY [dependent on processor and application]
/* Define to trap errors during development. */
//#define configASSERT( ( x ) ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
// #define configASSERT( ( x ) ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
/* FreeRTOS MPU specific definitions. */
#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0

View File

@ -1,9 +1,8 @@
#pragma once
#include <rtems/extension.h>
#include <rtems/bspIo.h>
void user_handle_fatal(Internal_errors_Source source, bool internal, Internal_errors_t error_code);
#include <rtems/extension.h>
void user_handle_fatal(Internal_errors_Source source, bool internal, Internal_errors_t error_code);
#define RTEMS_USE_UNLIMITED_OBJECTS_ALLOCATION 0
@ -24,7 +23,8 @@ void user_handle_fatal(Internal_errors_Source source, bool internal, Internal_e
//! Around 41 kB extra task stack for now.
#define CONFIGURE_EXTRA_TASK_STACKS (10 * RTEMS_MINIMUM_STACK_SIZE)
#define CONFIGURE_INITIAL_EXTENSIONS { NULL, NULL, NULL, NULL, NULL, NULL, NULL, user_handle_fatal, NULL }
#define CONFIGURE_INITIAL_EXTENSIONS \
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, user_handle_fatal, NULL }
#define CONFIGURE_INIT