Merge branch 'development' into mueller/gpio-update
This commit is contained in:
commit
ea3812fbbd
@ -15,11 +15,6 @@
|
|||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstring>
|
#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):
|
SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF):
|
||||||
SystemObject(objectId), gpioComIF(gpioComIF) {
|
SystemObject(objectId), gpioComIF(gpioComIF) {
|
||||||
if(gpioComIF == nullptr) {
|
if(gpioComIF == nullptr) {
|
||||||
@ -193,7 +188,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie *spiCookie, const
|
|||||||
spiCookie->getSpiParameters(spiMode, spiSpeed, nullptr);
|
spiCookie->getSpiParameters(spiMode, spiSpeed, nullptr);
|
||||||
setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
|
setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
|
||||||
spiCookie->assignWriteBuffer(sendData);
|
spiCookie->assignWriteBuffer(sendData);
|
||||||
spiCookie->assignTransferSize(sendLen);
|
spiCookie->setTransferSize(sendLen);
|
||||||
|
|
||||||
bool fullDuplex = spiCookie->isFullDuplex();
|
bool fullDuplex = spiCookie->isFullDuplex();
|
||||||
gpioId_t gpioId = spiCookie->getChipSelectPin();
|
gpioId_t gpioId = spiCookie->getChipSelectPin();
|
||||||
@ -335,6 +330,7 @@ ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
|||||||
|
|
||||||
*buffer = rxBuf;
|
*buffer = rxBuf;
|
||||||
*size = spiCookie->getCurrentTransferSize();
|
*size = spiCookie->getCurrentTransferSize();
|
||||||
|
spiCookie->setTransferSize(0);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef LINUX_SPI_SPICOMIF_H_
|
#ifndef LINUX_SPI_SPICOMIF_H_
|
||||||
#define LINUX_SPI_SPICOMIF_H_
|
#define LINUX_SPI_SPICOMIF_H_
|
||||||
|
|
||||||
|
#include "fsfw/FSFW.h"
|
||||||
#include "spiDefinitions.h"
|
#include "spiDefinitions.h"
|
||||||
#include "returnvalues/classIds.h"
|
#include "returnvalues/classIds.h"
|
||||||
#include "fsfw_hal/common/gpio/GpioIF.h"
|
#include "fsfw_hal/common/gpio/GpioIF.h"
|
||||||
|
@ -121,7 +121,7 @@ bool SpiCookie::isFullDuplex() const {
|
|||||||
return not this->halfDuplex;
|
return not this->halfDuplex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpiCookie::assignTransferSize(size_t transferSize) {
|
void SpiCookie::setTransferSize(size_t transferSize) {
|
||||||
spiTransferStruct.len = transferSize;
|
spiTransferStruct.len = transferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,10 +103,10 @@ public:
|
|||||||
void assignReadBuffer(uint8_t* rx);
|
void assignReadBuffer(uint8_t* rx);
|
||||||
void assignWriteBuffer(const uint8_t* tx);
|
void assignWriteBuffer(const uint8_t* tx);
|
||||||
/**
|
/**
|
||||||
* Assign size for the next transfer.
|
* Set size for the next transfer. Set to 0 for no transfer
|
||||||
* @param transferSize
|
* @param transferSize
|
||||||
*/
|
*/
|
||||||
void assignTransferSize(size_t transferSize);
|
void setTransferSize(size_t transferSize);
|
||||||
size_t getCurrentTransferSize() const;
|
size_t getCurrentTransferSize() const;
|
||||||
|
|
||||||
struct UncommonParameters {
|
struct UncommonParameters {
|
||||||
@ -158,8 +158,6 @@ private:
|
|||||||
std::string spiDev, const size_t maxSize, spi::SpiModes spiMode, uint32_t spiSpeed,
|
std::string spiDev, const size_t maxSize, spi::SpiModes spiMode, uint32_t spiSpeed,
|
||||||
spi::send_callback_function_t callback, void* args);
|
spi::send_callback_function_t callback, void* args);
|
||||||
|
|
||||||
size_t currentTransferSize = 0;
|
|
||||||
|
|
||||||
address_t spiAddress;
|
address_t spiAddress;
|
||||||
gpioId_t chipSelectPin;
|
gpioId_t chipSelectPin;
|
||||||
std::string spiDevice;
|
std::string spiDevice;
|
||||||
|
@ -1355,10 +1355,20 @@ void DeviceHandlerBase::buildInternalCommand(void) {
|
|||||||
DeviceCommandMap::iterator iter = deviceCommandMap.find(
|
DeviceCommandMap::iterator iter = deviceCommandMap.find(
|
||||||
deviceCommandId);
|
deviceCommandId);
|
||||||
if (iter == deviceCommandMap.end()) {
|
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;
|
result = COMMAND_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
else if (iter->second.isExecuting) {
|
else if (iter->second.isExecuting) {
|
||||||
#if FSFW_DISABLE_PRINTOUT == 0
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
char output[36];
|
char output[36];
|
||||||
sprintf(output, "Command 0x%08x is executing",
|
sprintf(output, "Command 0x%08x is executing",
|
||||||
static_cast<unsigned int>(deviceCommandId));
|
static_cast<unsigned int>(deviceCommandId));
|
||||||
@ -1569,7 +1579,7 @@ LocalDataPoolManager* DeviceHandlerBase::getHkManagerHandle() {
|
|||||||
return &poolManager;
|
return &poolManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueueId_t DeviceHandlerBase::getCommanderId(DeviceCommandId_t replyId) const {
|
MessageQueueId_t DeviceHandlerBase::getCommanderQueueId(DeviceCommandId_t replyId) const {
|
||||||
auto commandIter = deviceCommandMap.find(replyId);
|
auto commandIter = deviceCommandMap.find(replyId);
|
||||||
if(commandIter == deviceCommandMap.end()) {
|
if(commandIter == deviceCommandMap.end()) {
|
||||||
return MessageQueueIF::NO_QUEUE;
|
return MessageQueueIF::NO_QUEUE;
|
||||||
|
@ -6,22 +6,22 @@
|
|||||||
#include "DeviceHandlerFailureIsolation.h"
|
#include "DeviceHandlerFailureIsolation.h"
|
||||||
#include "DeviceHandlerThermalSet.h"
|
#include "DeviceHandlerThermalSet.h"
|
||||||
|
|
||||||
#include "../serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
#include "../serviceinterface/serviceInterfaceDefintions.h"
|
#include "fsfw/serviceinterface/serviceInterfaceDefintions.h"
|
||||||
#include "../objectmanager/SystemObject.h"
|
#include "fsfw/objectmanager/SystemObject.h"
|
||||||
#include "../tasks/ExecutableObjectIF.h"
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||||
#include "../action/HasActionsIF.h"
|
#include "fsfw/action/HasActionsIF.h"
|
||||||
#include "../datapool/PoolVariableIF.h"
|
#include "fsfw/datapool/PoolVariableIF.h"
|
||||||
#include "../modes/HasModesIF.h"
|
#include "fsfw/modes/HasModesIF.h"
|
||||||
#include "../power/PowerSwitchIF.h"
|
#include "fsfw/power/PowerSwitchIF.h"
|
||||||
#include "../ipc/MessageQueueIF.h"
|
#include "fsfw/ipc/MessageQueueIF.h"
|
||||||
#include "../tasks/PeriodicTaskIF.h"
|
#include "fsfw/tasks/PeriodicTaskIF.h"
|
||||||
#include "../action/ActionHelper.h"
|
#include "fsfw/action/ActionHelper.h"
|
||||||
#include "../health/HealthHelper.h"
|
#include "fsfw/health/HealthHelper.h"
|
||||||
#include "../parameters/ParameterHelper.h"
|
#include "fsfw/parameters/ParameterHelper.h"
|
||||||
#include "../datapoollocal/HasLocalDataPoolIF.h"
|
#include "fsfw/datapoollocal/HasLocalDataPoolIF.h"
|
||||||
#include "../datapoollocal/LocalDataPoolManager.h"
|
#include "fsfw/datapoollocal/LocalDataPoolManager.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ protected:
|
|||||||
*/
|
*/
|
||||||
virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
|
virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
|
||||||
const uint8_t *packet) = 0;
|
const uint8_t *packet) = 0;
|
||||||
MessageQueueId_t getCommanderId(DeviceCommandId_t replyId) const;
|
MessageQueueId_t getCommanderQueueId(DeviceCommandId_t replyId) const;
|
||||||
/**
|
/**
|
||||||
* Helper function to get pending command. This is useful for devices
|
* Helper function to get pending command. This is useful for devices
|
||||||
* like SPI sensors to identify the last sent command.
|
* like SPI sensors to identify the last sent command.
|
||||||
|
@ -16,15 +16,18 @@ InternalUnitTester::~InternalUnitTester() {}
|
|||||||
ReturnValue_t InternalUnitTester::performTests(
|
ReturnValue_t InternalUnitTester::performTests(
|
||||||
const struct InternalUnitTester::TestConfig& testConfig) {
|
const struct InternalUnitTester::TestConfig& testConfig) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << "Running internal unit tests.." << std::endl;
|
sif::info << "Running internal unit tests.. Error messages might follow" <<
|
||||||
|
std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printInfo("Running internal unit tests..\n");
|
sif::printInfo("Running internal unit tests..\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
testserialize::test_serialization();
|
testserialize::test_serialization();
|
||||||
testmq::testMq();
|
testmq::testMq();
|
||||||
|
if(testConfig.testSemaphores) {
|
||||||
testsemaph::testBinSemaph();
|
testsemaph::testBinSemaph();
|
||||||
testsemaph::testCountingSemaph();
|
testsemaph::testCountingSemaph();
|
||||||
|
}
|
||||||
testmutex::testMutex();
|
testmutex::testMutex();
|
||||||
if(testConfig.testArrayPrinter) {
|
if(testConfig.testArrayPrinter) {
|
||||||
arrayprinter::testArrayPrinter();
|
arrayprinter::testArrayPrinter();
|
||||||
|
@ -18,6 +18,7 @@ class InternalUnitTester: public HasReturnvaluesIF {
|
|||||||
public:
|
public:
|
||||||
struct TestConfig {
|
struct TestConfig {
|
||||||
bool testArrayPrinter = false;
|
bool testArrayPrinter = false;
|
||||||
|
bool testSemaphores = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
InternalUnitTester();
|
InternalUnitTester();
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#include "fsfw_tests/internal/osal/IntTestMutex.h"
|
#include "fsfw_tests/internal/osal/IntTestMutex.h"
|
||||||
#include "fsfw_tests/internal/UnittDefinitions.h"
|
#include "fsfw_tests/internal/UnittDefinitions.h"
|
||||||
|
#include "fsfw/platform.h"
|
||||||
|
|
||||||
#include <fsfw/ipc/MutexFactory.h>
|
#include <fsfw/ipc/MutexFactory.h>
|
||||||
|
|
||||||
#if defined(WIN32) || defined(UNIX)
|
#if defined PLATFORM_WIN || defined PLATFORM_UNIX
|
||||||
#include <fsfw/osal/host/Mutex.h>
|
#include "fsfw/osal/host/Mutex.h"
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <future>
|
#include <future>
|
||||||
#endif
|
#endif
|
||||||
@ -20,7 +22,7 @@ void testmutex::testMutex() {
|
|||||||
// timed_mutex from the C++ library specifies undefined behaviour if
|
// timed_mutex from the C++ library specifies undefined behaviour if
|
||||||
// the timed mutex is locked twice from the same thread.
|
// the timed mutex is locked twice from the same thread.
|
||||||
// TODO: we should pass a define like FSFW_OSAL_HOST to the build.
|
// TODO: we should pass a define like FSFW_OSAL_HOST to the build.
|
||||||
#if defined(WIN32) || defined(UNIX)
|
#if defined PLATFORM_WIN || defined PLATFORM_UNIX
|
||||||
// This calls the function from
|
// This calls the function from
|
||||||
// another thread and stores the returnvalue in a future.
|
// another thread and stores the returnvalue in a future.
|
||||||
auto future = std::async(&MutexIF::lockMutex, mutex, MutexIF::TimeoutType::WAITING, 1);
|
auto future = std::async(&MutexIF::lockMutex, mutex, MutexIF::TimeoutType::WAITING, 1);
|
||||||
@ -37,8 +39,7 @@ void testmutex::testMutex() {
|
|||||||
unitt::put_error(id);
|
unitt::put_error(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: we should pass a define like FSFW_OSAL_HOST to the build.
|
#if !defined PLATFORM_WIN && !defined PLATFORM_UNIX
|
||||||
#if !defined(WIN32) && !defined(UNIX)
|
|
||||||
result = mutex->unlockMutex();
|
result = mutex->unlockMutex();
|
||||||
if(result != MutexIF::CURR_THREAD_DOES_NOT_OWN_MUTEX) {
|
if(result != MutexIF::CURR_THREAD_DOES_NOT_OWN_MUTEX) {
|
||||||
unitt::put_error(id);
|
unitt::put_error(id);
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
#include "fsfw/FSFW.h"
|
||||||
#include "fsfw_tests/internal/osal/IntTestSemaphore.h"
|
#include "fsfw_tests/internal/osal/IntTestSemaphore.h"
|
||||||
#include "fsfw_tests/internal/UnittDefinitions.h"
|
#include "fsfw_tests/internal/UnittDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/tasks/SemaphoreFactory.h>
|
#include "fsfw/tasks/SemaphoreFactory.h"
|
||||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
#include <fsfw/timemanager/Stopwatch.h>
|
#include "fsfw/timemanager/Stopwatch.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ void testsemaph::testBinSemaph() {
|
|||||||
}
|
}
|
||||||
testBinSemaphoreImplementation(binSemaph, id);
|
testBinSemaphoreImplementation(binSemaph, id);
|
||||||
SemaphoreFactory::instance()->deleteSemaphore(binSemaph);
|
SemaphoreFactory::instance()->deleteSemaphore(binSemaph);
|
||||||
#if defined(freeRTOS)
|
#if defined FSFW_OSAL_FREERTOS
|
||||||
SemaphoreIF* binSemaphUsingTask =
|
SemaphoreIF* binSemaphUsingTask =
|
||||||
SemaphoreFactory::instance()->createBinarySemaphore(1);
|
SemaphoreFactory::instance()->createBinarySemaphore(1);
|
||||||
testBinSemaphoreImplementation(binSemaphUsingTask, id);
|
testBinSemaphoreImplementation(binSemaphUsingTask, id);
|
||||||
@ -36,7 +37,7 @@ void testsemaph::testCountingSemaph() {
|
|||||||
}
|
}
|
||||||
testBinSemaphoreImplementation(countingSemaph, id);
|
testBinSemaphoreImplementation(countingSemaph, id);
|
||||||
SemaphoreFactory::instance()->deleteSemaphore(countingSemaph);
|
SemaphoreFactory::instance()->deleteSemaphore(countingSemaph);
|
||||||
#if defined(freeRTOS)
|
#if defined FSFW_OSAL_FREERTOS
|
||||||
countingSemaph = SemaphoreFactory::instance()->
|
countingSemaph = SemaphoreFactory::instance()->
|
||||||
createCountingSemaphore(1, 1, 1);
|
createCountingSemaphore(1, 1, 1);
|
||||||
testBinSemaphoreImplementation(countingSemaph, id);
|
testBinSemaphoreImplementation(countingSemaph, id);
|
||||||
@ -50,7 +51,7 @@ void testsemaph::testCountingSemaph() {
|
|||||||
createCountingSemaphore(3,3);
|
createCountingSemaphore(3,3);
|
||||||
testCountingSemaphImplementation(countingSemaph, id);
|
testCountingSemaphImplementation(countingSemaph, id);
|
||||||
SemaphoreFactory::instance()->deleteSemaphore(countingSemaph);
|
SemaphoreFactory::instance()->deleteSemaphore(countingSemaph);
|
||||||
#if defined(freeRTOS)
|
#if defined FSFW_OSAL_FREERTOS
|
||||||
countingSemaph = SemaphoreFactory::instance()->
|
countingSemaph = SemaphoreFactory::instance()->
|
||||||
createCountingSemaphore(3, 0, 1);
|
createCountingSemaphore(3, 0, 1);
|
||||||
uint8_t semaphCount = countingSemaph->getSemaphoreCounter();
|
uint8_t semaphCount = countingSemaph->getSemaphoreCounter();
|
||||||
|
Loading…
Reference in New Issue
Block a user