Merge pull request 'clang formatting applied' (#126) from mueller/clang-formatting-applied into develop
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
Reviewed-on: #126
This commit is contained in:
commit
328b9d95af
@ -1,20 +1,19 @@
|
||||
#include "InitMission.h"
|
||||
#include "ObjectFactory.h"
|
||||
|
||||
#include <OBSWConfig.h>
|
||||
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include <fsfw/objectmanager/ObjectManagerIF.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
|
||||
#include <fsfw/tasks/PeriodicTaskIF.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
|
||||
#include <mission/utility/InitMission.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "ObjectFactory.h"
|
||||
|
||||
#ifdef LINUX
|
||||
ServiceInterfaceStream sif::debug("DEBUG");
|
||||
ServiceInterfaceStream sif::info("INFO");
|
||||
@ -55,8 +54,7 @@ void initmission::initTasks() {
|
||||
/* TMTC Distribution */
|
||||
PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask(
|
||||
"DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
|
||||
ReturnValue_t result = tmTcDistributor->addComponent(
|
||||
objects::CCSDS_PACKET_DISTRIBUTOR);
|
||||
ReturnValue_t result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "Object add component failed" << std::endl;
|
||||
}
|
||||
|
@ -4,6 +4,6 @@
|
||||
namespace initmission {
|
||||
void initMission();
|
||||
void initTasks();
|
||||
};
|
||||
}; // namespace initmission
|
||||
|
||||
#endif /* BSP_LINUX_INITMISSION_H_ */
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "ObjectFactory.h"
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
#include <fsfw/tmtcservices/CommandingServiceBase.h>
|
||||
#include <fsfw/tmtcservices/PusServiceBase.h>
|
||||
#include <mission/core/GenericFactory.h>
|
||||
#include <mission/utility/TmFunnel.h>
|
||||
#include <objects/systemObjectList.h>
|
||||
#include <tmtc/apid.h>
|
||||
#include <tmtc/pusIds.h>
|
||||
|
||||
#include <fsfw/tmtcservices/CommandingServiceBase.h>
|
||||
#include <fsfw/tmtcservices/PusServiceBase.h>
|
||||
|
||||
#include <mission/core/GenericFactory.h>
|
||||
#include <mission/utility/TmFunnel.h>
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
#if OBSW_USE_TMTC_TCP_BRIDGE == 0
|
||||
#include "fsfw/osal/common/UdpTcPollingTask.h"
|
||||
@ -20,7 +20,6 @@
|
||||
|
||||
#include <fsfw/tmtcpacket/pus/tm.h>
|
||||
|
||||
|
||||
#if OBSW_ADD_TEST_CODE == 1
|
||||
#include <test/testtasks/TestTask.h>
|
||||
#endif
|
||||
|
@ -1,10 +1,9 @@
|
||||
#ifndef BSP_LINUX_OBJECTFACTORY_H_
|
||||
#define BSP_LINUX_OBJECTFACTORY_H_
|
||||
|
||||
|
||||
namespace ObjectFactory {
|
||||
void setStatics();
|
||||
void produce(void* args);
|
||||
};
|
||||
}; // namespace ObjectFactory
|
||||
|
||||
#endif /* BSP_LINUX_OBJECTFACTORY_H_ */
|
||||
|
@ -7,7 +7,8 @@ extern "C" void __gcov_flush();
|
||||
#else
|
||||
void __gcov_flush() {
|
||||
sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if "
|
||||
"coverage information is desired.\n" << std::flush;
|
||||
"coverage information is desired.\n"
|
||||
<< std::flush;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -9,7 +9,3 @@ void printChar(const char* character, bool errStream) {
|
||||
}
|
||||
putc(*character, stdout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,26 +1,25 @@
|
||||
#include "ArduinoComIF.h"
|
||||
#include "ArduinoCookie.h"
|
||||
|
||||
#include <fsfw/globalfunctions/DleEncoder.h>
|
||||
#include <fsfw/globalfunctions/CRC.h>
|
||||
#include <fsfw/globalfunctions/DleEncoder.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
|
||||
#include "ArduinoCookie.h"
|
||||
|
||||
// This only works on Linux
|
||||
#ifdef LINUX
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#elif WIN32
|
||||
#include <windows.h>
|
||||
#include <strsafe.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
|
||||
ArduinoComIF::ArduinoComIF(object_id_t setObjectId, bool promptComIF,
|
||||
const char *serialDevice):
|
||||
rxBuffer(MAX_PACKET_SIZE * MAX_NUMBER_OF_SPI_DEVICES*10, true),
|
||||
SystemObject(setObjectId) {
|
||||
ArduinoComIF::ArduinoComIF(object_id_t setObjectId, bool promptComIF, const char *serialDevice)
|
||||
: rxBuffer(MAX_PACKET_SIZE * MAX_NUMBER_OF_SPI_DEVICES * 10, true), SystemObject(setObjectId) {
|
||||
#ifdef LINUX
|
||||
initialized = false;
|
||||
serialPort = ::open("/dev/ttyUSB0", O_RDWR);
|
||||
@ -66,7 +65,6 @@ ArduinoComIF::ArduinoComIF(object_id_t setObjectId, bool promptComIF,
|
||||
sif::info << "Please enter the COM port (c to cancel): " << std::flush;
|
||||
std::string comPort;
|
||||
while (hCom == INVALID_HANDLE_VALUE) {
|
||||
|
||||
std::getline(std::cin, comPort);
|
||||
if (comPort[0] == 'c') {
|
||||
break;
|
||||
@ -80,37 +78,29 @@ ArduinoComIF::ArduinoComIF(object_id_t setObjectId, bool promptComIF,
|
||||
0, // Non Overlapped I/O
|
||||
NULL); // Null for Comm Devices
|
||||
|
||||
if (hCom == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (hCom == INVALID_HANDLE_VALUE) {
|
||||
if (GetLastError() == 2) {
|
||||
sif::error << "COM Port does not found!" << std::endl;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
TCHAR err[128];
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
err, sizeof(err), NULL);
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), err, sizeof(err), NULL);
|
||||
// Handle the error.
|
||||
sif::info << "CreateFileA Error code: " << GetLastError()
|
||||
<< std::endl;
|
||||
sif::info << "CreateFileA Error code: " << GetLastError() << std::endl;
|
||||
sif::error << err << std::flush;
|
||||
}
|
||||
sif::info << "Please enter a valid COM port: " << std::flush;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
serialParams.DCBlength = sizeof(serialParams);
|
||||
if (baudRate == 9600) {
|
||||
serialParams.BaudRate = CBR_9600;
|
||||
}
|
||||
if (baudRate == 115200) {
|
||||
serialParams.BaudRate = CBR_115200;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
serialParams.BaudRate = baudRate;
|
||||
}
|
||||
|
||||
@ -143,29 +133,22 @@ ReturnValue_t ArduinoComIF::initializeInterface(CookieIF * cookie) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ArduinoComIF::sendMessage(CookieIF *cookie, const uint8_t *data,
|
||||
size_t len) {
|
||||
ReturnValue_t ArduinoComIF::sendMessage(CookieIF *cookie, const uint8_t *data, size_t len) {
|
||||
ArduinoCookie *arduinoCookie = dynamic_cast<ArduinoCookie *>(cookie);
|
||||
if (arduinoCookie == nullptr) {
|
||||
return INVALID_COOKIE_TYPE;
|
||||
}
|
||||
|
||||
return sendMessage(arduinoCookie->command, arduinoCookie->address, data,
|
||||
len);
|
||||
return sendMessage(arduinoCookie->command, arduinoCookie->address, data, len);
|
||||
}
|
||||
|
||||
ReturnValue_t ArduinoComIF::getSendSuccess(CookieIF *cookie) {
|
||||
ReturnValue_t ArduinoComIF::getSendSuccess(CookieIF *cookie) { return RETURN_OK; }
|
||||
|
||||
ReturnValue_t ArduinoComIF::requestReceiveMessage(CookieIF *cookie, size_t requestLen) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ArduinoComIF::requestReceiveMessage(CookieIF *cookie,
|
||||
size_t requestLen) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie,
|
||||
uint8_t **buffer, size_t *size) {
|
||||
|
||||
ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) {
|
||||
handleSerialPortRx();
|
||||
|
||||
ArduinoCookie *arduinoCookie = dynamic_cast<ArduinoCookie *>(cookie);
|
||||
@ -178,8 +161,8 @@ ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie,
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ArduinoComIF::sendMessage(uint8_t command,
|
||||
uint8_t address, const uint8_t *data, size_t dataLen) {
|
||||
ReturnValue_t ArduinoComIF::sendMessage(uint8_t command, uint8_t address, const uint8_t *data,
|
||||
size_t dataLen) {
|
||||
if (dataLen > UINT16_MAX) {
|
||||
return TOO_MUCH_DATA;
|
||||
}
|
||||
@ -193,16 +176,15 @@ ReturnValue_t ArduinoComIF::sendMessage(uint8_t command,
|
||||
size_t remainingLen = sizeof(sendBuffer) - 1;
|
||||
size_t encodedLen = 0;
|
||||
|
||||
ReturnValue_t result = DleEncoder::encode(&command, 1, currentPosition,
|
||||
remainingLen, &encodedLen, false);
|
||||
ReturnValue_t result =
|
||||
DleEncoder::encode(&command, 1, currentPosition, remainingLen, &encodedLen, false);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
currentPosition += encodedLen;
|
||||
remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen
|
||||
|
||||
result = DleEncoder::encode(&address, 1, currentPosition, remainingLen,
|
||||
&encodedLen, false);
|
||||
result = DleEncoder::encode(&address, 1, currentPosition, remainingLen, &encodedLen, false);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
@ -215,8 +197,8 @@ ReturnValue_t ArduinoComIF::sendMessage(uint8_t command,
|
||||
temporaryBuffer[0] = dataLen >> 8; // we checked dataLen above
|
||||
temporaryBuffer[1] = dataLen;
|
||||
|
||||
result = DleEncoder::encode(temporaryBuffer, 2, currentPosition,
|
||||
remainingLen, &encodedLen, false);
|
||||
result =
|
||||
DleEncoder::encode(temporaryBuffer, 2, currentPosition, remainingLen, &encodedLen, false);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
@ -224,8 +206,7 @@ ReturnValue_t ArduinoComIF::sendMessage(uint8_t command,
|
||||
remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen
|
||||
|
||||
// encoding the actual data
|
||||
result = DleEncoder::encode(data, dataLen, currentPosition, remainingLen,
|
||||
&encodedLen, false);
|
||||
result = DleEncoder::encode(data, dataLen, currentPosition, remainingLen, &encodedLen, false);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
@ -241,8 +222,8 @@ ReturnValue_t ArduinoComIF::sendMessage(uint8_t command,
|
||||
temporaryBuffer[0] = crc >> 8;
|
||||
temporaryBuffer[1] = crc;
|
||||
|
||||
result = DleEncoder::encode(temporaryBuffer, 2, currentPosition,
|
||||
remainingLen, &encodedLen, false);
|
||||
result =
|
||||
DleEncoder::encode(temporaryBuffer, 2, currentPosition, remainingLen, &encodedLen, false);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
@ -279,8 +260,7 @@ void ArduinoComIF::handleSerialPortRx() {
|
||||
|
||||
uint8_t dataFromSerial[availableSpace];
|
||||
|
||||
ssize_t bytesRead = read(serialPort, dataFromSerial,
|
||||
sizeof(dataFromSerial));
|
||||
ssize_t bytesRead = read(serialPort, dataFromSerial, sizeof(dataFromSerial));
|
||||
|
||||
if (bytesRead < 0) {
|
||||
return;
|
||||
@ -292,13 +272,12 @@ void ArduinoComIF::handleSerialPortRx() {
|
||||
|
||||
uint32_t dataLenReceivedSoFar = 0;
|
||||
|
||||
rxBuffer.readData(dataReceivedSoFar, sizeof(dataReceivedSoFar), true,
|
||||
&dataLenReceivedSoFar);
|
||||
rxBuffer.readData(dataReceivedSoFar, sizeof(dataReceivedSoFar), true, &dataLenReceivedSoFar);
|
||||
|
||||
// look for STX
|
||||
size_t firstSTXinRawData = 0;
|
||||
while ((firstSTXinRawData < dataLenReceivedSoFar)
|
||||
&& (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR)) {
|
||||
while ((firstSTXinRawData < dataLenReceivedSoFar) &&
|
||||
(dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR)) {
|
||||
firstSTXinRawData++;
|
||||
}
|
||||
|
||||
@ -313,10 +292,9 @@ void ArduinoComIF::handleSerialPortRx() {
|
||||
|
||||
size_t readSize = 0;
|
||||
|
||||
ReturnValue_t result = DleEncoder::decode(
|
||||
dataReceivedSoFar + firstSTXinRawData,
|
||||
dataLenReceivedSoFar - firstSTXinRawData, &readSize, packet,
|
||||
sizeof(packet), &packetLen);
|
||||
ReturnValue_t result = DleEncoder::decode(dataReceivedSoFar + firstSTXinRawData,
|
||||
dataLenReceivedSoFar - firstSTXinRawData, &readSize,
|
||||
packet, sizeof(packet), &packetLen);
|
||||
|
||||
size_t toDelete = firstSTXinRawData;
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
@ -333,9 +311,7 @@ void ArduinoComIF::handleSerialPortRx() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void ArduinoComIF::setBaudrate(uint32_t baudRate) {
|
||||
this->baudRate = baudRate;
|
||||
}
|
||||
void ArduinoComIF::setBaudrate(uint32_t baudRate) { this->baudRate = baudRate; }
|
||||
|
||||
void ArduinoComIF::handlePacket(uint8_t *packet, size_t packetLen) {
|
||||
uint16_t crc = CRC::crc16ccitt(packet, packetLen);
|
||||
@ -368,8 +344,7 @@ void ArduinoComIF::handlePacket(uint8_t *packet, size_t packetLen) {
|
||||
}
|
||||
std::memcpy(cookie.replyBuffer.data(), packet + 4, packetLen - 6);
|
||||
cookie.receivedDataLen = packetLen - 6;
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include <fsfw/container/FixedMap.h>
|
||||
#include <fsfw/container/SimpleRingBuffer.h>
|
||||
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
@ -17,8 +17,7 @@
|
||||
// Forward declaration, so users don't peek
|
||||
class ArduinoCookie;
|
||||
|
||||
class ArduinoComIF: public SystemObject,
|
||||
public DeviceCommunicationIF {
|
||||
class ArduinoComIF : public SystemObject, public DeviceCommunicationIF {
|
||||
public:
|
||||
static const uint8_t MAX_NUMBER_OF_SPI_DEVICES = 8;
|
||||
static const uint8_t MAX_PACKET_SIZE = 64;
|
||||
@ -34,13 +33,12 @@ public:
|
||||
|
||||
/** DeviceCommunicationIF overrides */
|
||||
virtual ReturnValue_t initializeInterface(CookieIF *cookie) override;
|
||||
virtual ReturnValue_t sendMessage(CookieIF *cookie,
|
||||
const uint8_t * sendData, size_t sendLen) override;
|
||||
virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData,
|
||||
size_t sendLen) override;
|
||||
virtual ReturnValue_t getSendSuccess(CookieIF *cookie) override;
|
||||
virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie,
|
||||
size_t requestLen) override;
|
||||
virtual ReturnValue_t readReceivedMessage(CookieIF *cookie,
|
||||
uint8_t **buffer, size_t *size) override;
|
||||
virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override;
|
||||
virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
||||
size_t *size) override;
|
||||
|
||||
private:
|
||||
#ifdef LINUX
|
||||
@ -59,8 +57,7 @@ private:
|
||||
|
||||
SimpleRingBuffer rxBuffer;
|
||||
|
||||
ReturnValue_t sendMessage(uint8_t command, uint8_t address,
|
||||
const uint8_t *data, size_t dataLen);
|
||||
ReturnValue_t sendMessage(uint8_t command, uint8_t address, const uint8_t *data, size_t dataLen);
|
||||
void handleSerialPortRx();
|
||||
|
||||
void handlePacket(uint8_t *packet, size_t packetLen);
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <bsp_hosted/comIF/ArduinoCookie.h>
|
||||
|
||||
ArduinoCookie::ArduinoCookie(Protocol_t protocol, uint8_t address,
|
||||
const size_t maxReplySize) :
|
||||
protocol(protocol), command(protocol), address(address),
|
||||
maxReplySize(maxReplySize), replyBuffer(maxReplySize) {
|
||||
}
|
||||
|
||||
ArduinoCookie::ArduinoCookie(Protocol_t protocol, uint8_t address, const size_t maxReplySize)
|
||||
: protocol(protocol),
|
||||
command(protocol),
|
||||
address(address),
|
||||
maxReplySize(maxReplySize),
|
||||
replyBuffer(maxReplySize) {}
|
||||
|
@ -2,18 +2,14 @@
|
||||
#define MISSION_ARDUINO_ARDUINOCOOKIE_H_
|
||||
|
||||
#include <fsfw/devicehandlers/CookieIF.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
class ArduinoCookie : public CookieIF {
|
||||
public:
|
||||
enum Protocol_t: uint8_t {
|
||||
INVALID,
|
||||
SPI,
|
||||
I2C
|
||||
};
|
||||
enum Protocol_t : uint8_t { INVALID, SPI, I2C };
|
||||
|
||||
ArduinoCookie(Protocol_t protocol, uint8_t address,
|
||||
const size_t maxReplySize);
|
||||
ArduinoCookie(Protocol_t protocol, uint8_t address, const size_t maxReplySize);
|
||||
|
||||
Protocol_t protocol;
|
||||
uint8_t command;
|
||||
@ -21,7 +17,6 @@ public:
|
||||
std::vector<uint8_t> replyBuffer;
|
||||
size_t receivedDataLen = 0;
|
||||
size_t maxReplySize;
|
||||
|
||||
};
|
||||
|
||||
#endif /* MISSION_ARDUINO_ARDUINOCOOKIE_H_ */
|
||||
|
@ -51,7 +51,4 @@ namespace gpioIds {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* FSFWCONFIG_DEVICES_GPIOIDS_H_ */
|
||||
|
@ -52,7 +52,6 @@ namespace pcduSwitches {
|
||||
static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF;
|
||||
static const uint8_t INIT_STATE_PLOC = OFF;
|
||||
static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF;
|
||||
}
|
||||
|
||||
} // namespace pcduSwitches
|
||||
|
||||
#endif /* FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ */
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_
|
||||
|
||||
#include <common/config/commonSubsystemIds.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
@ -9,9 +10,7 @@
|
||||
* Numbers 0-80 are reserved for FSFW Subsystem IDs (framework/events/)
|
||||
*/
|
||||
namespace SUBSYSTEM_ID {
|
||||
enum: uint8_t {
|
||||
SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END
|
||||
};
|
||||
enum : uint8_t { SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END };
|
||||
}
|
||||
|
||||
#endif /* CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ */
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "MissionMessageTypes.h"
|
||||
|
||||
#include <fsfw/ipc/CommandMessage.h>
|
||||
|
||||
void messagetypes::clearMissionMessage(CommandMessage* message) {
|
||||
@ -7,5 +8,3 @@ void messagetypes::clearMissionMessage(CommandMessage* message) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,6 +17,6 @@ enum MESSAGE_TYPE {
|
||||
};
|
||||
|
||||
void clearMissionMessage(CommandMessage* message);
|
||||
}
|
||||
} // namespace messagetypes
|
||||
|
||||
#endif /* CONFIG_IPC_MISSIONMESSAGETYPES_H_ */
|
||||
|
@ -1,9 +1,10 @@
|
||||
#ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_
|
||||
#define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <commonObjects.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
// The objects will be instantiated in the ID order
|
||||
namespace objects {
|
||||
enum sourceObjects : uint32_t {
|
||||
|
@ -1,9 +1,10 @@
|
||||
#ifndef CONFIG_RETURNVALUES_CLASSIDS_H_
|
||||
#define CONFIG_RETURNVALUES_CLASSIDS_H_
|
||||
|
||||
#include "commonClassIds.h"
|
||||
#include <fsfw/returnvalues/FwClassIds.h>
|
||||
|
||||
#include "commonClassIds.h"
|
||||
|
||||
/**
|
||||
* Source IDs starts at 73 for now
|
||||
* Framework IDs for ReturnValues run from 0 to 56
|
||||
@ -15,5 +16,4 @@ enum {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif /* CONFIG_RETURNVALUES_CLASSIDS_H_ */
|
||||
|
@ -15,5 +15,4 @@ namespace apid {
|
||||
static const uint16_t EIVE_OBSW = 0x65;
|
||||
}
|
||||
|
||||
|
||||
#endif /* FSFWCONFIG_TMTC_APID_H_ */
|
||||
|
@ -1,10 +1,9 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "InitMission.h"
|
||||
#include "OBSWVersion.h"
|
||||
|
||||
#include "fsfw/FSFWVersion.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
|
||||
#include <iostream>
|
||||
#ifdef WIN32
|
||||
static const char* COMPILE_PRINTOUT = "Windows";
|
||||
#elif LINUX
|
||||
@ -17,13 +16,12 @@ static const char* COMPILE_PRINTOUT = "unknown OS";
|
||||
* Linux and Windows.
|
||||
* @return
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
int main(void) {
|
||||
std::cout << "-- EIVE OBSW --" << std::endl;
|
||||
std::cout << "-- Compiled for " << COMPILE_PRINTOUT << " --" << std::endl;
|
||||
std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION <<
|
||||
"." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << "." <<
|
||||
FSFW_REVISION << "--" << std::endl;
|
||||
std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << "."
|
||||
<< SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << "."
|
||||
<< FSFW_REVISION << "--" << std::endl;
|
||||
std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl;
|
||||
|
||||
initmission::initMission();
|
||||
@ -33,5 +31,3 @@ int main(void)
|
||||
TaskFactory::delayTask(5000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,21 +1,21 @@
|
||||
#include "InitMission.h"
|
||||
#include "ObjectFactory.h"
|
||||
|
||||
#include "objects/systemObjectList.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "pollingsequence/pollingSequenceFactory.h"
|
||||
|
||||
#include <mission/utility/InitMission.h>
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include <fsfw/objectmanager/ObjectManagerIF.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
|
||||
#include <fsfw/tasks/PeriodicTaskIF.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
#include <mission/utility/InitMission.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "ObjectFactory.h"
|
||||
#include "objects/systemObjectList.h"
|
||||
#include "pollingsequence/pollingSequenceFactory.h"
|
||||
|
||||
ServiceInterfaceStream sif::debug("DEBUG");
|
||||
ServiceInterfaceStream sif::info("INFO");
|
||||
ServiceInterfaceStream sif::warning("WARNING");
|
||||
@ -47,7 +47,6 @@ void initmission::initTasks() {
|
||||
void (*missedDeadlineFunc)(void) = nullptr;
|
||||
#endif
|
||||
|
||||
|
||||
/* TMTC Distribution */
|
||||
PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask(
|
||||
"DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
|
||||
@ -93,8 +92,7 @@ void initmission::initTasks() {
|
||||
for (const auto& task : taskVector) {
|
||||
if (task != nullptr) {
|
||||
task->startTask();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::error << "Task in vector " << name << " is invalid!" << std::endl;
|
||||
}
|
||||
}
|
||||
@ -120,7 +118,8 @@ void initmission::initTasks() {
|
||||
}
|
||||
|
||||
void initmission::createPusTasks(TaskFactory& factory,
|
||||
TaskDeadlineMissedFunction missedDeadlineFunc, std::vector<PeriodicTaskIF*>& taskVec) {
|
||||
TaskDeadlineMissedFunction missedDeadlineFunc,
|
||||
std::vector<PeriodicTaskIF*>& taskVec) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
PeriodicTaskIF* pusVerification = factory.createPeriodicTask(
|
||||
"PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc);
|
||||
@ -182,19 +181,18 @@ void initmission::createPusTasks(TaskFactory& factory,
|
||||
}
|
||||
result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
initmission::printAddObjectError("INT_ERR_RPRT",
|
||||
objects::INTERNAL_ERROR_REPORTER);
|
||||
initmission::printAddObjectError("INT_ERR_RPRT", objects::INTERNAL_ERROR_REPORTER);
|
||||
}
|
||||
taskVec.push_back(pusLowPrio);
|
||||
}
|
||||
|
||||
void initmission::createPstTasks(TaskFactory& factory,
|
||||
TaskDeadlineMissedFunction missedDeadlineFunc, std::vector<PeriodicTaskIF*> &taskVec) {
|
||||
TaskDeadlineMissedFunction missedDeadlineFunc,
|
||||
std::vector<PeriodicTaskIF*>& taskVec) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
#if OBSW_ADD_SPI_TEST_CODE == 0
|
||||
FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask(
|
||||
"SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0,
|
||||
missedDeadlineFunc);
|
||||
"SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc);
|
||||
result = pst::pstSpi(spiPst);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl;
|
||||
@ -235,13 +233,12 @@ void initmission::createTestTasks(TaskFactory& factory,
|
||||
bool startTestPst = true;
|
||||
static_cast<void>(startTestPst);
|
||||
#if OBSW_ADD_TEST_PST == 1
|
||||
FixedTimeslotTaskIF* pstTestTask = factory->createFixedTimeslotTask("TEST_PST", 50,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 2.0, missedDeadlineFunc);
|
||||
FixedTimeslotTaskIF* pstTestTask = factory->createFixedTimeslotTask(
|
||||
"TEST_PST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 2.0, missedDeadlineFunc);
|
||||
result = pst::pstTest(pstTestTask);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::info << "initmission::initTasks: ACS PST empty or invalid" << std::endl;
|
||||
startTestPst = false;
|
||||
}
|
||||
#endif /* RPI_TEST_ACS_BOARD == 1 */
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
#ifndef BSP_LINUX_INITMISSION_H_
|
||||
#define BSP_LINUX_INITMISSION_H_
|
||||
|
||||
#include "fsfw/tasks/Typedef.h"
|
||||
#include <vector>
|
||||
|
||||
#include "fsfw/tasks/Typedef.h"
|
||||
|
||||
class PeriodicTaskIF;
|
||||
class TaskFactory;
|
||||
|
||||
@ -11,14 +12,12 @@ namespace initmission {
|
||||
void initMission();
|
||||
void initTasks();
|
||||
|
||||
void createPstTasks(TaskFactory& factory,
|
||||
TaskDeadlineMissedFunction missedDeadlineFunc,
|
||||
void createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc,
|
||||
std::vector<PeriodicTaskIF*>& taskVec);
|
||||
void createTestTasks(TaskFactory& factory,
|
||||
TaskDeadlineMissedFunction missedDeadlineFunc,
|
||||
void createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc,
|
||||
std::vector<PeriodicTaskIF*>& taskVec);
|
||||
void createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc,
|
||||
std::vector<PeriodicTaskIF*>& taskVec);
|
||||
};
|
||||
}; // namespace initmission
|
||||
|
||||
#endif /* BSP_LINUX_INITMISSION_H_ */
|
||||
|
@ -1,47 +1,47 @@
|
||||
#include <devConf.h>
|
||||
#include "ObjectFactory.h"
|
||||
|
||||
#include "objects/systemObjectList.h"
|
||||
#include <devConf.h>
|
||||
#include <mission/devices/GPSHyperionHandler.h>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "devices/addresses.h"
|
||||
#include "devices/gpioIds.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "tmtc/apid.h"
|
||||
#include "tmtc/pusIds.h"
|
||||
#include "fsfw/datapoollocal/LocalDataPoolManager.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
#include "fsfw/tmtcpacket/pus/tm.h"
|
||||
#include "fsfw/tmtcservices/CommandingServiceBase.h"
|
||||
#include "fsfw/tmtcservices/PusServiceBase.h"
|
||||
#include "linux/boardtest/LibgpiodTest.h"
|
||||
#include "linux/boardtest/SpiTestClass.h"
|
||||
#include "linux/boardtest/UartTestClass.h"
|
||||
|
||||
#include "mission/core/GenericFactory.h"
|
||||
#include "mission/utility/TmFunnel.h"
|
||||
#include <mission/devices/GPSHyperionHandler.h>
|
||||
#include "mission/devices/GyroADIS1650XHandler.h"
|
||||
|
||||
#include "fsfw/datapoollocal/LocalDataPoolManager.h"
|
||||
#include "fsfw/tmtcservices/CommandingServiceBase.h"
|
||||
#include "fsfw/tmtcservices/PusServiceBase.h"
|
||||
#include "fsfw/tmtcpacket/pus/tm.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
#include "mission/utility/TmFunnel.h"
|
||||
#include "objects/systemObjectList.h"
|
||||
#include "tmtc/apid.h"
|
||||
#include "tmtc/pusIds.h"
|
||||
|
||||
/* UDP server includes */
|
||||
#if OBSW_USE_TMTC_TCP_BRIDGE == 1
|
||||
#include <fsfw/src/fsfw/osal/common/TcpTmTcBridge.h>
|
||||
#include <fsfw/src/fsfw/osal/common/TcpTmTcServer.h>
|
||||
#else
|
||||
#include "fsfw/osal/common/UdpTmTcBridge.h"
|
||||
#include "fsfw/osal/common/UdpTcPollingTask.h"
|
||||
#include "fsfw/osal/common/UdpTmTcBridge.h"
|
||||
#endif
|
||||
|
||||
#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h"
|
||||
#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h"
|
||||
#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h"
|
||||
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
|
||||
#include "fsfw_hal/linux/rpi/GpioRPi.h"
|
||||
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
||||
#include "fsfw_hal/linux/spi/SpiCookie.h"
|
||||
#include "fsfw_hal/linux/spi/SpiComIF.h"
|
||||
#include <fsfw_hal/linux/uart/UartComIF.h>
|
||||
#include <fsfw_hal/linux/uart/UartCookie.h>
|
||||
|
||||
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
||||
#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h"
|
||||
#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h"
|
||||
#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h"
|
||||
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
|
||||
#include "fsfw_hal/linux/rpi/GpioRPi.h"
|
||||
#include "fsfw_hal/linux/spi/SpiComIF.h"
|
||||
#include "fsfw_hal/linux/spi/SpiCookie.h"
|
||||
|
||||
void Factory::setStaticFrameworkObjectIds() {
|
||||
PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR;
|
||||
PusServiceBase::packetDestination = objects::TM_FUNNEL;
|
||||
@ -57,8 +57,6 @@ void Factory::setStaticFrameworkObjectIds() {
|
||||
TmPacketBase::timeStamperId = objects::TIME_STAMPER;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ObjectFactory::produce(void* args) {
|
||||
Factory::setStaticFrameworkObjectIds();
|
||||
ObjectFactory::produceGenericObjects();
|
||||
@ -88,85 +86,93 @@ void ObjectFactory::produce(void* args){
|
||||
gpioCookie = new GpioCookie();
|
||||
}
|
||||
// TODO: Missing pin for Gyro 2
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_0_LIS3_CS, gpio::MGM_0_BCM_PIN,
|
||||
"MGM_0_LIS3", gpio::Direction::OUT, 1);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_0_LIS3_CS, gpio::MGM_0_BCM_PIN, "MGM_0_LIS3",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_1_RM3100_CS, gpio::MGM_1_BCM_PIN,
|
||||
"MGM_1_RM3100", gpio::Direction::OUT, 1);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_2_LIS3_CS, gpio::MGM_2_BCM_PIN,
|
||||
"MGM_2_LIS3", gpio::Direction::OUT, 1);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_2_LIS3_CS, gpio::MGM_2_BCM_PIN, "MGM_2_LIS3",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_3_RM3100_CS, gpio::MGM_3_BCM_PIN,
|
||||
"MGM_3_RM3100", gpio::Direction::OUT, 1);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN,
|
||||
"GYRO_0_ADIS", gpio::Direction::OUT, 1);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_1_L3G_CS, gpio::GYRO_1_BCM_PIN,
|
||||
"GYRO_1_L3G", gpio::Direction::OUT, 1);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_1_L3G_CS, gpio::GYRO_1_BCM_PIN, "GYRO_1_L3G",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_2_ADIS_CS, gpio::GYRO_2_BCM_PIN,
|
||||
"GYRO_2_ADIS", gpio::Direction::OUT, 1);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_3_L3G_CS, gpio::GYRO_3_BCM_PIN,
|
||||
"GYRO_3_L3G", gpio::Direction::OUT, 1);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_3_L3G_CS, gpio::GYRO_3_BCM_PIN, "GYRO_3_L3G",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioIF->addGpios(gpioCookie);
|
||||
|
||||
spiDev = "/dev/spidev0.1";
|
||||
spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev,
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev,
|
||||
MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED);
|
||||
auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER,
|
||||
objects::SPI_COM_IF, spiCookie, 0);
|
||||
auto mgmLis3Handler =
|
||||
new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_COM_IF, spiCookie, 0);
|
||||
mgmLis3Handler->setStartUpImmediately();
|
||||
#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1
|
||||
mgmLis3Handler->setToGoToNormalMode(true);
|
||||
#endif
|
||||
|
||||
spiCookie = new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev,
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev,
|
||||
RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED);
|
||||
auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER,
|
||||
objects::SPI_COM_IF, spiCookie, 0);
|
||||
auto mgmRm3100Handler =
|
||||
new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_COM_IF, spiCookie, 0);
|
||||
mgmRm3100Handler->setStartUpImmediately();
|
||||
#if FSFW_HAL_RM3100_MGM_DEBUG == 1
|
||||
mgmRm3100Handler->setToGoToNormalMode(true);
|
||||
#endif
|
||||
|
||||
spiCookie = new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev,
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev,
|
||||
MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED);
|
||||
mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER,
|
||||
objects::SPI_COM_IF, spiCookie, 0);
|
||||
mgmLis3Handler =
|
||||
new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_COM_IF, spiCookie, 0);
|
||||
mgmLis3Handler->setStartUpImmediately();
|
||||
#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1
|
||||
mgmLis3Handler->setToGoToNormalMode(true);
|
||||
#endif
|
||||
|
||||
spiCookie = new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev,
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev,
|
||||
RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED);
|
||||
mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER,
|
||||
objects::SPI_COM_IF, spiCookie, 0);
|
||||
mgmRm3100Handler =
|
||||
new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_COM_IF, spiCookie, 0);
|
||||
mgmRm3100Handler->setStartUpImmediately();
|
||||
#if FSFW_HAL_RM3100_MGM_DEBUG == 1
|
||||
mgmRm3100Handler->setToGoToNormalMode(true);
|
||||
#endif
|
||||
|
||||
spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev,
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev,
|
||||
ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
auto adisHandler = new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF,
|
||||
spiCookie);
|
||||
auto adisHandler =
|
||||
new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie);
|
||||
adisHandler->setStartUpImmediately();
|
||||
spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev,
|
||||
L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF,
|
||||
spiCookie, 0);
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE,
|
||||
spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
auto gyroL3gHandler =
|
||||
new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, spiCookie, 0);
|
||||
gyroL3gHandler->setStartUpImmediately();
|
||||
#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1
|
||||
gyroL3gHandler->setToGoToNormalMode(true);
|
||||
#endif
|
||||
|
||||
spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev,
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev,
|
||||
ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
adisHandler = new GyroADIS16507Handler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF,
|
||||
spiCookie);
|
||||
adisHandler =
|
||||
new GyroADIS16507Handler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie);
|
||||
adisHandler->setStartUpImmediately();
|
||||
|
||||
spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev,
|
||||
L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF,
|
||||
spiCookie, 0);
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE,
|
||||
spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
gyroL3gHandler =
|
||||
new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, spiCookie, 0);
|
||||
gyroL3gHandler->setStartUpImmediately();
|
||||
#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1
|
||||
gyroL3gHandler->setToGoToNormalMode(true);
|
||||
@ -180,7 +186,6 @@ void ObjectFactory::produce(void* args){
|
||||
}
|
||||
|
||||
void ObjectFactory::createTestTasks() {
|
||||
|
||||
new TestTask(objects::TEST_TASK);
|
||||
|
||||
#if RPI_ADD_SPI_TEST == 1
|
||||
@ -217,20 +222,20 @@ void ObjectFactory::createTestTasks() {
|
||||
|
||||
spiDev = "/dev/spidev0.1";
|
||||
spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev,
|
||||
ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, spi::DEFAULT_ADIS16507_SPEED,
|
||||
nullptr, nullptr);
|
||||
auto adisGyroHandler = new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie);
|
||||
ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE,
|
||||
spi::DEFAULT_ADIS16507_SPEED, nullptr, nullptr);
|
||||
auto adisGyroHandler =
|
||||
new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie);
|
||||
adisGyroHandler->setStartUpImmediately();
|
||||
#endif /* RPI_TEST_ADIS16507 == 1 */
|
||||
|
||||
#if RPI_TEST_GPS_HANDLER == 1
|
||||
UartCookie* uartCookie = new UartCookie(objects::GPS0_HANDLER, "/dev/serial0",
|
||||
UartModes::CANONICAL, 9600, 1024);
|
||||
UartCookie* uartCookie =
|
||||
new UartCookie(objects::GPS0_HANDLER, "/dev/serial0", UartModes::CANONICAL, 9600, 1024);
|
||||
uartCookie->setToFlushInput(true);
|
||||
uartCookie->setReadCycles(6);
|
||||
GPSHyperionHandler* gpsHandler = new GPSHyperionHandler(objects::GPS0_HANDLER,
|
||||
objects::UART_COM_IF, uartCookie, false);
|
||||
GPSHyperionHandler* gpsHandler =
|
||||
new GPSHyperionHandler(objects::GPS0_HANDLER, objects::UART_COM_IF, uartCookie, false);
|
||||
gpsHandler->setStartUpImmediately();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
#ifndef BSP_LINUX_OBJECTFACTORY_H_
|
||||
#define BSP_LINUX_OBJECTFACTORY_H_
|
||||
|
||||
|
||||
namespace ObjectFactory {
|
||||
void setStatics();
|
||||
void produce(void* args);
|
||||
|
||||
void createTestTasks();
|
||||
};
|
||||
}; // namespace ObjectFactory
|
||||
|
||||
#endif /* BSP_LINUX_OBJECTFACTORY_H_ */
|
||||
|
@ -7,7 +7,8 @@ extern "C" void __gcov_flush();
|
||||
#else
|
||||
void __gcov_flush() {
|
||||
sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if "
|
||||
"coverage information is desired.\n" << std::flush;
|
||||
"coverage information is desired.\n"
|
||||
<< std::flush;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -8,7 +8,3 @@ void printChar(const char* character, bool errStream) {
|
||||
}
|
||||
putc(*character, stdout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "InitMission.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "OBSWVersion.h"
|
||||
|
||||
#include "fsfw/FSFWVersion.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#ifdef RASPBERRY_PI
|
||||
static const char* const BOARD_NAME = "Raspberry Pi";
|
||||
#elif defined(BEAGLEBONEBLACK)
|
||||
@ -19,13 +18,12 @@ static const char* const BOARD_NAME = "Unknown Board";
|
||||
* @brief This is the main program and entry point for the Raspberry Pi.
|
||||
* @return
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
int main(void) {
|
||||
std::cout << "-- EIVE OBSW --" << std::endl;
|
||||
std::cout << "-- Compiled for Linux board " << BOARD_NAME << " --" << std::endl;
|
||||
std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION <<
|
||||
"." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION <<
|
||||
FSFW_REVISION << "--" << std::endl;
|
||||
std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << "."
|
||||
<< SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << FSFW_REVISION
|
||||
<< "--" << std::endl;
|
||||
std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl;
|
||||
|
||||
initmission::initMission();
|
||||
@ -35,5 +33,3 @@ int main(void)
|
||||
TaskFactory::delayTask(5000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@ namespace gpioNames {
|
||||
static constexpr char RS485_EN_RX_DATA[] = "rx_data_enable_ltc2872";
|
||||
static constexpr char PDEC_RESET[] = "pdec_reset";
|
||||
static constexpr char BIT_RATE_SEL[] = "bit_rate_sel";
|
||||
}
|
||||
}
|
||||
} // namespace gpioNames
|
||||
} // namespace q7s
|
||||
|
||||
#endif /* BSP_Q7S_BOARDCONFIG_BUSCONF_H_ */
|
||||
|
@ -7,7 +7,8 @@ extern "C" void __gcov_flush();
|
||||
#else
|
||||
void __gcov_flush() {
|
||||
sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if "
|
||||
"coverage information is desired.\n" << std::flush;
|
||||
"coverage information is desired.\n"
|
||||
<< std::flush;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -8,7 +8,3 @@ void printChar(const char* character, bool errStream) {
|
||||
}
|
||||
putc(*character, stdout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,13 +1,11 @@
|
||||
#include "FileSystemTest.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include "fsfw/timemanager/Stopwatch.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
enum SdCard {
|
||||
SDC0,
|
||||
SDC1
|
||||
};
|
||||
enum SdCard { SDC0, SDC1 };
|
||||
|
||||
FileSystemTest::FileSystemTest() {
|
||||
using namespace std;
|
||||
@ -22,5 +20,4 @@ FileSystemTest::FileSystemTest() {
|
||||
// stopwatch.stop(true);
|
||||
}
|
||||
|
||||
FileSystemTest::~FileSystemTest() {
|
||||
}
|
||||
FileSystemTest::~FileSystemTest() {}
|
||||
|
@ -5,9 +5,8 @@ class FileSystemTest {
|
||||
public:
|
||||
FileSystemTest();
|
||||
virtual ~FileSystemTest();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ */
|
||||
|
@ -1,25 +1,23 @@
|
||||
#include "Q7STestTask.h"
|
||||
|
||||
#include <bsp_q7s/core/CoreController.h>
|
||||
#include <bsp_q7s/memory/FileSystemHandler.h>
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include "Q7STestTask.h"
|
||||
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "bsp_q7s/memory/scratchApi.h"
|
||||
|
||||
#include "fsfw/timemanager/Stopwatch.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
|
||||
#include "test/DummyParameter.h"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <gps.h>
|
||||
#include <libgpsmm.h>
|
||||
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "bsp_q7s/memory/scratchApi.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
#include "fsfw/timemanager/Stopwatch.h"
|
||||
#include "test/DummyParameter.h"
|
||||
|
||||
Q7STestTask::Q7STestTask(object_id_t objectId) : TestTask(objectId) {
|
||||
doTestSdCard = false;
|
||||
@ -65,8 +63,7 @@ void Q7STestTask::testSdCard() {
|
||||
while (iss >> word) {
|
||||
if (word == "on") {
|
||||
sif::info << "SD card " << static_cast<int>(idx) << " is on" << endl;
|
||||
}
|
||||
else if(word == "off") {
|
||||
} else if (word == "off") {
|
||||
sif::info << "SD card " << static_cast<int>(idx) << " is off" << endl;
|
||||
}
|
||||
}
|
||||
@ -136,7 +133,6 @@ void Q7STestTask::testDummyParams() {
|
||||
|
||||
ReturnValue_t result = param.readJsonFile();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
|
||||
}
|
||||
|
||||
param.setValue(DummyParameter::DUMMY_KEY_PARAM_1, 3);
|
||||
@ -164,8 +160,8 @@ void Q7STestTask::testDummyParams() {
|
||||
ReturnValue_t Q7STestTask::initialize() {
|
||||
coreController = ObjectManager::instance()->get<CoreController>(objects::CORE_CONTROLLER);
|
||||
if (coreController == nullptr) {
|
||||
sif::warning << "Q7STestTask::initialize: Could not retrieve CORE_CONTROLLER object" <<
|
||||
std::endl;
|
||||
sif::warning << "Q7STestTask::initialize: Could not retrieve CORE_CONTROLLER object"
|
||||
<< std::endl;
|
||||
}
|
||||
return TestTask::initialize();
|
||||
}
|
||||
@ -175,16 +171,14 @@ void Q7STestTask::testProtHandler() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
// If any chips are unlocked, lock them here
|
||||
result = coreController->setBootCopyProtection(
|
||||
CoreController::Chip::ALL_CHIP, CoreController::Copy::ALL_COPY, true,
|
||||
opPerformed, true);
|
||||
CoreController::Chip::ALL_CHIP, CoreController::Copy::ALL_COPY, true, opPerformed, true);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl;
|
||||
}
|
||||
|
||||
// unlock own copy
|
||||
result = coreController->setBootCopyProtection(
|
||||
CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false,
|
||||
opPerformed, true);
|
||||
CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false, opPerformed, true);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl;
|
||||
}
|
||||
@ -198,8 +192,7 @@ void Q7STestTask::testProtHandler() {
|
||||
|
||||
// lock own copy
|
||||
result = coreController->setBootCopyProtection(
|
||||
CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true,
|
||||
opPerformed, true);
|
||||
CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true, opPerformed, true);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl;
|
||||
}
|
||||
@ -213,8 +206,7 @@ void Q7STestTask::testProtHandler() {
|
||||
|
||||
// unlock specific copy
|
||||
result = coreController->setBootCopyProtection(
|
||||
CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, false,
|
||||
opPerformed, true);
|
||||
CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, false, opPerformed, true);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl;
|
||||
}
|
||||
@ -228,8 +220,7 @@ void Q7STestTask::testProtHandler() {
|
||||
|
||||
// lock specific copy
|
||||
result = coreController->setBootCopyProtection(
|
||||
CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, true,
|
||||
opPerformed, true);
|
||||
CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, true, opPerformed, true);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl;
|
||||
}
|
||||
@ -263,8 +254,7 @@ void Q7STestTask::testGpsDaemon() {
|
||||
}
|
||||
|
||||
void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
|
||||
auto fsHandler = ObjectManager::instance()->
|
||||
get<FileSystemHandler>(objects::FILE_SYSTEM_HANDLER);
|
||||
auto fsHandler = ObjectManager::instance()->get<FileSystemHandler>(objects::FILE_SYSTEM_HANDLER);
|
||||
if (fsHandler == nullptr) {
|
||||
sif::warning << "Q7STestTask::testFileSystemHandlerDirect: No FS handler running.."
|
||||
<< std::endl;
|
||||
@ -293,7 +283,6 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
switch (opCode) {
|
||||
case (FsOpCodes::CREATE_EMPTY_FILE_IN_TMP): {
|
||||
// No mount prefix, cause file is created in tmp
|
||||
@ -315,8 +304,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
|
||||
result = fsHandler->removeFile("/tmp", "test.txt", &cfg);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::info << "File removed successfully" << std::endl;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::warning << "File removal failed!" << std::endl;
|
||||
}
|
||||
break;
|
||||
@ -329,8 +317,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
|
||||
ReturnValue_t result = fsHandler->createDirectory("/tmp/", "test", false, &cfg);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::info << "Directory created successfully" << std::endl;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::warning << "Directory creation failed!" << std::endl;
|
||||
}
|
||||
break;
|
||||
@ -340,16 +327,14 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
|
||||
cfg.useMountPrefix = false;
|
||||
if (not std::filesystem::exists("/tmp/test")) {
|
||||
result = fsHandler->createDirectory("/tmp", "test", false, &cfg);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Delete any leftover files to regular dir removal works
|
||||
std::remove("/tmp/test/*");
|
||||
}
|
||||
result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::info << "Directory removed successfully" << std::endl;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::warning << "Directory removal failed!" << std::endl;
|
||||
}
|
||||
break;
|
||||
@ -362,8 +347,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
|
||||
result = fsHandler->removeDirectory("/tmp/", "test", true, &cfg);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::info << "Directory removed recursively successfully" << std::endl;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::warning << "Recursive directory removal failed!" << std::endl;
|
||||
}
|
||||
break;
|
||||
@ -376,8 +360,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
|
||||
result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::info << "Directory removal attempt failed as expected" << std::endl;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::warning << "Directory removal worked when it should not have!" << std::endl;
|
||||
}
|
||||
break;
|
||||
@ -407,8 +390,8 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
|
||||
std::string content = "Hello World\n";
|
||||
// Do not delete file, user can check existence in shell
|
||||
fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg);
|
||||
fsHandler->appendToFile("/tmp/", "test.txt", reinterpret_cast<const uint8_t*>(
|
||||
content.data()), content.size(), 0, &cfg);
|
||||
fsHandler->appendToFile("/tmp/", "test.txt", reinterpret_cast<const uint8_t*>(content.data()),
|
||||
content.size(), 0, &cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ public:
|
||||
Q7STestTask(object_id_t objectId);
|
||||
|
||||
ReturnValue_t initialize() override;
|
||||
|
||||
private:
|
||||
bool doTestSdCard = false;
|
||||
bool doTestScratchApi = false;
|
||||
@ -42,5 +43,4 @@ private:
|
||||
void testFileSystemHandlerDirect(FsOpCodes opCode);
|
||||
};
|
||||
|
||||
|
||||
#endif /* BSP_Q7S_BOARDTEST_Q7STESTTASK_H_ */
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "gnssCallback.h"
|
||||
#include "devices/gpioIds.h"
|
||||
|
||||
#include "devices/gpioIds.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
|
||||
ReturnValue_t gps::triggerGpioResetPin(void* args) {
|
||||
@ -15,8 +15,7 @@ ReturnValue_t gps::triggerGpioResetPin(void *args) {
|
||||
if (resetArgs->gnss1) {
|
||||
gpioId = gpioIds::GNSS_1_NRESET;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
gpioId = gpioIds::GNSS_0_NRESET;
|
||||
}
|
||||
resetArgs->gpioComIF->pullLow(gpioId);
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef BSP_Q7S_CALLBACKS_GNSSCALLBACK_H_
|
||||
#define BSP_Q7S_CALLBACKS_GNSSCALLBACK_H_
|
||||
|
||||
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
|
||||
|
||||
struct ResetArgs {
|
||||
bool gnss1 = false;
|
||||
|
@ -1,22 +1,20 @@
|
||||
#include "rwSpiCallback.h"
|
||||
#include "devices/gpioIds.h"
|
||||
#include "mission/devices/RwHandler.h"
|
||||
|
||||
#include "fsfw_hal/linux/spi/SpiCookie.h"
|
||||
#include "fsfw_hal/linux/UnixFileGuard.h"
|
||||
#include "devices/gpioIds.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw_hal/linux/UnixFileGuard.h"
|
||||
#include "fsfw_hal/linux/spi/SpiCookie.h"
|
||||
#include "mission/devices/RwHandler.h"
|
||||
|
||||
namespace rwSpiCallback {
|
||||
|
||||
ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData,
|
||||
size_t sendLen, void* args) {
|
||||
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
|
||||
RwHandler* handler = reinterpret_cast<RwHandler*>(args);
|
||||
if (handler == nullptr) {
|
||||
sif::error << "rwSpiCallback::spiCallback: Pointer to handler is invalid"
|
||||
<< std::endl;
|
||||
sif::error << "rwSpiCallback::spiCallback: Pointer to handler is invalid" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -153,7 +151,6 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen
|
||||
|
||||
size_t decodedFrameLen = 0;
|
||||
while (decodedFrameLen < replyBufferSize) {
|
||||
|
||||
/** First byte already read in */
|
||||
if (decodedFrameLen != 0) {
|
||||
byteRead = 0;
|
||||
@ -167,8 +164,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen
|
||||
if (byteRead == FLAG_BYTE) {
|
||||
/** Reached end of frame */
|
||||
break;
|
||||
}
|
||||
else if (byteRead == 0x7D) {
|
||||
} else if (byteRead == 0x7D) {
|
||||
if (read(fileDescriptor, &byteRead, 1) != 1) {
|
||||
sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl;
|
||||
result = RwHandler::SPI_READ_FAILURE;
|
||||
@ -178,20 +174,17 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen
|
||||
*(rxBuf + decodedFrameLen) = 0x7E;
|
||||
decodedFrameLen++;
|
||||
continue;
|
||||
}
|
||||
else if (byteRead == 0x5D) {
|
||||
} else if (byteRead == 0x5D) {
|
||||
*(rxBuf + decodedFrameLen) = 0x7D;
|
||||
decodedFrameLen++;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl;
|
||||
closeSpi(gpioId, gpioIF, mutex);
|
||||
result = RwHandler::INVALID_SUBSTITUTE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
*(rxBuf + decodedFrameLen) = byteRead;
|
||||
decodedFrameLen++;
|
||||
continue;
|
||||
@ -232,7 +225,8 @@ void closeSpi (gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) {
|
||||
}
|
||||
}
|
||||
if (mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "rwSpiCallback::closeSpi: Failed to unlock mutex" << std::endl;;
|
||||
}
|
||||
sif::error << "rwSpiCallback::closeSpi: Failed to unlock mutex" << std::endl;
|
||||
;
|
||||
}
|
||||
}
|
||||
} // namespace rwSpiCallback
|
||||
|
@ -2,9 +2,8 @@
|
||||
#define BSP_Q7S_RW_SPI_CALLBACK_H_
|
||||
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw_hal/linux/spi/SpiComIF.h"
|
||||
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
||||
|
||||
#include "fsfw_hal/linux/spi/SpiComIF.h"
|
||||
|
||||
namespace rwSpiCallback {
|
||||
|
||||
@ -43,5 +42,5 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen
|
||||
*/
|
||||
void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex);
|
||||
|
||||
}
|
||||
} // namespace rwSpiCallback
|
||||
#endif /* BSP_Q7S_RW_SPI_CALLBACK_H_ */
|
||||
|
@ -1,36 +1,35 @@
|
||||
#include "CoreController.h"
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "OBSWVersion.h"
|
||||
#include "watchdogConf.h"
|
||||
|
||||
#include "fsfw/FSFWVersion.h"
|
||||
#include "fsfw/timemanager/Stopwatch.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/timemanager/Stopwatch.h"
|
||||
#include "watchdogConf.h"
|
||||
#if OBSW_USE_TMTC_TCP_BRIDGE == 0
|
||||
#include "fsfw/osal/common/UdpTmTcBridge.h"
|
||||
#else
|
||||
#include "fsfw/osal/common/TcpTmTcServer.h"
|
||||
#endif
|
||||
|
||||
#include "bsp_q7s/memory/scratchApi.h"
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "bsp_q7s/memory/scratchApi.h"
|
||||
|
||||
CoreController::Chip CoreController::CURRENT_CHIP = Chip::NO_CHIP;
|
||||
CoreController::Copy CoreController::CURRENT_COPY = Copy::NO_COPY;
|
||||
|
||||
CoreController::CoreController(object_id_t objectId):
|
||||
ExtendedControllerBase(objectId, objects::NO_OBJECT, 5), opDivider(5) {
|
||||
CoreController::CoreController(object_id_t objectId)
|
||||
: ExtendedControllerBase(objectId, objects::NO_OBJECT, 5), opDivider(5) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
try {
|
||||
result = initWatchdogFifo();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "CoreController::CoreController: Watchdog FIFO init failed" <<
|
||||
std::endl;
|
||||
sif::warning << "CoreController::CoreController: Watchdog FIFO init failed" << std::endl;
|
||||
}
|
||||
sdcMan = SdCardManager::instance();
|
||||
if (sdcMan == nullptr) {
|
||||
@ -46,10 +45,8 @@ CoreController::CoreController(object_id_t objectId):
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "CoreController::CoreController: Boot copy init" << std::endl;
|
||||
}
|
||||
}
|
||||
catch(const std::filesystem::filesystem_error& e) {
|
||||
sif::error << "CoreController::CoreController: Failed with exception " <<
|
||||
e.what() << std::endl;
|
||||
} catch (const std::filesystem::filesystem_error &e) {
|
||||
sif::error << "CoreController::CoreController: Failed with exception " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,9 +64,7 @@ ReturnValue_t CoreController::initializeLocalDataPool(localpool::DataPool &local
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase* CoreController::getDataSetHandle(sid_t sid) {
|
||||
return nullptr;
|
||||
}
|
||||
LocalPoolDataSetBase *CoreController::getDataSetHandle(sid_t sid) { return nullptr; }
|
||||
|
||||
ReturnValue_t CoreController::initialize() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
@ -77,7 +72,8 @@ ReturnValue_t CoreController::initialize() {
|
||||
result = scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, 0);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "CoreController::initialize: Setting up alloc failure "
|
||||
"count failed" << std::endl;
|
||||
"count failed"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
sdStateMachine();
|
||||
@ -115,8 +111,7 @@ ReturnValue_t CoreController::initSdCardBlocking() {
|
||||
// Create update status file
|
||||
ReturnValue_t result = sdcMan->updateSdCardStateFile();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "CoreController::initialize: Updating SD card state file failed"
|
||||
<< std::endl;
|
||||
sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl;
|
||||
}
|
||||
#if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE
|
||||
sif::info << "No SD card initialization will be performed" << std::endl;
|
||||
@ -131,8 +126,8 @@ ReturnValue_t CoreController::initSdCardBlocking() {
|
||||
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT
|
||||
determinePreferredSdCard();
|
||||
updateSdInfoOther();
|
||||
sif::info << "Cold redundant SD card configuration, preferred SD card: " <<
|
||||
static_cast<int>(sdInfo.pref) << std::endl;
|
||||
sif::info << "Cold redundant SD card configuration, preferred SD card: "
|
||||
<< static_cast<int>(sdInfo.pref) << std::endl;
|
||||
result = sdColdRedundantBlockingInit();
|
||||
// Update status file
|
||||
sdcMan->updateSdCardStateFile();
|
||||
@ -147,7 +142,6 @@ ReturnValue_t CoreController::initSdCardBlocking() {
|
||||
#endif
|
||||
|
||||
#endif /* Q7S_SD_CARD_CONFIG != Q7S_SD_NONE */
|
||||
|
||||
}
|
||||
|
||||
ReturnValue_t CoreController::sdStateMachine() {
|
||||
@ -165,8 +159,7 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
sdInfo.state = SdStates::IDLE;
|
||||
sdInfo.initFinished = true;
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Still update SD state file
|
||||
#if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE
|
||||
sdInfo.state = SdStates::UPDATE_INFO;
|
||||
@ -180,18 +173,17 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
|
||||
// This lambda checks the non-blocking operation and assigns the new state on success.
|
||||
// It returns true for an operation success and false otherwise
|
||||
auto nonBlockingOpChecking = [&](SdStates newStateOnSuccess,
|
||||
uint16_t maxCycleCount, std::string opPrintout) {
|
||||
auto nonBlockingOpChecking = [&](SdStates newStateOnSuccess, uint16_t maxCycleCount,
|
||||
std::string opPrintout) {
|
||||
SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation);
|
||||
if (status == SdCardManager::OpStatus::SUCCESS) {
|
||||
sdInfo.state = newStateOnSuccess;
|
||||
sdInfo.commandExecuted = false;
|
||||
sdInfo.cycleCount = 0;
|
||||
return true;
|
||||
}
|
||||
else if(sdInfo.cycleCount > 4) {
|
||||
sif::warning << "CoreController::sdInitStateMachine: " << opPrintout <<
|
||||
" takes too long" << std::endl;
|
||||
} else if (sdInfo.cycleCount > 4) {
|
||||
sif::warning << "CoreController::sdInitStateMachine: " << opPrintout << " takes too long"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
@ -206,8 +198,7 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
<< std::endl;
|
||||
}
|
||||
sdInfo.commandExecuted = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
nonBlockingOpChecking(SdStates::SET_STATE_SELF, 4, "Updating SDC file");
|
||||
}
|
||||
}
|
||||
@ -225,32 +216,28 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
sif::warning << "Getting SD card activity status failed" << std::endl;
|
||||
}
|
||||
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT
|
||||
sif::info << "Cold redundant SD card configuration, preferred SD card: " <<
|
||||
static_cast<int>(sdInfo.pref) << std::endl;
|
||||
sif::info << "Cold redundant SD card configuration, preferred SD card: "
|
||||
<< static_cast<int>(sdInfo.pref) << std::endl;
|
||||
#endif
|
||||
if (sdInfo.prefState == sd::SdState::MOUNTED) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
std::string mountString;
|
||||
if (sdInfo.pref == sd::SdCard::SLOT_0) {
|
||||
mountString = SdCardManager::SD_0_MOUNT_POINT;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mountString = SdCardManager::SD_1_MOUNT_POINT;
|
||||
}
|
||||
sif::info << "SD card " << sdInfo.prefChar << " already on and mounted at " <<
|
||||
mountString << std::endl;
|
||||
sif::info << "SD card " << sdInfo.prefChar << " already on and mounted at " << mountString
|
||||
<< std::endl;
|
||||
#endif
|
||||
sdInfo.state = SdStates::DETERMINE_OTHER;
|
||||
}
|
||||
else if(sdInfo.prefState == sd::SdState::OFF) {
|
||||
} else if (sdInfo.prefState == sd::SdState::OFF) {
|
||||
sdCardSetup(sdInfo.pref, sd::SdState::ON, sdInfo.prefChar, false);
|
||||
sdInfo.commandExecuted = true;
|
||||
}
|
||||
else if(sdInfo.prefState == sd::SdState::ON) {
|
||||
} else if (sdInfo.prefState == sd::SdState::ON) {
|
||||
sdInfo.state = SdStates::MOUNT_SELF;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (nonBlockingOpChecking(SdStates::MOUNT_SELF, 10, "Setting SDC state")) {
|
||||
sdInfo.prefState = sd::SdState::ON;
|
||||
currentStateSetter(sdInfo.pref, sd::SdState::ON);
|
||||
@ -262,8 +249,7 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar);
|
||||
sdInfo.commandExecuted = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) {
|
||||
sdInfo.prefState = sd::SdState::MOUNTED;
|
||||
currentStateSetter(sdInfo.pref, sd::SdState::MOUNTED);
|
||||
@ -278,22 +264,18 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT
|
||||
if (sdInfo.otherState == sd::SdState::ON) {
|
||||
sdInfo.state = SdStates::SET_STATE_OTHER;
|
||||
}
|
||||
else if(sdInfo.otherState == sd::SdState::MOUNTED) {
|
||||
} else if (sdInfo.otherState == sd::SdState::MOUNTED) {
|
||||
sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Is already off, update info, but with a small delay
|
||||
sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE;
|
||||
}
|
||||
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
|
||||
if (sdInfo.otherState == sd::SdState::OFF) {
|
||||
sdInfo.state = SdStates::SET_STATE_OTHER;
|
||||
}
|
||||
else if(sdInfo.otherState == sd::SdState::ON) {
|
||||
} else if (sdInfo.otherState == sd::SdState::ON) {
|
||||
sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Is already on and mounted, update info
|
||||
sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE;
|
||||
}
|
||||
@ -306,8 +288,7 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
result = sdCardSetup(sdInfo.other, sd::SdState::OFF, sdInfo.otherChar, false);
|
||||
sdInfo.commandExecuted = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (nonBlockingOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10,
|
||||
"Switching off other SD card")) {
|
||||
sdInfo.otherState = sd::SdState::OFF;
|
||||
@ -318,10 +299,8 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar, false);
|
||||
sdInfo.commandExecuted = true;
|
||||
}
|
||||
else {
|
||||
if(nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10,
|
||||
"Switching on other SD card")) {
|
||||
} else {
|
||||
if (nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10, "Switching on other SD card")) {
|
||||
sdInfo.otherState = sd::SdState::ON;
|
||||
currentStateSetter(sdInfo.other, sd::SdState::ON);
|
||||
}
|
||||
@ -335,8 +314,7 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar);
|
||||
sdInfo.commandExecuted = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (nonBlockingOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card")) {
|
||||
sdInfo.otherState = sd::SdState::ON;
|
||||
currentStateSetter(sdInfo.other, sd::SdState::ON);
|
||||
@ -346,8 +324,7 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
result = sdCardSetup(sdInfo.other, sd::SdState::MOUNTED, sdInfo.otherChar);
|
||||
sdInfo.commandExecuted = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (nonBlockingOpChecking(SdStates::UPDATE_INFO, 4, "Mounting other SD card")) {
|
||||
sdInfo.otherState = sd::SdState::MOUNTED;
|
||||
currentStateSetter(sdInfo.other, sd::SdState::MOUNTED);
|
||||
@ -358,8 +335,7 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
|
||||
if (sdInfo.state == SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE) {
|
||||
sdInfo.state = SdStates::UPDATE_INFO;
|
||||
}
|
||||
else if(sdInfo.state == SdStates::UPDATE_INFO) {
|
||||
} else if (sdInfo.state == SdStates::UPDATE_INFO) {
|
||||
// It is assumed that all tasks are running by the point this section is reached.
|
||||
// Therefore, perform this operation in blocking mode because it does not take long
|
||||
// and the ready state of the SD card is available sooner
|
||||
@ -367,8 +343,7 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
// Update status file
|
||||
result = sdcMan->updateSdCardStateFile();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "CoreController::initialize: Updating SD card state file failed"
|
||||
<< std::endl;
|
||||
sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl;
|
||||
}
|
||||
sdInfo.commandExecuted = false;
|
||||
sdInfo.state = SdStates::IDLE;
|
||||
@ -385,8 +360,7 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
if (sdInfo.state == SdStates::SET_STATE_FROM_COMMAND) {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
executeNextExternalSdCommand();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
checkExternalSdCommandStatus();
|
||||
}
|
||||
}
|
||||
@ -401,44 +375,36 @@ void CoreController::executeNextExternalSdCommand() {
|
||||
if (sdInfo.commandedCard == sd::SdCard::SLOT_0) {
|
||||
sdChar = "0";
|
||||
currentStateOfCard = sdInfo.currentState.first;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sdChar = "1";
|
||||
currentStateOfCard = sdInfo.currentState.second;
|
||||
}
|
||||
if (currentStateOfCard == sd::SdState::OFF) {
|
||||
if (sdInfo.commandedState == sd::SdState::ON) {
|
||||
sdInfo.currentlyCommandedState = sdInfo.commandedState;
|
||||
}
|
||||
else if(sdInfo.commandedState == sd::SdState::MOUNTED) {
|
||||
} else if (sdInfo.commandedState == sd::SdState::MOUNTED) {
|
||||
sdInfo.currentlyCommandedState = sd::SdState::ON;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// SD card is already on target state
|
||||
sdInfo.commandFinished = true;
|
||||
sdInfo.state = SdStates::IDLE;
|
||||
}
|
||||
}
|
||||
else if(currentStateOfCard == sd::SdState::ON) {
|
||||
} else if (currentStateOfCard == sd::SdState::ON) {
|
||||
if (sdInfo.commandedState == sd::SdState::OFF or
|
||||
sdInfo.commandedState == sd::SdState::MOUNTED) {
|
||||
sdInfo.currentlyCommandedState = sdInfo.commandedState;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Already on target state
|
||||
sdInfo.commandFinished = true;
|
||||
sdInfo.state = SdStates::IDLE;
|
||||
}
|
||||
}
|
||||
else if(currentStateOfCard == sd::SdState::MOUNTED) {
|
||||
} else if (currentStateOfCard == sd::SdState::MOUNTED) {
|
||||
if (sdInfo.commandedState == sd::SdState::ON) {
|
||||
sdInfo.currentlyCommandedState = sdInfo.commandedState;
|
||||
}
|
||||
else if(sdInfo.commandedState == sd::SdState::OFF) {
|
||||
} else if (sdInfo.commandedState == sd::SdState::OFF) {
|
||||
// This causes an unmount in sdCardSetup
|
||||
sdInfo.currentlyCommandedState = sd::SdState::ON;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sdInfo.commandFinished = true;
|
||||
}
|
||||
}
|
||||
@ -453,25 +419,23 @@ void CoreController::checkExternalSdCommandStatus() {
|
||||
if (sdInfo.currentlyCommandedState == sdInfo.commandedState) {
|
||||
sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE;
|
||||
sdInfo.commandFinished = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// stay on same state machine state because the target state was not reached yet.
|
||||
sdInfo.cycleCount = 0;
|
||||
}
|
||||
currentStateSetter(sdInfo.commandedCard, sdInfo.currentlyCommandedState);
|
||||
sdInfo.commandExecuted = false;
|
||||
}
|
||||
else if(sdInfo.cycleCount > 4) {
|
||||
} else if (sdInfo.cycleCount > 4) {
|
||||
sif::warning << "CoreController::sdStateMachine: Commanding SD state "
|
||||
"takes too long" << std::endl;
|
||||
"takes too long"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void CoreController::currentStateSetter(sd::SdCard sdCard, sd::SdState newState) {
|
||||
if (sdCard == sd::SdCard::SLOT_0) {
|
||||
sdInfo.currentState.first = newState;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sdInfo.currentState.second = newState;
|
||||
}
|
||||
}
|
||||
@ -482,46 +446,41 @@ ReturnValue_t CoreController::sdCardSetup(sd::SdCard sdCard, sd::SdState targetS
|
||||
sdcMan->setPrintCommandOutput(printOutput);
|
||||
if (sdCard == sd::SdCard::SLOT_0) {
|
||||
mountString = SdCardManager::SD_0_MOUNT_POINT;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mountString = SdCardManager::SD_1_MOUNT_POINT;
|
||||
}
|
||||
|
||||
sd::SdState state = sd::SdState::OFF;
|
||||
if (sdCard == sd::SdCard::SLOT_0) {
|
||||
state = sdInfo.currentState.first;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
state = sdInfo.currentState.second;
|
||||
}
|
||||
if (state == sd::SdState::MOUNTED) {
|
||||
if (targetState == sd::SdState::OFF) {
|
||||
sif::info << "Switching off SD card " << sdChar << std::endl;
|
||||
return sdcMan->switchOffSdCard(sdCard, true, &sdInfo.currentState);
|
||||
}
|
||||
else if(targetState == sd::SdState::ON) {
|
||||
} else if (targetState == sd::SdState::ON) {
|
||||
sif::info << "Unmounting SD card " << sdChar << std::endl;
|
||||
return sdcMan->unmountSdCard(sdCard);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (std::filesystem::exists(mountString)) {
|
||||
sif::info << "SD card " << sdChar << " already on and mounted at " <<
|
||||
mountString << std::endl;
|
||||
sif::info << "SD card " << sdChar << " already on and mounted at " << mountString
|
||||
<< std::endl;
|
||||
return SdCardManager::ALREADY_MOUNTED;
|
||||
}
|
||||
sif::error << "SD card mounted but expected mount point " <<
|
||||
mountString << " not found!" << std::endl;
|
||||
sif::error << "SD card mounted but expected mount point " << mountString << " not found!"
|
||||
<< std::endl;
|
||||
return SdCardManager::MOUNT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (state == sd::SdState::OFF) {
|
||||
if (targetState == sd::SdState::MOUNTED) {
|
||||
sif::info << "Switching on and mounting SD card " << sdChar << " at " <<
|
||||
mountString << std::endl;
|
||||
sif::info << "Switching on and mounting SD card " << sdChar << " at " << mountString
|
||||
<< std::endl;
|
||||
return sdcMan->switchOnSdCard(sdCard, true, &sdInfo.currentState);
|
||||
}
|
||||
else if(targetState == sd::SdState::ON) {
|
||||
} else if (targetState == sd::SdState::ON) {
|
||||
sif::info << "Switching on SD card " << sdChar << std::endl;
|
||||
return sdcMan->switchOnSdCard(sdCard, false, &sdInfo.currentState);
|
||||
}
|
||||
@ -531,19 +490,16 @@ ReturnValue_t CoreController::sdCardSetup(sd::SdCard sdCard, sd::SdState targetS
|
||||
if (targetState == sd::SdState::MOUNTED) {
|
||||
sif::info << "Mounting SD card " << sdChar << " at " << mountString << std::endl;
|
||||
return sdcMan->mountSdCard(sdCard);
|
||||
}
|
||||
else if(targetState == sd::SdState::OFF) {
|
||||
} else if (targetState == sd::SdState::OFF) {
|
||||
sif::info << "Switching off SD card " << sdChar << std::endl;
|
||||
return sdcMan->switchOffSdCard(sdCard, false, &sdInfo.currentState);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::warning << "CoreController::sdCardSetup: Invalid state for this call" << std::endl;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t *data, size_t size) {
|
||||
switch (actionId) {
|
||||
@ -564,8 +520,8 @@ ReturnValue_t CoreController::sdColdRedundantBlockingInit() {
|
||||
|
||||
result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar);
|
||||
if (result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "Setting up preferred card " << sdInfo.otherChar <<
|
||||
" in cold redundant mode failed" << std::endl;
|
||||
sif::warning << "Setting up preferred card " << sdInfo.otherChar
|
||||
<< " in cold redundant mode failed" << std::endl;
|
||||
// Try other SD card and mark set up operation as failed
|
||||
sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar);
|
||||
result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
@ -575,11 +531,11 @@ ReturnValue_t CoreController::sdColdRedundantBlockingInit() {
|
||||
sif::info << "Switching off secondary SD card " << sdInfo.otherChar << std::endl;
|
||||
// Switch off other SD card in cold redundant mode if setting up preferred one worked
|
||||
// without issues
|
||||
ReturnValue_t result2 = sdcMan->switchOffSdCard(sdInfo.other,
|
||||
sdInfo.otherState, &sdInfo.currentState);
|
||||
ReturnValue_t result2 =
|
||||
sdcMan->switchOffSdCard(sdInfo.other, sdInfo.otherState, &sdInfo.currentState);
|
||||
if (result2 != HasReturnvaluesIF::RETURN_OK and result2 != SdCardManager::ALREADY_OFF) {
|
||||
sif::warning << "Switching off secondary SD card " << sdInfo.otherChar <<
|
||||
" in cold redundant mode failed" << std::endl;
|
||||
sif::warning << "Switching off secondary SD card " << sdInfo.otherChar
|
||||
<< " in cold redundant mode failed" << std::endl;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -596,7 +552,6 @@ ReturnValue_t CoreController::incrementAllocationFailureCount() {
|
||||
}
|
||||
|
||||
ReturnValue_t CoreController::initVersionFile() {
|
||||
|
||||
std::string unameFileName = "/tmp/uname_version.txt";
|
||||
// TODO: No -v flag for now. If the kernel version is used, need to cut off first few letters
|
||||
std::string unameCmd = "uname -mnrso > " + unameFileName;
|
||||
@ -607,14 +562,15 @@ ReturnValue_t CoreController::initVersionFile() {
|
||||
std::ifstream unameFile(unameFileName);
|
||||
std::string unameLine;
|
||||
if (not std::getline(unameFile, unameLine)) {
|
||||
sif::warning << "CoreController::versionFileInit: Retrieving uname line failed"
|
||||
<< std::endl;
|
||||
sif::warning << "CoreController::versionFileInit: Retrieving uname line failed" << std::endl;
|
||||
}
|
||||
|
||||
std::string fullObswVersionString = "OBSW: v" + std::to_string(SW_VERSION) + "." +
|
||||
std::to_string(SW_SUBVERSION) + "." + std::to_string(SW_REVISION);
|
||||
std::to_string(SW_SUBVERSION) + "." +
|
||||
std::to_string(SW_REVISION);
|
||||
std::string fullFsfwVersionString = "FSFW: v" + std::to_string(FSFW_VERSION) + "." +
|
||||
std::to_string(FSFW_SUBVERSION) + "." + std::to_string(FSFW_REVISION);
|
||||
std::to_string(FSFW_SUBVERSION) + "." +
|
||||
std::to_string(FSFW_REVISION);
|
||||
std::string systemString = "System: " + unameLine;
|
||||
std::string mountPrefix = SdCardManager::instance()->getCurrentMountPrefix();
|
||||
std::string versionFilePath = mountPrefix + VERSION_FILE;
|
||||
@ -638,28 +594,25 @@ ReturnValue_t CoreController::initVersionFile() {
|
||||
if (idx == 0) {
|
||||
if (currentVersionString != fullObswVersionString) {
|
||||
sif::info << "OBSW version changed" << std::endl;
|
||||
sif::info << "From " << currentVersionString << " to " <<
|
||||
fullObswVersionString << std::endl;
|
||||
sif::info << "From " << currentVersionString << " to " << fullObswVersionString
|
||||
<< std::endl;
|
||||
createNewFile = true;
|
||||
}
|
||||
}
|
||||
else if(idx == 1) {
|
||||
} else if (idx == 1) {
|
||||
if (currentVersionString != fullFsfwVersionString) {
|
||||
sif::info << "FSFW version changed" << std::endl;
|
||||
sif::info << "From " << currentVersionString << " to " <<
|
||||
fullFsfwVersionString << std::endl;
|
||||
sif::info << "From " << currentVersionString << " to " << fullFsfwVersionString
|
||||
<< std::endl;
|
||||
createNewFile = true;
|
||||
}
|
||||
}
|
||||
else if(idx == 2) {
|
||||
} else if (idx == 2) {
|
||||
if (currentVersionString != systemString) {
|
||||
sif::info << "System version changed" << std::endl;
|
||||
sif::info << "Old: " << currentVersionString << std::endl;
|
||||
sif::info << "New: " << systemString << std::endl;
|
||||
createNewFile = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::warning << "Invalid version file! Rewriting it.." << std::endl;
|
||||
createNewFile = true;
|
||||
}
|
||||
@ -680,7 +633,8 @@ ReturnValue_t CoreController::initVersionFile() {
|
||||
}
|
||||
|
||||
ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy, const uint8_t *data, size_t size) {
|
||||
MessageQueueId_t commandedBy,
|
||||
const uint8_t *data, size_t size) {
|
||||
// TODO: Packet definition for clean deserialization
|
||||
// 2 bytes for a and R flag, at least 5 bytes for minimum valid path /tmp with
|
||||
// null termination, at least 7 bytes for minimum target file name /tmp/a with
|
||||
@ -764,8 +718,8 @@ void CoreController::getCurrentBootCopy(Chip &chip, Copy ©) {
|
||||
ReturnValue_t CoreController::initWatchdogFifo() {
|
||||
if (not std::filesystem::exists(watchdog::FIFO_NAME)) {
|
||||
// Still return RETURN_OK for now
|
||||
sif::info << "Watchdog FIFO " << watchdog::FIFO_NAME << " does not exist, can't initiate" <<
|
||||
" watchdog" << std::endl;
|
||||
sif::info << "Watchdog FIFO " << watchdog::FIFO_NAME << " does not exist, can't initiate"
|
||||
<< " watchdog" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
// Open FIFO write only and non-blocking to prevent SW from killing itself.
|
||||
@ -774,10 +728,9 @@ ReturnValue_t CoreController::initWatchdogFifo() {
|
||||
if (errno == ENXIO) {
|
||||
watchdogFifoFd = RETRY_FIFO_OPEN;
|
||||
sif::info << "eive-watchdog not running. FIFO can not be opened" << std::endl;
|
||||
}
|
||||
else {
|
||||
sif::error << "Opening pipe " << watchdog::FIFO_NAME << " write-only failed with " <<
|
||||
errno << ": " << strerror(errno) << std::endl;
|
||||
} else {
|
||||
sif::error << "Opening pipe " << watchdog::FIFO_NAME << " write-only failed with " << errno
|
||||
<< ": " << strerror(errno) << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
@ -806,8 +759,8 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si
|
||||
SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_0);
|
||||
SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_1);
|
||||
// If any boot copies are unprotected
|
||||
ReturnValue_t retval = setBootCopyProtection(Chip::SELF_CHIP, Copy::SELF_COPY,
|
||||
true, protOpPerformed, false);
|
||||
ReturnValue_t retval =
|
||||
setBootCopyProtection(Chip::SELF_CHIP, Copy::SELF_COPY, true, protOpPerformed, false);
|
||||
if (retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) {
|
||||
sif::info << "Running slot was writeprotected before reboot" << std::endl;
|
||||
}
|
||||
@ -822,22 +775,22 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si
|
||||
return HasActionsIF::INVALID_PARAMETERS;
|
||||
}
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::info << "CoreController::actionPerformReboot: Rebooting on " <<
|
||||
static_cast<int>(data[1]) << " " << static_cast<int>(data[2]) << std::endl;
|
||||
sif::info << "CoreController::actionPerformReboot: Rebooting on " << static_cast<int>(data[1])
|
||||
<< " " << static_cast<int>(data[2]) << std::endl;
|
||||
#endif
|
||||
|
||||
// Check that the target chip and copy is writeprotected first
|
||||
generateChipStateFile();
|
||||
// If any boot copies are unprotected, protect them here
|
||||
ReturnValue_t retval = setBootCopyProtection(static_cast<Chip>(data[1]),
|
||||
static_cast<Copy>(data[2]), true, protOpPerformed, false);
|
||||
ReturnValue_t retval = setBootCopyProtection(
|
||||
static_cast<Chip>(data[1]), static_cast<Copy>(data[2]), true, protOpPerformed, false);
|
||||
if (retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) {
|
||||
sif::info << "Target slot was writeprotected before reboot" << std::endl;
|
||||
}
|
||||
|
||||
// The second byte in data is the target chip, the third byte is the target copy
|
||||
std::string cmdString = "xsc_boot_copy " + std::to_string(data[1]) + " " +
|
||||
std::to_string(data[2]);
|
||||
std::string cmdString =
|
||||
"xsc_boot_copy " + std::to_string(data[1]) + " " + std::to_string(data[2]);
|
||||
int result = std::system(cmdString.c_str());
|
||||
if (result != 0) {
|
||||
utility::handleSystemError(result, "CoreController::executeAction");
|
||||
@ -846,8 +799,7 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si
|
||||
return HasActionsIF::EXECUTION_FINISHED;
|
||||
}
|
||||
|
||||
CoreController::~CoreController() {
|
||||
}
|
||||
CoreController::~CoreController() {}
|
||||
|
||||
void CoreController::determinePreferredSdCard() {
|
||||
if (sdInfo.pref == sd::SdCard::NONE) {
|
||||
@ -855,13 +807,14 @@ void CoreController::determinePreferredSdCard() {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result == scratch::KEY_NOT_FOUND) {
|
||||
sif::warning << "CoreController::sdCardInit: "
|
||||
"Preferred SD card not set. Setting to 0" << std::endl;
|
||||
"Preferred SD card not set. Setting to 0"
|
||||
<< std::endl;
|
||||
sdcMan->setPreferredSdCard(sd::SdCard::SLOT_0);
|
||||
sdInfo.pref = sd::SdCard::SLOT_0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::warning << "CoreController::sdCardInit: Could not get preferred SD card"
|
||||
"information from the scratch buffer" << std::endl;
|
||||
"information from the scratch buffer"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -875,22 +828,18 @@ void CoreController::updateSdInfoOther() {
|
||||
sdInfo.prefState = sdInfo.currentState.first;
|
||||
sdInfo.other = sd::SdCard::SLOT_1;
|
||||
|
||||
}
|
||||
else if(sdInfo.pref == sd::SdCard::SLOT_1) {
|
||||
} else if (sdInfo.pref == sd::SdCard::SLOT_1) {
|
||||
sdInfo.prefChar = "1";
|
||||
sdInfo.otherChar = "0";
|
||||
sdInfo.otherState = sdInfo.currentState.first;
|
||||
sdInfo.prefState = sdInfo.currentState.second;
|
||||
sdInfo.other = sd::SdCard::SLOT_0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::warning << "CoreController::updateSdInfoOther: Invalid SD card passed" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
bool CoreController::sdInitFinished() const {
|
||||
return sdInfo.initFinished;
|
||||
}
|
||||
bool CoreController::sdInitFinished() const { return sdInfo.initFinished; }
|
||||
|
||||
ReturnValue_t CoreController::generateChipStateFile() {
|
||||
int result = std::system(CHIP_PROT_SCRIPT);
|
||||
@ -901,8 +850,9 @@ ReturnValue_t CoreController::generateChipStateFile() {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy targetCopy,
|
||||
bool protect, bool& protOperationPerformed, bool updateProtFile) {
|
||||
ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy targetCopy, bool protect,
|
||||
bool &protOperationPerformed,
|
||||
bool updateProtFile) {
|
||||
bool allChips = false;
|
||||
bool allCopies = false;
|
||||
bool selfChip = false;
|
||||
@ -945,8 +895,8 @@ ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy target
|
||||
}
|
||||
|
||||
for (uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) {
|
||||
int result = handleBootCopyProtAtIndex(targetChip, targetCopy, protect,
|
||||
protOperationPerformed, selfChip, selfCopy, allChips, allCopies, arrIdx);
|
||||
int result = handleBootCopyProtAtIndex(targetChip, targetCopy, protect, protOperationPerformed,
|
||||
selfChip, selfCopy, allChips, allCopies, arrIdx);
|
||||
if (result != 0) {
|
||||
break;
|
||||
}
|
||||
@ -958,8 +908,9 @@ ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy target
|
||||
}
|
||||
|
||||
int CoreController::handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect,
|
||||
bool &protOperationPerformed, bool selfChip, bool selfCopy, bool allChips,
|
||||
bool allCopies, uint8_t arrIdx) {
|
||||
bool &protOperationPerformed, bool selfChip,
|
||||
bool selfCopy, bool allChips, bool allCopies,
|
||||
uint8_t arrIdx) {
|
||||
bool currentProt = protArray[arrIdx];
|
||||
std::ostringstream oss;
|
||||
bool performOp = false;
|
||||
@ -978,64 +929,52 @@ int CoreController::handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy,
|
||||
if (arrIdx == 0 or arrIdx == 1) {
|
||||
oss << "0 ";
|
||||
currentChip = Chip::CHIP_0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
oss << "1 ";
|
||||
currentChip = Chip::CHIP_1;
|
||||
}
|
||||
if (arrIdx == 0 or arrIdx == 2) {
|
||||
oss << "0 ";
|
||||
currentCopy = Copy::COPY_0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
oss << "1 ";
|
||||
currentCopy = Copy::COPY_1;
|
||||
}
|
||||
if (protect) {
|
||||
oss << "1";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
oss << "0";
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
if (allChips and allCopies) {
|
||||
performOp = true;
|
||||
}
|
||||
else if(allChips) {
|
||||
if((selfCopy and CURRENT_COPY == targetCopy) or
|
||||
(currentCopy == targetCopy)) {
|
||||
} else if (allChips) {
|
||||
if ((selfCopy and CURRENT_COPY == targetCopy) or (currentCopy == targetCopy)) {
|
||||
performOp = true;
|
||||
}
|
||||
}
|
||||
else if(allCopies) {
|
||||
if((selfChip and CURRENT_COPY == targetCopy) or
|
||||
(currentChip == targetChip)) {
|
||||
} else if (allCopies) {
|
||||
if ((selfChip and CURRENT_COPY == targetCopy) or (currentChip == targetChip)) {
|
||||
performOp = true;
|
||||
}
|
||||
}
|
||||
else if(selfChip and (currentChip == targetChip)) {
|
||||
} else if (selfChip and (currentChip == targetChip)) {
|
||||
if (selfCopy) {
|
||||
if (currentCopy == targetCopy) {
|
||||
performOp = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
performOp = true;
|
||||
}
|
||||
|
||||
}
|
||||
else if(selfCopy and (currentCopy == targetCopy)) {
|
||||
} else if (selfCopy and (currentCopy == targetCopy)) {
|
||||
if (selfChip) {
|
||||
if (currentChip == targetChip) {
|
||||
performOp = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
performOp = true;
|
||||
}
|
||||
}
|
||||
else if((targetChip == currentChip) and (targetCopy == currentCopy)) {
|
||||
} else if ((targetChip == currentChip) and (targetCopy == currentCopy)) {
|
||||
performOp = true;
|
||||
}
|
||||
if (result != 0) {
|
||||
@ -1057,8 +996,8 @@ ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) {
|
||||
if (regenerateChipStateFile) {
|
||||
result = generateChipStateFile();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "CoreController::updateProtInfo: Generating chip state file failed" <<
|
||||
std::endl;
|
||||
sif::warning << "CoreController::updateProtInfo: Generating chip state file failed"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -1075,14 +1014,14 @@ ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) {
|
||||
while (getline(chipStateFile, nextLine)) {
|
||||
ReturnValue_t result = handleProtInfoUpdateLine(nextLine);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "CoreController::updateProtInfo: Protection info update failed!" <<
|
||||
std::endl;
|
||||
sif::warning << "CoreController::updateProtInfo: Protection info update failed!" << std::endl;
|
||||
return result;
|
||||
}
|
||||
++lineCounter;
|
||||
if (lineCounter > 4) {
|
||||
sif::warning << "CoreController::checkAndProtectBootCopy: "
|
||||
"Line counter larger than 4" << std::endl;
|
||||
"Line counter larger than 4"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
@ -1108,8 +1047,7 @@ ReturnValue_t CoreController::handleProtInfoUpdateLine(std::string nextLine) {
|
||||
if (currentChip == Chip::CHIP_0) {
|
||||
if (currentCopy == Copy::COPY_0) {
|
||||
arrayIdx = 0;
|
||||
}
|
||||
else if(currentCopy == Copy::COPY_1) {
|
||||
} else if (currentCopy == Copy::COPY_1) {
|
||||
arrayIdx = 1;
|
||||
}
|
||||
}
|
||||
@ -1117,8 +1055,7 @@ ReturnValue_t CoreController::handleProtInfoUpdateLine(std::string nextLine) {
|
||||
else if (currentChip == Chip::CHIP_1) {
|
||||
if (currentCopy == Copy::COPY_0) {
|
||||
arrayIdx = 2;
|
||||
}
|
||||
else if(currentCopy == Copy::COPY_1) {
|
||||
} else if (currentCopy == Copy::COPY_1) {
|
||||
arrayIdx = 3;
|
||||
}
|
||||
}
|
||||
@ -1126,8 +1063,7 @@ ReturnValue_t CoreController::handleProtInfoUpdateLine(std::string nextLine) {
|
||||
if (wordIdx == 5) {
|
||||
if (word == "unlocked.") {
|
||||
protArray[arrayIdx] = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
protArray[arrayIdx] = true;
|
||||
}
|
||||
}
|
||||
@ -1147,25 +1083,21 @@ void CoreController::performWatchdogControlOperation() {
|
||||
watchdogFifoFd = RETRY_FIFO_OPEN;
|
||||
// No printout for now, would be spam
|
||||
return;
|
||||
}
|
||||
else {
|
||||
sif::error << "Opening pipe " << watchdog::FIFO_NAME <<
|
||||
" write-only failed with " << errno << ": " <<
|
||||
strerror(errno) << std::endl;
|
||||
} else {
|
||||
sif::error << "Opening pipe " << watchdog::FIFO_NAME << " write-only failed with "
|
||||
<< errno << ": " << strerror(errno) << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
sif::info << "Opened " << watchdog::FIFO_NAME << " successfully" << std::endl;
|
||||
}
|
||||
else if(watchdogFifoFd > 0) {
|
||||
} else if (watchdogFifoFd > 0) {
|
||||
// Write to OBSW watchdog FIFO here
|
||||
const char writeChar = 'a';
|
||||
ssize_t writtenBytes = write(watchdogFifoFd, &writeChar, 1);
|
||||
if (writtenBytes < 0) {
|
||||
sif::error << "Errors writing to watchdog FIFO, code " << errno << ": " <<
|
||||
strerror(errno) << std::endl;
|
||||
sif::error << "Errors writing to watchdog FIFO, code " << errno << ": " << strerror(errno)
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,32 +2,19 @@
|
||||
#define BSP_Q7S_CORE_CORECONTROLLER_H_
|
||||
|
||||
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
|
||||
#include "fsfw/controller/ExtendedControllerBase.h"
|
||||
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
|
||||
#include "events/subsystemIdRanges.h"
|
||||
|
||||
#include "fsfw/controller/ExtendedControllerBase.h"
|
||||
|
||||
class Timer;
|
||||
class SdCardManager;
|
||||
|
||||
class CoreController : public ExtendedControllerBase {
|
||||
public:
|
||||
enum Chip: uint8_t {
|
||||
CHIP_0,
|
||||
CHIP_1,
|
||||
NO_CHIP,
|
||||
SELF_CHIP,
|
||||
ALL_CHIP
|
||||
};
|
||||
enum Chip : uint8_t { CHIP_0, CHIP_1, NO_CHIP, SELF_CHIP, ALL_CHIP };
|
||||
|
||||
enum Copy: uint8_t {
|
||||
COPY_0,
|
||||
COPY_1,
|
||||
NO_COPY,
|
||||
SELF_COPY,
|
||||
ALL_COPY
|
||||
};
|
||||
enum Copy : uint8_t { COPY_0, COPY_1, NO_COPY, SELF_COPY, ALL_COPY };
|
||||
|
||||
static constexpr char CHIP_PROT_SCRIPT[] = "/home/root/scripts/get-chip-prot-status.sh";
|
||||
static constexpr char CHIP_STATE_FILE[] = "/tmp/chip_prot_status.txt";
|
||||
@ -38,12 +25,10 @@ public:
|
||||
static constexpr ActionId_t REBOOT_OBC = 32;
|
||||
static constexpr ActionId_t MOUNT_OTHER_COPY = 33;
|
||||
|
||||
|
||||
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;
|
||||
|
||||
static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
|
||||
|
||||
|
||||
CoreController(object_id_t objectId);
|
||||
virtual ~CoreController();
|
||||
|
||||
@ -51,8 +36,8 @@ public:
|
||||
|
||||
ReturnValue_t initializeAfterTaskCreation() override;
|
||||
|
||||
ReturnValue_t executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy, const uint8_t *data, size_t size) override;
|
||||
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size) override;
|
||||
|
||||
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
|
||||
void performControlOperation() override;
|
||||
@ -78,8 +63,8 @@ public:
|
||||
* @param updateProtFile Specify whether the protection info file is updated
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t setBootCopyProtection(Chip targetChip, Copy targetCopy,
|
||||
bool protect, bool& protOperationPerformed, bool updateProtFile = true);
|
||||
ReturnValue_t setBootCopyProtection(Chip targetChip, Copy targetCopy, bool protect,
|
||||
bool& protOperationPerformed, bool updateProtFile = true);
|
||||
|
||||
bool sdInitFinished() const;
|
||||
|
||||
@ -150,8 +135,7 @@ private:
|
||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
||||
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||
uint32_t *msToReachTheMode);
|
||||
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode);
|
||||
|
||||
ReturnValue_t initVersionFile();
|
||||
ReturnValue_t initBootCopy();
|
||||
@ -177,8 +161,8 @@ private:
|
||||
|
||||
ReturnValue_t handleProtInfoUpdateLine(std::string nextLine);
|
||||
int handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect,
|
||||
bool &protOperationPerformed, bool selfChip, bool selfCopy, bool allChips,
|
||||
bool allCopies, uint8_t arrIdx);
|
||||
bool& protOperationPerformed, bool selfChip, bool selfCopy,
|
||||
bool allChips, bool allCopies, uint8_t arrIdx);
|
||||
};
|
||||
|
||||
#endif /* BSP_Q7S_CORE_CORECONTROLLER_H_ */
|
||||
|
@ -1,22 +1,21 @@
|
||||
#include "InitMission.h"
|
||||
#include "ObjectFactory.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "pollingsequence/pollingSequenceFactory.h"
|
||||
|
||||
#include "mission/utility/InitMission.h"
|
||||
|
||||
#include "fsfw/platform.h"
|
||||
#include "fsfw/objectmanager/ObjectManagerIF.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/tasks/FixedTimeslotTaskIF.h"
|
||||
#include "fsfw/tasks/PeriodicTaskIF.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "ObjectFactory.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/objectmanager/ObjectManagerIF.h"
|
||||
#include "fsfw/platform.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "fsfw/tasks/FixedTimeslotTaskIF.h"
|
||||
#include "fsfw/tasks/PeriodicTaskIF.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
#include "mission/utility/InitMission.h"
|
||||
#include "pollingsequence/pollingSequenceFactory.h"
|
||||
|
||||
/* This is configured for linux without CR */
|
||||
#ifdef PLATFORM_UNIX
|
||||
ServiceInterfaceStream sif::debug("DEBUG");
|
||||
@ -33,7 +32,6 @@ ServiceInterfaceStream sif::error("ERROR", true, false, true);
|
||||
ObjectManagerIF* objectManager = nullptr;
|
||||
|
||||
void initmission::initMission() {
|
||||
|
||||
sif::info << "Building global objects.." << std::endl;
|
||||
/* Instantiate global object manager and also create all objects */
|
||||
ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr);
|
||||
@ -168,8 +166,7 @@ void initmission::initTasks() {
|
||||
for (const auto& task : taskVector) {
|
||||
if (task != nullptr) {
|
||||
task->startTask();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::error << "Task in vector " << name << " is invalid!" << std::endl;
|
||||
}
|
||||
}
|
||||
@ -215,21 +212,20 @@ void initmission::initTasks() {
|
||||
}
|
||||
|
||||
void initmission::createPstTasks(TaskFactory& factory,
|
||||
TaskDeadlineMissedFunction missedDeadlineFunc, std::vector<PeriodicTaskIF*> &taskVec) {
|
||||
TaskDeadlineMissedFunction missedDeadlineFunc,
|
||||
std::vector<PeriodicTaskIF*>& taskVec) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
#if BOARD_TE0720 == 0
|
||||
/* Polling Sequence Table Default */
|
||||
#if OBSW_ADD_SPI_TEST_CODE == 0
|
||||
FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask(
|
||||
"PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5,
|
||||
missedDeadlineFunc);
|
||||
"PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc);
|
||||
result = pst::pstSpi(spiPst);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
|
||||
sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
taskVec.push_back(spiPst);
|
||||
}
|
||||
#endif
|
||||
@ -264,8 +260,7 @@ void initmission::createPstTasks(TaskFactory& factory,
|
||||
taskVec.push_back(gomSpacePstTask);
|
||||
#else /* BOARD_TE7020 == 0 */
|
||||
FixedTimeslotTaskIF* pollingSequenceTaskTE0720 = factory.createFixedTimeslotTask(
|
||||
"PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0,
|
||||
missedDeadlineFunc);
|
||||
"PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0, missedDeadlineFunc);
|
||||
result = pst::pollingSequenceTE0720(pollingSequenceTaskTE0720);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "InitMission::initTasks: Creating TE0720 PST failed!" << std::endl;
|
||||
@ -275,7 +270,8 @@ void initmission::createPstTasks(TaskFactory& factory,
|
||||
}
|
||||
|
||||
void initmission::createPusTasks(TaskFactory& factory,
|
||||
TaskDeadlineMissedFunction missedDeadlineFunc, std::vector<PeriodicTaskIF*> &taskVec) {
|
||||
TaskDeadlineMissedFunction missedDeadlineFunc,
|
||||
std::vector<PeriodicTaskIF*>& taskVec) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
/* PUS Services */
|
||||
PeriodicTaskIF* pusVerification = factory.createPeriodicTask(
|
||||
@ -343,9 +339,11 @@ void initmission::createPusTasks(TaskFactory &factory,
|
||||
taskVec.push_back(pusLowPrio);
|
||||
}
|
||||
|
||||
void initmission::createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc,
|
||||
void initmission::createTestTasks(TaskFactory& factory,
|
||||
TaskDeadlineMissedFunction missedDeadlineFunc,
|
||||
std::vector<PeriodicTaskIF*>& taskVec) {
|
||||
#if OBSW_ADD_TEST_TASK == 1 || OBSW_ADD_SPI_TEST_CODE == 1 || (BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1)
|
||||
#if OBSW_ADD_TEST_TASK == 1 || OBSW_ADD_SPI_TEST_CODE == 1 || \
|
||||
(BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1)
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
#endif
|
||||
PeriodicTaskIF* testTask = factory.createPeriodicTask(
|
||||
|
@ -1,9 +1,10 @@
|
||||
#ifndef BSP_Q7S_INITMISSION_H_
|
||||
#define BSP_Q7S_INITMISSION_H_
|
||||
|
||||
#include "fsfw/tasks/Typedef.h"
|
||||
#include <vector>
|
||||
|
||||
#include "fsfw/tasks/Typedef.h"
|
||||
|
||||
class PeriodicTaskIF;
|
||||
class TaskFactory;
|
||||
|
||||
@ -17,6 +18,6 @@ void createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadl
|
||||
std::vector<PeriodicTaskIF*>& taskVec);
|
||||
void createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc,
|
||||
std::vector<PeriodicTaskIF*>& taskVec);
|
||||
};
|
||||
}; // namespace initmission
|
||||
|
||||
#endif /* BSP_Q7S_INITMISSION_H_ */
|
||||
|
@ -1,87 +1,82 @@
|
||||
#include <sstream>
|
||||
#include "ObjectFactory.h"
|
||||
|
||||
#include "bsp_q7s/devices/startracker/StrHelper.h"
|
||||
#include "bsp_q7s/devices/startracker/StarTrackerDefinitions.h"
|
||||
#include <sstream>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "devConf.h"
|
||||
#include "ccsdsConfig.h"
|
||||
#include "busConf.h"
|
||||
#include "tmtc/apid.h"
|
||||
#include "devices/addresses.h"
|
||||
#include "devices/gpioIds.h"
|
||||
#include "tmtc/pusIds.h"
|
||||
#include "devices/powerSwitcherList.h"
|
||||
#include "bsp_q7s/gpio/gpioCallbacks.h"
|
||||
#include "bsp_q7s/core/CoreController.h"
|
||||
#include "bsp_q7s/boardtest/Q7STestTask.h"
|
||||
#include "bsp_q7s/memory/FileSystemHandler.h"
|
||||
#include "bsp_q7s/callbacks/gnssCallback.h"
|
||||
#include "bsp_q7s/callbacks/rwSpiCallback.h"
|
||||
#include "bsp_q7s/core/CoreController.h"
|
||||
#include "bsp_q7s/devices/PlocMemoryDumper.h"
|
||||
#include "bsp_q7s/devices/PlocSupervisorHandler.h"
|
||||
#include "bsp_q7s/devices/PlocUpdater.h"
|
||||
#include "bsp_q7s/devices/PlocMemoryDumper.h"
|
||||
#include "bsp_q7s/devices/startracker/StarTrackerDefinitions.h"
|
||||
#include "bsp_q7s/devices/startracker/StarTrackerHandler.h"
|
||||
#include "bsp_q7s/callbacks/rwSpiCallback.h"
|
||||
#include "bsp_q7s/callbacks/gnssCallback.h"
|
||||
|
||||
#include "linux/devices/SolarArrayDeploymentHandler.h"
|
||||
#include "linux/devices/devicedefinitions/SusDefinitions.h"
|
||||
#include "linux/devices/SusHandler.h"
|
||||
#include "linux/csp/CspCookie.h"
|
||||
#include "bsp_q7s/devices/startracker/StrHelper.h"
|
||||
#include "bsp_q7s/gpio/gpioCallbacks.h"
|
||||
#include "bsp_q7s/memory/FileSystemHandler.h"
|
||||
#include "busConf.h"
|
||||
#include "ccsdsConfig.h"
|
||||
#include "devConf.h"
|
||||
#include "devices/addresses.h"
|
||||
#include "devices/gpioIds.h"
|
||||
#include "devices/powerSwitcherList.h"
|
||||
#include "fsfw/datapoollocal/LocalDataPoolManager.h"
|
||||
#include "fsfw/tmtcpacket/pus/tm.h"
|
||||
#include "fsfw/tmtcservices/CommandingServiceBase.h"
|
||||
#include "fsfw/tmtcservices/PusServiceBase.h"
|
||||
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
||||
#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h"
|
||||
#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h"
|
||||
#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h"
|
||||
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
|
||||
#include "fsfw_hal/linux/i2c/I2cComIF.h"
|
||||
#include "fsfw_hal/linux/i2c/I2cCookie.h"
|
||||
#include "fsfw_hal/linux/spi/SpiComIF.h"
|
||||
#include "fsfw_hal/linux/spi/SpiCookie.h"
|
||||
#include "fsfw_hal/linux/uart/UartComIF.h"
|
||||
#include "fsfw_hal/linux/uart/UartCookie.h"
|
||||
#include "linux/boardtest/SpiTestClass.h"
|
||||
#include "linux/csp/CspComIF.h"
|
||||
|
||||
#include "mission/devices/HeaterHandler.h"
|
||||
#include "linux/csp/CspCookie.h"
|
||||
#include "linux/devices/SolarArrayDeploymentHandler.h"
|
||||
#include "linux/devices/SusHandler.h"
|
||||
#include "linux/devices/devicedefinitions/SusDefinitions.h"
|
||||
#include "mission/core/GenericFactory.h"
|
||||
#include "mission/devices/ACUHandler.h"
|
||||
#include "mission/devices/GPSHyperionHandler.h"
|
||||
#include "mission/devices/GyroADIS1650XHandler.h"
|
||||
#include "mission/devices/HeaterHandler.h"
|
||||
#include "mission/devices/IMTQHandler.h"
|
||||
#include "mission/devices/Max31865PT1000Handler.h"
|
||||
#include "mission/devices/P60DockHandler.h"
|
||||
#include "mission/devices/PCDUHandler.h"
|
||||
#include "mission/devices/PDU1Handler.h"
|
||||
#include "mission/devices/PDU2Handler.h"
|
||||
#include "mission/devices/ACUHandler.h"
|
||||
#include "mission/devices/PCDUHandler.h"
|
||||
#include "mission/devices/P60DockHandler.h"
|
||||
#include "mission/devices/Tmp1075Handler.h"
|
||||
#include "mission/devices/Max31865PT1000Handler.h"
|
||||
#include "mission/devices/GyroADIS1650XHandler.h"
|
||||
#include "mission/devices/IMTQHandler.h"
|
||||
#include "mission/devices/SyrlinksHkHandler.h"
|
||||
#include "mission/devices/PlocMPSoCHandler.h"
|
||||
#include "mission/devices/RadiationSensorHandler.h"
|
||||
#include "mission/devices/RwHandler.h"
|
||||
#include "mission/devices/SyrlinksHkHandler.h"
|
||||
#include "mission/devices/Tmp1075Handler.h"
|
||||
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
|
||||
#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h"
|
||||
#include "mission/devices/devicedefinitions/Max31865Definitions.h"
|
||||
#include "mission/devices/devicedefinitions/PlocMPSoCDefinitions.h"
|
||||
#include "mission/devices/devicedefinitions/RadSensorDefinitions.h"
|
||||
#include "mission/devices/devicedefinitions/Max31865Definitions.h"
|
||||
#include "mission/devices/devicedefinitions/RwDefinitions.h"
|
||||
|
||||
#include "mission/devices/GPSHyperionHandler.h"
|
||||
#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h"
|
||||
#include "mission/tmtc/CCSDSHandler.h"
|
||||
#include "mission/tmtc/VirtualChannel.h"
|
||||
#include "mission/utility/TmFunnel.h"
|
||||
|
||||
#include "fsfw_hal/linux/uart/UartComIF.h"
|
||||
#include "fsfw_hal/linux/uart/UartCookie.h"
|
||||
#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h"
|
||||
#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h"
|
||||
#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h"
|
||||
#include "fsfw_hal/linux/i2c/I2cCookie.h"
|
||||
#include "fsfw_hal/linux/i2c/I2cComIF.h"
|
||||
#include "fsfw_hal/linux/spi/SpiCookie.h"
|
||||
#include "fsfw_hal/linux/spi/SpiComIF.h"
|
||||
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
|
||||
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
||||
|
||||
#include "fsfw/datapoollocal/LocalDataPoolManager.h"
|
||||
#include "fsfw/tmtcservices/CommandingServiceBase.h"
|
||||
#include "fsfw/tmtcservices/PusServiceBase.h"
|
||||
#include "fsfw/tmtcpacket/pus/tm.h"
|
||||
|
||||
#include "linux/boardtest/SpiTestClass.h"
|
||||
#include "tmtc/apid.h"
|
||||
#include "tmtc/pusIds.h"
|
||||
|
||||
#if OBSW_TEST_LIBGPIOD == 1
|
||||
#include "linux/boardtest/LibgpiodTest.h"
|
||||
#endif
|
||||
|
||||
#include <linux/obc/Ptme.h>
|
||||
#include <linux/obc/PdecHandler.h>
|
||||
#include <linux/obc/PapbVcInterface.h>
|
||||
#include <linux/obc/PdecHandler.h>
|
||||
#include <linux/obc/Ptme.h>
|
||||
#include <linux/obc/PtmeConfig.h>
|
||||
#include <linux/obc/PtmeRateSetter.h>
|
||||
#include <linux/obc/TxRateSetterIF.h>
|
||||
@ -89,9 +84,7 @@
|
||||
ResetArgs resetArgsGnss0;
|
||||
ResetArgs resetArgsGnss1;
|
||||
|
||||
void ObjectFactory::setStatics() {
|
||||
Factory::setStaticFrameworkObjectIds();
|
||||
}
|
||||
void ObjectFactory::setStatics() { Factory::setStaticFrameworkObjectIds(); }
|
||||
|
||||
void Factory::setStaticFrameworkObjectIds() {
|
||||
PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR;
|
||||
@ -146,22 +139,22 @@ void ObjectFactory::produce(void* args) {
|
||||
createRtdComponents(gpioComIF);
|
||||
#endif /* OBSW_ADD_RTD_DEVICES == 1 */
|
||||
|
||||
I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE,
|
||||
q7s::I2C_DEFAULT_DEV);
|
||||
I2cCookie* imtqI2cCookie =
|
||||
new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE, q7s::I2C_DEFAULT_DEV);
|
||||
new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie);
|
||||
createReactionWheelComponents(gpioComIF);
|
||||
|
||||
#if OBSW_ADD_PLOC_MPSOC == 1
|
||||
UartCookie* plocMpsocCookie = new UartCookie(objects::PLOC_MPSOC_HANDLER,
|
||||
q7s::UART_PLOC_MPSOC_DEV, UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD,
|
||||
PLOC_MPSOC::MAX_REPLY_SIZE);
|
||||
UartCookie* plocMpsocCookie =
|
||||
new UartCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV,
|
||||
UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, PLOC_MPSOC::MAX_REPLY_SIZE);
|
||||
new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie);
|
||||
#endif /* OBSW_ADD_PLOC_MPSOC == 1 */
|
||||
|
||||
#if OBSW_ADD_PLOC_SUPERVISOR == 1
|
||||
UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER,
|
||||
q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL, uart::PLOC_SUPERVISOR_BAUD,
|
||||
PLOC_SPV::MAX_PACKET_SIZE * 20);
|
||||
UartCookie* plocSupervisorCookie = new UartCookie(
|
||||
objects::PLOC_SUPERVISOR_HANDLER, q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL,
|
||||
uart::PLOC_SUPERVISOR_BAUD, PLOC_SPV::MAX_PACKET_SIZE * 20);
|
||||
plocSupervisorCookie->setNoFixedSizeReply();
|
||||
PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler(
|
||||
objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie);
|
||||
@ -171,13 +164,13 @@ void ObjectFactory::produce(void* args) {
|
||||
new FileSystemHandler(objects::FILE_SYSTEM_HANDLER);
|
||||
|
||||
#if OBSW_ADD_STAR_TRACKER == 1
|
||||
UartCookie* starTrackerCookie = new UartCookie(objects::STAR_TRACKER,
|
||||
q7s::UART_STAR_TRACKER_DEV, UartModes::NON_CANONICAL, uart::STAR_TRACKER_BAUD,
|
||||
StarTracker::MAX_FRAME_SIZE* 2 + 2);
|
||||
UartCookie* starTrackerCookie =
|
||||
new UartCookie(objects::STAR_TRACKER, q7s::UART_STAR_TRACKER_DEV, UartModes::NON_CANONICAL,
|
||||
uart::STAR_TRACKER_BAUD, StarTracker::MAX_FRAME_SIZE * 2 + 2);
|
||||
starTrackerCookie->setNoFixedSizeReply();
|
||||
StrHelper* strHelper = new StrHelper(objects::STR_HELPER);
|
||||
StarTrackerHandler* starTrackerHandler = new StarTrackerHandler(objects::STAR_TRACKER,
|
||||
objects::UART_COM_IF, starTrackerCookie, strHelper);
|
||||
StarTrackerHandler* starTrackerHandler = new StarTrackerHandler(
|
||||
objects::STAR_TRACKER, objects::UART_COM_IF, starTrackerCookie, strHelper);
|
||||
starTrackerHandler->setStartUpImmediately();
|
||||
|
||||
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
|
||||
@ -199,23 +192,23 @@ void ObjectFactory::produce(void* args) {
|
||||
|
||||
void ObjectFactory::createTmpComponents() {
|
||||
#if BOARD_TE0720 == 1
|
||||
I2cCookie* i2cCookieTmp1075tcs1 = new I2cCookie(addresses::TMP1075_TCS_1,
|
||||
TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0"));
|
||||
I2cCookie* i2cCookieTmp1075tcs2 = new I2cCookie(addresses::TMP1075_TCS_2,
|
||||
TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0"));
|
||||
I2cCookie* i2cCookieTmp1075tcs1 =
|
||||
new I2cCookie(addresses::TMP1075_TCS_1, TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0"));
|
||||
I2cCookie* i2cCookieTmp1075tcs2 =
|
||||
new I2cCookie(addresses::TMP1075_TCS_2, TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0"));
|
||||
#else
|
||||
I2cCookie* i2cCookieTmp1075tcs1 = new I2cCookie(addresses::TMP1075_TCS_1,
|
||||
TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV);
|
||||
I2cCookie* i2cCookieTmp1075tcs2 = new I2cCookie(addresses::TMP1075_TCS_2,
|
||||
TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV);
|
||||
I2cCookie* i2cCookieTmp1075tcs1 =
|
||||
new I2cCookie(addresses::TMP1075_TCS_1, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV);
|
||||
I2cCookie* i2cCookieTmp1075tcs2 =
|
||||
new I2cCookie(addresses::TMP1075_TCS_2, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV);
|
||||
#endif
|
||||
|
||||
/* Temperature sensors */
|
||||
Tmp1075Handler* tmp1075Handler_1 = new Tmp1075Handler(objects::TMP1075_HANDLER_1,
|
||||
objects::I2C_COM_IF, i2cCookieTmp1075tcs1);
|
||||
Tmp1075Handler* tmp1075Handler_1 =
|
||||
new Tmp1075Handler(objects::TMP1075_HANDLER_1, objects::I2C_COM_IF, i2cCookieTmp1075tcs1);
|
||||
(void)tmp1075Handler_1;
|
||||
Tmp1075Handler* tmp1075Handler_2 = new Tmp1075Handler(objects::TMP1075_HANDLER_2,
|
||||
objects::I2C_COM_IF, i2cCookieTmp1075tcs2);
|
||||
Tmp1075Handler* tmp1075Handler_2 =
|
||||
new Tmp1075Handler(objects::TMP1075_HANDLER_2, objects::I2C_COM_IF, i2cCookieTmp1075tcs2);
|
||||
(void)tmp1075Handler_2;
|
||||
}
|
||||
|
||||
@ -247,14 +240,13 @@ void ObjectFactory::createPcduComponents() {
|
||||
CspCookie* pdu2CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU2);
|
||||
CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH, addresses::ACU);
|
||||
/* Device Handler */
|
||||
P60DockHandler* p60dockhandler = new P60DockHandler(objects::P60DOCK_HANDLER,
|
||||
objects::CSP_COM_IF, p60DockCspCookie);
|
||||
PDU1Handler* pdu1handler = new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF,
|
||||
pdu1CspCookie);
|
||||
PDU2Handler* pdu2handler = new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF,
|
||||
pdu2CspCookie);
|
||||
ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF,
|
||||
acuCspCookie);
|
||||
P60DockHandler* p60dockhandler =
|
||||
new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie);
|
||||
PDU1Handler* pdu1handler =
|
||||
new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie);
|
||||
PDU2Handler* pdu2handler =
|
||||
new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie);
|
||||
ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, acuCspCookie);
|
||||
new PCDUHandler(objects::PCDU_HANDLER, 50);
|
||||
|
||||
/**
|
||||
@ -276,9 +268,9 @@ void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) {
|
||||
gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, gpio);
|
||||
gpioComIF->addGpios(gpioCookieRadSensor);
|
||||
|
||||
SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieRadSensor = new SpiCookie(
|
||||
addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor);
|
||||
}
|
||||
|
||||
@ -328,64 +320,55 @@ void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF, SpiComI
|
||||
|
||||
gpioComIF->addGpios(gpioCookieSus);
|
||||
|
||||
SpiCookie* spiCookieSus1 = new SpiCookie(addresses::SUS_1, gpio::NO_GPIO,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus2 = new SpiCookie(addresses::SUS_2, gpio::NO_GPIO,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus3 = new SpiCookie(addresses::SUS_3, gpio::NO_GPIO,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus4 = new SpiCookie(addresses::SUS_4, gpio::NO_GPIO,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus5 = new SpiCookie(addresses::SUS_5, gpio::NO_GPIO,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus6 = new SpiCookie(addresses::SUS_6, gpio::NO_GPIO,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus7 = new SpiCookie(addresses::SUS_7, gpio::NO_GPIO,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus8 = new SpiCookie(addresses::SUS_8, gpio::NO_GPIO,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus9 = new SpiCookie(addresses::SUS_9, gpio::NO_GPIO,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus10 = new SpiCookie(addresses::SUS_10, gpio::NO_GPIO,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus11 = new SpiCookie(addresses::SUS_11, gpio::NO_GPIO,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus12 = new SpiCookie(addresses::SUS_12, gpio::NO_GPIO,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus13 = new SpiCookie(addresses::SUS_13, gpio::NO_GPIO,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus1 =
|
||||
new SpiCookie(addresses::SUS_1, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus2 =
|
||||
new SpiCookie(addresses::SUS_2, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus3 =
|
||||
new SpiCookie(addresses::SUS_3, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus4 =
|
||||
new SpiCookie(addresses::SUS_4, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus5 =
|
||||
new SpiCookie(addresses::SUS_5, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus6 =
|
||||
new SpiCookie(addresses::SUS_6, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus7 =
|
||||
new SpiCookie(addresses::SUS_7, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus8 =
|
||||
new SpiCookie(addresses::SUS_8, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus9 =
|
||||
new SpiCookie(addresses::SUS_9, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus10 =
|
||||
new SpiCookie(addresses::SUS_10, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus11 =
|
||||
new SpiCookie(addresses::SUS_11, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus12 =
|
||||
new SpiCookie(addresses::SUS_12, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
SpiCookie* spiCookieSus13 =
|
||||
new SpiCookie(addresses::SUS_13, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ);
|
||||
|
||||
new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF,
|
||||
gpioIds::CS_SUS_1);
|
||||
new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2, gpioComIF,
|
||||
gpioIds::CS_SUS_2);
|
||||
new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3, gpioComIF,
|
||||
gpioIds::CS_SUS_3);
|
||||
new SusHandler(objects::SUS_4, objects::SPI_COM_IF, spiCookieSus4, gpioComIF,
|
||||
gpioIds::CS_SUS_4);
|
||||
new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookieSus5, gpioComIF,
|
||||
gpioIds::CS_SUS_5);
|
||||
new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookieSus6, gpioComIF,
|
||||
gpioIds::CS_SUS_6);
|
||||
new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookieSus7, gpioComIF,
|
||||
gpioIds::CS_SUS_7);
|
||||
new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8, gpioComIF,
|
||||
gpioIds::CS_SUS_8);
|
||||
new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9, gpioComIF,
|
||||
gpioIds::CS_SUS_9);
|
||||
new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF, gpioIds::CS_SUS_1);
|
||||
new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2, gpioComIF, gpioIds::CS_SUS_2);
|
||||
new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3, gpioComIF, gpioIds::CS_SUS_3);
|
||||
new SusHandler(objects::SUS_4, objects::SPI_COM_IF, spiCookieSus4, gpioComIF, gpioIds::CS_SUS_4);
|
||||
new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookieSus5, gpioComIF, gpioIds::CS_SUS_5);
|
||||
new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookieSus6, gpioComIF, gpioIds::CS_SUS_6);
|
||||
new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookieSus7, gpioComIF, gpioIds::CS_SUS_7);
|
||||
new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8, gpioComIF, gpioIds::CS_SUS_8);
|
||||
new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9, gpioComIF, gpioIds::CS_SUS_9);
|
||||
new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookieSus10, gpioComIF,
|
||||
gpioIds::CS_SUS_10);
|
||||
new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieSus11, gpioComIF,
|
||||
@ -402,8 +385,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
|
||||
std::stringstream consumer;
|
||||
GpiodRegularByLineName* gpio = nullptr;
|
||||
consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER;
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, consumer.str(),
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio);
|
||||
|
||||
consumer.str("");
|
||||
@ -438,8 +421,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
|
||||
|
||||
consumer.str("");
|
||||
consumer << "0x" << std::hex << objects::MGM_2_LIS3_HANDLER;
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, consumer.str(),
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpio);
|
||||
|
||||
consumer.str("");
|
||||
@ -464,8 +447,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
|
||||
consumer.str("");
|
||||
consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER;
|
||||
// Enable pins must be pulled low for regular operations
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, consumer.str(),
|
||||
gpio::DIR_OUT, gpio::LOW);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::LOW);
|
||||
gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ENABLE, gpio);
|
||||
|
||||
consumer.str("");
|
||||
@ -477,8 +460,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
|
||||
// Enable pins for GNSS
|
||||
consumer.str("");
|
||||
consumer << "0x" << std::hex << objects::GPS_CONTROLLER;
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_0_ENABLE, consumer.str(),
|
||||
gpio::DIR_OUT, gpio::LOW);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_0_ENABLE, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::LOW);
|
||||
gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_ENABLE, gpio);
|
||||
|
||||
consumer.str("");
|
||||
@ -490,7 +473,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
|
||||
gpioComIF->addGpios(gpioCookieAcsBoard);
|
||||
|
||||
std::string spiDev = q7s::SPI_DEFAULT_DEV;
|
||||
SpiCookie* spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev,
|
||||
SpiCookie* spiCookie =
|
||||
new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev,
|
||||
MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED);
|
||||
auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_COM_IF,
|
||||
spiCookie, spi::LIS3_TRANSITION_DELAY);
|
||||
@ -499,7 +483,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
|
||||
mgmLis3Handler->setToGoToNormalMode(true);
|
||||
#endif
|
||||
|
||||
spiCookie = new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev,
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev,
|
||||
RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED);
|
||||
auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_COM_IF,
|
||||
spiCookie, spi::RM3100_TRANSITION_DELAY);
|
||||
@ -508,7 +493,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
|
||||
mgmRm3100Handler->setToGoToNormalMode(true);
|
||||
#endif
|
||||
|
||||
spiCookie = new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev,
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev,
|
||||
MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED);
|
||||
auto mgmLis3Handler2 = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_COM_IF,
|
||||
spiCookie, spi::LIS3_TRANSITION_DELAY);
|
||||
@ -517,7 +503,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
|
||||
mgmLis3Handler2->setToGoToNormalMode(true);
|
||||
#endif
|
||||
|
||||
spiCookie = new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev,
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev,
|
||||
RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED);
|
||||
mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_COM_IF,
|
||||
spiCookie, spi::RM3100_TRANSITION_DELAY);
|
||||
@ -535,8 +522,9 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
|
||||
spiCookie, ADIS1650X::Type::ADIS16505);
|
||||
adisHandler->setStartUpImmediately();
|
||||
// Gyro 1 Side A
|
||||
spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev,
|
||||
L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE,
|
||||
spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF,
|
||||
spiCookie, spi::L3G_TRANSITION_DELAY);
|
||||
gyroL3gHandler->setStartUpImmediately();
|
||||
@ -551,8 +539,9 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
|
||||
spiCookie, ADIS1650X::Type::ADIS16505);
|
||||
adisHandler->setStartUpImmediately();
|
||||
// Gyro 3 Side B
|
||||
spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev,
|
||||
L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE,
|
||||
spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF,
|
||||
spiCookie, spi::L3G_TRANSITION_DELAY);
|
||||
gyroL3gHandler->setStartUpImmediately();
|
||||
@ -570,13 +559,11 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
|
||||
resetArgsGnss0.gnss1 = false;
|
||||
resetArgsGnss0.gpioComIF = gpioComIF;
|
||||
resetArgsGnss0.waitPeriodMs = 100;
|
||||
auto gpsHandler0 = new GPSHyperionHandler(objects::GPS_CONTROLLER, objects::NO_OBJECT,
|
||||
debugGps);
|
||||
auto gpsHandler0 = new GPSHyperionHandler(objects::GPS_CONTROLLER, objects::NO_OBJECT, debugGps);
|
||||
gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0);
|
||||
}
|
||||
|
||||
void ObjectFactory::createHeaterComponents() {
|
||||
|
||||
GpioCookie* heaterGpiosCookie = new GpioCookie;
|
||||
GpiodRegularByLineName* gpio = nullptr;
|
||||
|
||||
@ -596,24 +583,24 @@ void ObjectFactory::createHeaterComponents() {
|
||||
gpio::LOW);
|
||||
heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpio);
|
||||
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_3, consumer.str(),
|
||||
gpio::DIR_OUT, gpio::LOW);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_3, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::LOW);
|
||||
heaterGpiosCookie->addGpio(gpioIds::HEATER_3, gpio);
|
||||
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_4, consumer.str(),
|
||||
gpio::DIR_OUT, gpio::LOW);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_4, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::LOW);
|
||||
heaterGpiosCookie->addGpio(gpioIds::HEATER_4, gpio);
|
||||
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_5, consumer.str(),
|
||||
gpio::DIR_OUT, gpio::LOW);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_5, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::LOW);
|
||||
heaterGpiosCookie->addGpio(gpioIds::HEATER_5, gpio);
|
||||
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_6, consumer.str(),
|
||||
gpio::DIR_OUT, gpio::LOW);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_6, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::LOW);
|
||||
heaterGpiosCookie->addGpio(gpioIds::HEATER_6, gpio);
|
||||
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_7, consumer.str(),
|
||||
gpio::DIR_OUT, gpio::LOW);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_7, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::LOW);
|
||||
heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio);
|
||||
|
||||
new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie,
|
||||
@ -626,8 +613,8 @@ void ObjectFactory::createSolarArrayDeploymentComponents() {
|
||||
|
||||
std::stringstream consumer;
|
||||
consumer << "0x" << std::hex << objects::SOLAR_ARRAY_DEPL_HANDLER;
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_0,
|
||||
consumer.str(), gpio::DIR_OUT, gpio::LOW);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_0, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::LOW);
|
||||
solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpio);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_1, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::LOW);
|
||||
@ -635,14 +622,15 @@ void ObjectFactory::createSolarArrayDeploymentComponents() {
|
||||
|
||||
// TODO: Find out burn time. For now set to 1000 ms.
|
||||
new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, objects::GPIO_IF,
|
||||
solarArrayDeplCookie, objects::PCDU_HANDLER, pcduSwitches::DEPLOYMENT_MECHANISM,
|
||||
gpioIds::DEPLSA1, gpioIds::DEPLSA2, 1000);
|
||||
solarArrayDeplCookie, objects::PCDU_HANDLER,
|
||||
pcduSwitches::DEPLOYMENT_MECHANISM, gpioIds::DEPLSA1,
|
||||
gpioIds::DEPLSA2, 1000);
|
||||
}
|
||||
|
||||
void ObjectFactory::createSyrlinksComponents() {
|
||||
UartCookie* syrlinksUartCookie = new UartCookie(objects::SYRLINKS_HK_HANDLER,
|
||||
q7s::UART_SYRLINKS_DEV, UartModes::NON_CANONICAL, uart::SYRLINKS_BAUD,
|
||||
SYRLINKS::MAX_REPLY_SIZE);
|
||||
UartCookie* syrlinksUartCookie =
|
||||
new UartCookie(objects::SYRLINKS_HK_HANDLER, q7s::UART_SYRLINKS_DEV, UartModes::NON_CANONICAL,
|
||||
uart::SYRLINKS_BAUD, SYRLINKS::MAX_REPLY_SIZE);
|
||||
syrlinksUartCookie->setParityEven();
|
||||
|
||||
new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie);
|
||||
@ -702,80 +690,87 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) {
|
||||
|
||||
gpioComIF->addGpios(rtdGpioCookie);
|
||||
|
||||
SpiCookie* spiRtdIc0 = new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV,
|
||||
SpiCookie* spiRtdIc0 =
|
||||
new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc1 = new SpiCookie(addresses::RTD_IC_4, gpioIds::RTD_IC_4, q7s::SPI_DEFAULT_DEV,
|
||||
SpiCookie* spiRtdIc1 =
|
||||
new SpiCookie(addresses::RTD_IC_4, gpioIds::RTD_IC_4, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc2 = new SpiCookie(addresses::RTD_IC_5, gpioIds::RTD_IC_5, q7s::SPI_DEFAULT_DEV,
|
||||
SpiCookie* spiRtdIc2 =
|
||||
new SpiCookie(addresses::RTD_IC_5, gpioIds::RTD_IC_5, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC_6, gpioIds::RTD_IC_6, q7s::SPI_DEFAULT_DEV,
|
||||
SpiCookie* spiRtdIc3 =
|
||||
new SpiCookie(addresses::RTD_IC_6, gpioIds::RTD_IC_6, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC_7, gpioIds::RTD_IC_7, q7s::SPI_DEFAULT_DEV,
|
||||
SpiCookie* spiRtdIc4 =
|
||||
new SpiCookie(addresses::RTD_IC_7, gpioIds::RTD_IC_7, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc5 = new SpiCookie(addresses::RTD_IC_8, gpioIds::RTD_IC_8, q7s::SPI_DEFAULT_DEV,
|
||||
SpiCookie* spiRtdIc5 =
|
||||
new SpiCookie(addresses::RTD_IC_8, gpioIds::RTD_IC_8, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc6 = new SpiCookie(addresses::RTD_IC_9, gpioIds::RTD_IC_9, q7s::SPI_DEFAULT_DEV,
|
||||
SpiCookie* spiRtdIc6 =
|
||||
new SpiCookie(addresses::RTD_IC_9, gpioIds::RTD_IC_9, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc7 =
|
||||
new SpiCookie(addresses::RTD_IC_10, gpioIds::RTD_IC_10, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc8 =
|
||||
new SpiCookie(addresses::RTD_IC_11, gpioIds::RTD_IC_11, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc9 =
|
||||
new SpiCookie(addresses::RTD_IC_12, gpioIds::RTD_IC_12, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc10 =
|
||||
new SpiCookie(addresses::RTD_IC_13, gpioIds::RTD_IC_13, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc11 =
|
||||
new SpiCookie(addresses::RTD_IC_14, gpioIds::RTD_IC_14, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc12 =
|
||||
new SpiCookie(addresses::RTD_IC_15, gpioIds::RTD_IC_15, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc13 =
|
||||
new SpiCookie(addresses::RTD_IC_16, gpioIds::RTD_IC_16, std::string(q7s::SPI_DEFAULT_DEV),
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc14 =
|
||||
new SpiCookie(addresses::RTD_IC_17, gpioIds::RTD_IC_17, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc15 =
|
||||
new SpiCookie(addresses::RTD_IC_18, gpioIds::RTD_IC_18, q7s::SPI_DEFAULT_DEV,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc7 = new SpiCookie(addresses::RTD_IC_10, gpioIds::RTD_IC_10,
|
||||
q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE,
|
||||
spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc8 = new SpiCookie(addresses::RTD_IC_11, gpioIds::RTD_IC_11,
|
||||
q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE,
|
||||
spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc9 = new SpiCookie(addresses::RTD_IC_12, gpioIds::RTD_IC_12,
|
||||
q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE,
|
||||
spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc10 = new SpiCookie(addresses::RTD_IC_13, gpioIds::RTD_IC_13,
|
||||
q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE,
|
||||
spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc11 = new SpiCookie(addresses::RTD_IC_14, gpioIds::RTD_IC_14,
|
||||
q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE,
|
||||
spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc12 = new SpiCookie(addresses::RTD_IC_15, gpioIds::RTD_IC_15,
|
||||
q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE,
|
||||
spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc13 = new SpiCookie(addresses::RTD_IC_16, gpioIds::RTD_IC_16,
|
||||
std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE,
|
||||
spi::RTD_MODE, spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc14 = new SpiCookie(addresses::RTD_IC_17, gpioIds::RTD_IC_17,
|
||||
q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE,
|
||||
spi::RTD_SPEED);
|
||||
SpiCookie* spiRtdIc15 = new SpiCookie(addresses::RTD_IC_18, gpioIds::RTD_IC_18,
|
||||
q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE,
|
||||
spi::RTD_SPEED);
|
||||
|
||||
Max31865PT1000Handler* rtdIc0 = new Max31865PT1000Handler(objects::RTD_IC_3, objects::SPI_COM_IF,
|
||||
spiRtdIc0);
|
||||
Max31865PT1000Handler* rtdIc1 = new Max31865PT1000Handler(objects::RTD_IC_4, objects::SPI_COM_IF,
|
||||
spiRtdIc1);
|
||||
Max31865PT1000Handler* rtdIc2 = new Max31865PT1000Handler(objects::RTD_IC_5, objects::SPI_COM_IF,
|
||||
spiRtdIc2);
|
||||
Max31865PT1000Handler* rtdIc3 = new Max31865PT1000Handler(objects::RTD_IC_6, objects::SPI_COM_IF,
|
||||
spiRtdIc3);
|
||||
Max31865PT1000Handler* rtdIc4 = new Max31865PT1000Handler(objects::RTD_IC_7, objects::SPI_COM_IF,
|
||||
spiRtdIc4);
|
||||
Max31865PT1000Handler* rtdIc5 = new Max31865PT1000Handler(objects::RTD_IC_8, objects::SPI_COM_IF,
|
||||
spiRtdIc5);
|
||||
Max31865PT1000Handler* rtdIc6 = new Max31865PT1000Handler(objects::RTD_IC_9, objects::SPI_COM_IF,
|
||||
spiRtdIc6);
|
||||
Max31865PT1000Handler* rtdIc7 = new Max31865PT1000Handler(objects::RTD_IC_10,
|
||||
objects::SPI_COM_IF, spiRtdIc7);
|
||||
Max31865PT1000Handler* rtdIc8 = new Max31865PT1000Handler(objects::RTD_IC_11,
|
||||
objects::SPI_COM_IF, spiRtdIc8);
|
||||
Max31865PT1000Handler* rtdIc9 = new Max31865PT1000Handler(objects::RTD_IC_12,
|
||||
objects::SPI_COM_IF, spiRtdIc9);
|
||||
Max31865PT1000Handler* rtdIc10 = new Max31865PT1000Handler(objects::RTD_IC_13,
|
||||
objects::SPI_COM_IF, spiRtdIc10);
|
||||
Max31865PT1000Handler* rtdIc11 = new Max31865PT1000Handler(objects::RTD_IC_14,
|
||||
objects::SPI_COM_IF, spiRtdIc11);
|
||||
Max31865PT1000Handler* rtdIc12 = new Max31865PT1000Handler(objects::RTD_IC_15,
|
||||
objects::SPI_COM_IF, spiRtdIc12);
|
||||
Max31865PT1000Handler* rtdIc13 = new Max31865PT1000Handler(objects::RTD_IC_16,
|
||||
objects::SPI_COM_IF, spiRtdIc13);
|
||||
Max31865PT1000Handler* rtdIc14 = new Max31865PT1000Handler(objects::RTD_IC_17,
|
||||
objects::SPI_COM_IF, spiRtdIc14);
|
||||
Max31865PT1000Handler* rtdIc15 = new Max31865PT1000Handler(objects::RTD_IC_18,
|
||||
objects::SPI_COM_IF, spiRtdIc15);
|
||||
Max31865PT1000Handler* rtdIc0 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_3, objects::SPI_COM_IF, spiRtdIc0);
|
||||
Max31865PT1000Handler* rtdIc1 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_4, objects::SPI_COM_IF, spiRtdIc1);
|
||||
Max31865PT1000Handler* rtdIc2 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_5, objects::SPI_COM_IF, spiRtdIc2);
|
||||
Max31865PT1000Handler* rtdIc3 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_6, objects::SPI_COM_IF, spiRtdIc3);
|
||||
Max31865PT1000Handler* rtdIc4 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_7, objects::SPI_COM_IF, spiRtdIc4);
|
||||
Max31865PT1000Handler* rtdIc5 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_8, objects::SPI_COM_IF, spiRtdIc5);
|
||||
Max31865PT1000Handler* rtdIc6 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_9, objects::SPI_COM_IF, spiRtdIc6);
|
||||
Max31865PT1000Handler* rtdIc7 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_10, objects::SPI_COM_IF, spiRtdIc7);
|
||||
Max31865PT1000Handler* rtdIc8 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_11, objects::SPI_COM_IF, spiRtdIc8);
|
||||
Max31865PT1000Handler* rtdIc9 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_12, objects::SPI_COM_IF, spiRtdIc9);
|
||||
Max31865PT1000Handler* rtdIc10 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_13, objects::SPI_COM_IF, spiRtdIc10);
|
||||
Max31865PT1000Handler* rtdIc11 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_14, objects::SPI_COM_IF, spiRtdIc11);
|
||||
Max31865PT1000Handler* rtdIc12 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_15, objects::SPI_COM_IF, spiRtdIc12);
|
||||
Max31865PT1000Handler* rtdIc13 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_16, objects::SPI_COM_IF, spiRtdIc13);
|
||||
Max31865PT1000Handler* rtdIc14 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_17, objects::SPI_COM_IF, spiRtdIc14);
|
||||
Max31865PT1000Handler* rtdIc15 =
|
||||
new Max31865PT1000Handler(objects::RTD_IC_18, objects::SPI_COM_IF, spiRtdIc15);
|
||||
|
||||
rtdIc0->setStartUpImmediately();
|
||||
rtdIc1->setStartUpImmediately();
|
||||
@ -822,63 +817,63 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) {
|
||||
std::stringstream consumer;
|
||||
GpiodRegularByLineName* gpio = nullptr;
|
||||
consumer << "0x" << std::hex << objects::RW1;
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_1, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::LOW);
|
||||
gpio =
|
||||
new GpiodRegularByLineName(q7s::gpioNames::EN_RW_1, consumer.str(), gpio::DIR_OUT, gpio::LOW);
|
||||
gpioCookieRw->addGpio(gpioIds::EN_RW1, gpio);
|
||||
consumer.str("");
|
||||
consumer << "0x" << std::hex << objects::RW2;
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_2, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::LOW);
|
||||
gpio =
|
||||
new GpiodRegularByLineName(q7s::gpioNames::EN_RW_2, consumer.str(), gpio::DIR_OUT, gpio::LOW);
|
||||
gpioCookieRw->addGpio(gpioIds::EN_RW2, gpio);
|
||||
consumer.str("");
|
||||
consumer << "0x" << std::hex << objects::RW3;
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_3, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::LOW);
|
||||
gpio =
|
||||
new GpiodRegularByLineName(q7s::gpioNames::EN_RW_3, consumer.str(), gpio::DIR_OUT, gpio::LOW);
|
||||
gpioCookieRw->addGpio(gpioIds::EN_RW3, gpio);
|
||||
consumer.str("");
|
||||
consumer << "0x" << std::hex << objects::RW4;
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_4, consumer.str(), gpio::DIR_OUT,
|
||||
gpio::LOW);
|
||||
gpio =
|
||||
new GpiodRegularByLineName(q7s::gpioNames::EN_RW_4, consumer.str(), gpio::DIR_OUT, gpio::LOW);
|
||||
gpioCookieRw->addGpio(gpioIds::EN_RW4, gpio);
|
||||
|
||||
gpioComIF->addGpios(gpioCookieRw);
|
||||
|
||||
auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, q7s::SPI_RW_DEV,
|
||||
RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback,
|
||||
nullptr);
|
||||
auto rw2SpiCookie = new SpiCookie(addresses::RW2, gpioIds::CS_RW2, q7s::SPI_RW_DEV,
|
||||
RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback,
|
||||
nullptr);
|
||||
auto rw3SpiCookie = new SpiCookie(addresses::RW3, gpioIds::CS_RW3, q7s::SPI_RW_DEV,
|
||||
RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback,
|
||||
nullptr);
|
||||
auto rw4SpiCookie = new SpiCookie(addresses::RW4, gpioIds::CS_RW4, q7s::SPI_RW_DEV,
|
||||
RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback,
|
||||
nullptr);
|
||||
auto rw1SpiCookie =
|
||||
new SpiCookie(addresses::RW1, gpioIds::CS_RW1, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE,
|
||||
spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr);
|
||||
auto rw2SpiCookie =
|
||||
new SpiCookie(addresses::RW2, gpioIds::CS_RW2, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE,
|
||||
spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr);
|
||||
auto rw3SpiCookie =
|
||||
new SpiCookie(addresses::RW3, gpioIds::CS_RW3, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE,
|
||||
spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr);
|
||||
auto rw4SpiCookie =
|
||||
new SpiCookie(addresses::RW4, gpioIds::CS_RW4, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE,
|
||||
spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr);
|
||||
|
||||
auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF,
|
||||
gpioIds::EN_RW1);
|
||||
auto rwHandler1 =
|
||||
new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF, gpioIds::EN_RW1);
|
||||
#if OBSW_DEBUG_RW == 1
|
||||
rwHandler1->setStartUpImmediately();
|
||||
#endif
|
||||
rw1SpiCookie->setCallbackArgs(rwHandler1);
|
||||
|
||||
auto rwHandler2 = new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF,
|
||||
gpioIds::EN_RW2);
|
||||
auto rwHandler2 =
|
||||
new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF, gpioIds::EN_RW2);
|
||||
#if OBSW_DEBUG_RW == 1
|
||||
rwHandler2->setStartUpImmediately();
|
||||
#endif
|
||||
rw2SpiCookie->setCallbackArgs(rwHandler2);
|
||||
|
||||
auto rwHandler3 = new RwHandler(objects::RW3, objects::SPI_COM_IF, rw3SpiCookie, gpioComIF,
|
||||
gpioIds::EN_RW3);
|
||||
auto rwHandler3 =
|
||||
new RwHandler(objects::RW3, objects::SPI_COM_IF, rw3SpiCookie, gpioComIF, gpioIds::EN_RW3);
|
||||
#if OBSW_DEBUG_RW == 1
|
||||
rwHandler3->setStartUpImmediately();
|
||||
#endif
|
||||
rw3SpiCookie->setCallbackArgs(rwHandler3);
|
||||
|
||||
auto rwHandler4 = new RwHandler(objects::RW4, objects::SPI_COM_IF, rw4SpiCookie, gpioComIF,
|
||||
gpioIds::EN_RW4);
|
||||
auto rwHandler4 =
|
||||
new RwHandler(objects::RW4, objects::SPI_COM_IF, rw4SpiCookie, gpioComIF, gpioIds::EN_RW4);
|
||||
#if OBSW_DEBUG_RW == 1
|
||||
rwHandler4->setStartUpImmediately();
|
||||
#endif
|
||||
@ -952,9 +947,9 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) {
|
||||
|
||||
TxRateSetterIF* txRateSetterIF = new PtmeRateSetter(gpioIds::BIT_RATE_SEL, gpioComIF);
|
||||
|
||||
CCSDSHandler* ccsdsHandler = new CCSDSHandler(objects::CCSDS_HANDLER, objects::PTME,
|
||||
objects::CCSDS_PACKET_DISTRIBUTOR, txRateSetterIF, gpioComIF,
|
||||
gpioIds::RS485_EN_TX_CLOCK, gpioIds::RS485_EN_TX_DATA);
|
||||
CCSDSHandler* ccsdsHandler = new CCSDSHandler(
|
||||
objects::CCSDS_HANDLER, objects::PTME, objects::CCSDS_PACKET_DISTRIBUTOR, txRateSetterIF,
|
||||
gpioComIF, gpioIds::RS485_EN_TX_CLOCK, gpioIds::RS485_EN_TX_DATA);
|
||||
|
||||
VirtualChannel* vc = nullptr;
|
||||
vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE);
|
||||
@ -1002,7 +997,6 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) {
|
||||
}
|
||||
|
||||
void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) {
|
||||
|
||||
#if BOARD_TE0720 == 0
|
||||
new Q7STestTask(objects::TEST_TASK);
|
||||
#endif
|
||||
@ -1012,8 +1006,8 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) {
|
||||
/* Configure MIO0 as input */
|
||||
GpiodRegular* testGpio = new GpiodRegular("MIO0", gpio::DIR_OUT, 0, "/amba_pl/gpio@41200000", 0);
|
||||
#elif OBSW_TEST_GPIO_OPEN_BY_LINE_NAME
|
||||
GpiodRegularByLineName* testGpio = new GpiodRegularByLineName("test-name", "gpio-test",
|
||||
gpio::DIR_OUT, 0);
|
||||
GpiodRegularByLineName* testGpio =
|
||||
new GpiodRegularByLineName("test-name", "gpio-test", gpio::DIR_OUT, 0);
|
||||
#else
|
||||
/* Configure MIO0 as input */
|
||||
GpiodRegular* testGpio = new GpiodRegular("gpiochip0", 0, "MIO0", gpio::IN, 0);
|
||||
@ -1025,24 +1019,25 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) {
|
||||
|
||||
#if BOARD_TE0720 == 1 && OBSW_TEST_SUS_HANDLER == 1
|
||||
GpioCookie* gpioCookieSus = new GpioCookie;
|
||||
GpiodRegular* chipSelectSus = new GpiodRegular(std::string("gpiochip1"), 9,
|
||||
std::string("Chip Select Sus Sensor"), gpio::DIR_OUT, 1);
|
||||
GpiodRegular* chipSelectSus = new GpiodRegular(
|
||||
std::string("gpiochip1"), 9, std::string("Chip Select Sus Sensor"), gpio::DIR_OUT, 1);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_1, chipSelectSus);
|
||||
gpioComIF->addGpios(gpioCookieSus);
|
||||
|
||||
SpiCookie* spiCookieSus = new SpiCookie(addresses::SUS_1, std::string("/dev/spidev1.0"),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieSus =
|
||||
new SpiCookie(addresses::SUS_1, std::string("/dev/spidev1.0"), SUS::MAX_CMD_SIZE,
|
||||
spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
|
||||
new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus, gpioComIF,
|
||||
gpioIds::CS_SUS_1);
|
||||
new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus, gpioComIF, gpioIds::CS_SUS_1);
|
||||
#endif
|
||||
|
||||
#if BOARD_TE0720 == 1 && OBSW_TEST_CCSDS_BRIDGE == 1
|
||||
GpioCookie* gpioCookieCcsdsIp = new GpioCookie;
|
||||
GpiodRegular* papbBusyN = new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_VC0"));
|
||||
GpiodRegular* papbBusyN =
|
||||
new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_VC0"));
|
||||
gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN);
|
||||
GpiodRegular* papbEmpty = new GpiodRegular(std::string("gpiochip0"), 1,
|
||||
std::string("PAPBEmpty_VC0"));
|
||||
GpiodRegular* papbEmpty =
|
||||
new GpiodRegular(std::string("gpiochip0"), 1, std::string("PAPBEmpty_VC0"));
|
||||
gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_EMPTY, papbEmpty);
|
||||
gpioComIF->addGpios(gpioCookieCcsdsIp);
|
||||
|
||||
@ -1053,32 +1048,33 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) {
|
||||
|
||||
#if BOARD_TE0720 == 1 && OBSW_TEST_RADIATION_SENSOR_HANDLER == 1
|
||||
GpioCookie* gpioCookieRadSensor = new GpioCookie;
|
||||
GpiodRegular* chipSelectRadSensor = new GpiodRegular(std::string("gpiochip1"), 0,
|
||||
std::string("Chip select radiation sensor"), gpio::DIR_OUT, 1);
|
||||
GpiodRegular* chipSelectRadSensor = new GpiodRegular(
|
||||
std::string("gpiochip1"), 0, std::string("Chip select radiation sensor"), gpio::DIR_OUT, 1);
|
||||
gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, chipSelectRadSensor);
|
||||
gpioComIF->addGpios(gpioCookieRadSensor);
|
||||
|
||||
SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR,
|
||||
std::string("/dev/spidev1.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
|
||||
spi::DEFAULT_MAX_1227_SPEED);
|
||||
SpiCookie* spiCookieRadSensor =
|
||||
new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, std::string("/dev/spidev1.0"),
|
||||
SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
|
||||
|
||||
RadiationSensorHandler* radSensor = new RadiationSensorHandler(objects::RAD_SENSOR,
|
||||
objects::SPI_COM_IF, spiCookieRadSensor);
|
||||
RadiationSensorHandler* radSensor =
|
||||
new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor);
|
||||
radSensor->setStartUpImmediately();
|
||||
#endif
|
||||
|
||||
#if BOARD_TE0720 == 1 && OBSW_ADD_PLOC_MPSOC == 1
|
||||
UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyPS1"), 115200,
|
||||
PLOC_MPSOC::MAX_REPLY_SIZE);
|
||||
UartCookie* plocUartCookie =
|
||||
new UartCookie(std::string("/dev/ttyPS1"), 115200, PLOC_MPSOC::MAX_REPLY_SIZE);
|
||||
/* Testing PlocMPSoCHandler on TE0720-03-1CFA */
|
||||
PlocMPSoCHandler* mpsocPlocHandler = new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF,
|
||||
plocUartCookie);
|
||||
PlocMPSoCHandler* mpsocPlocHandler =
|
||||
new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocUartCookie);
|
||||
mpsocPlocHandler->setStartUpImmediately();
|
||||
#endif
|
||||
|
||||
#if BOARD_TE0720 == 1 && OBSW_TEST_TE7020_HEATER == 1
|
||||
/* Configuration for MIO0 on TE0720-03-1CFA */
|
||||
GpiodRegular* heaterGpio = new GpiodRegular(std::string("gpiochip0"), 0, std::string("MIO0"), gpio::IN, 0);
|
||||
GpiodRegular* heaterGpio =
|
||||
new GpiodRegular(std::string("gpiochip0"), 0, std::string("MIO0"), gpio::IN, 0);
|
||||
GpioCookie* gpioCookie = new GpioCookie;
|
||||
gpioCookie->addGpio(gpioIds::HEATER_0, heaterGpio);
|
||||
new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, gpioCookie, objects::PCDU_HANDLER,
|
||||
@ -1087,9 +1083,9 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) {
|
||||
|
||||
#if BOARD_TE0720 == 1 && OBSW_ADD_PLOC_SUPERVISOR == 1
|
||||
/* Configuration for MIO0 on TE0720-03-1CFA */
|
||||
UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER,
|
||||
std::string("/dev/ttyPS1"), UartModes::NON_CANONICAL, 115200,
|
||||
PLOC_SPV::MAX_PACKET_SIZE * 20);
|
||||
UartCookie* plocSupervisorCookie =
|
||||
new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, std::string("/dev/ttyPS1"),
|
||||
UartModes::NON_CANONICAL, 115200, PLOC_SPV::MAX_PACKET_SIZE * 20);
|
||||
plocSupervisorCookie->setNoFixedSizeReply();
|
||||
PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler(
|
||||
objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie);
|
||||
@ -1099,5 +1095,4 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) {
|
||||
#if OBSW_ADD_SPI_TEST_CODE == 1
|
||||
new SpiTestClass(objects::SPI_TEST, gpioComIF);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,6 @@ void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF);
|
||||
void createCcsdsComponents(LinuxLibgpioIF* gpioComIF);
|
||||
void createTestComponents(LinuxLibgpioIF* gpioComIF);
|
||||
|
||||
};
|
||||
}; // namespace ObjectFactory
|
||||
|
||||
#endif /* BSP_Q7S_OBJECTFACTORY_H_ */
|
||||
|
@ -1,8 +1,5 @@
|
||||
#include "ParameterHandler.h"
|
||||
|
||||
ParameterHandler::ParameterHandler(std::string mountPrefix): mountPrefix(mountPrefix) {
|
||||
}
|
||||
ParameterHandler::ParameterHandler(std::string mountPrefix) : mountPrefix(mountPrefix) {}
|
||||
|
||||
void ParameterHandler::setMountPrefix(std::string prefix) {
|
||||
mountPrefix = prefix;
|
||||
}
|
||||
void ParameterHandler::setMountPrefix(std::string prefix) { mountPrefix = prefix; }
|
||||
|
@ -4,8 +4,6 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
class ParameterHandler {
|
||||
public:
|
||||
ParameterHandler(std::string mountPrefix);
|
||||
@ -13,10 +11,10 @@ public:
|
||||
void setMountPrefix(std::string prefix);
|
||||
|
||||
void setUpDummyParameter();
|
||||
|
||||
private:
|
||||
std::string mountPrefix;
|
||||
DummyParameter dummyParam;
|
||||
};
|
||||
|
||||
|
||||
#endif /* BSP_Q7S_CORE_PARAMETERHANDLER_H_ */
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "obsw.h"
|
||||
#include "OBSWVersion.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "InitMission.h"
|
||||
#include "watchdogConf.h"
|
||||
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
#include "fsfw/FSFWVersion.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
|
||||
#include "InitMission.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "OBSWVersion.h"
|
||||
#include "fsfw/FSFWVersion.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
#include "watchdogConf.h"
|
||||
|
||||
static int OBSW_ALREADY_RUNNING = -2;
|
||||
|
||||
@ -19,17 +19,18 @@ int obsw::obsw() {
|
||||
#else
|
||||
std::cout << "-- Compiled for Linux (TE0720) --" << std::endl;
|
||||
#endif
|
||||
std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION <<
|
||||
"." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << "." <<
|
||||
FSFW_REVISION << "--" << std::endl;
|
||||
std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION << "." << SW_REVISION << ", FSFW v"
|
||||
<< FSFW_VERSION << "." << FSFW_SUBVERSION << "." << FSFW_REVISION << "--" << std::endl;
|
||||
std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl;
|
||||
|
||||
#if Q7S_CHECK_FOR_ALREADY_RUNNING_IMG == 1
|
||||
// Check special file here. This file is created or deleted by the eive-watchdog application
|
||||
// or systemd service!
|
||||
if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) {
|
||||
sif::warning << "File " << watchdog::RUNNING_FILE_NAME << " exists so the software might "
|
||||
"already be running. Check if obsw systemd service has been stopped." << std::endl;
|
||||
sif::warning << "File " << watchdog::RUNNING_FILE_NAME
|
||||
<< " exists so the software might "
|
||||
"already be running. Check if obsw systemd service has been stopped."
|
||||
<< std::endl;
|
||||
return OBSW_ALREADY_RUNNING;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,21 +1,21 @@
|
||||
#include <fsfw/src/fsfw/serialize/SerializeAdapter.h>
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "PlocMemoryDumper.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <fsfw/src/fsfw/serialize/SerializeAdapter.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
PlocMemoryDumper::PlocMemoryDumper(object_id_t objectId) :
|
||||
SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) {
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
|
||||
PlocMemoryDumper::PlocMemoryDumper(object_id_t objectId)
|
||||
: SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE);
|
||||
}
|
||||
|
||||
PlocMemoryDumper::~PlocMemoryDumper() {
|
||||
}
|
||||
PlocMemoryDumper::~PlocMemoryDumper() {}
|
||||
|
||||
ReturnValue_t PlocMemoryDumper::initialize() {
|
||||
|
||||
ReturnValue_t result = SystemObject::initialize();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
@ -38,9 +38,8 @@ ReturnValue_t PlocMemoryDumper::performOperation(uint8_t operationCode) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMemoryDumper::executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy, const uint8_t* data, size_t size) {
|
||||
|
||||
ReturnValue_t PlocMemoryDumper::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size) {
|
||||
if (state != State::IDLE) {
|
||||
return IS_BUSY;
|
||||
}
|
||||
@ -71,13 +70,9 @@ ReturnValue_t PlocMemoryDumper::executeAction(ActionId_t actionId,
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
|
||||
MessageQueueId_t PlocMemoryDumper::getCommandQueue() const {
|
||||
return commandQueue->getId();
|
||||
}
|
||||
MessageQueueId_t PlocMemoryDumper::getCommandQueue() const { return commandQueue->getId(); }
|
||||
|
||||
MessageQueueIF* PlocMemoryDumper::getCommandQueuePtr() {
|
||||
return commandQueue;
|
||||
}
|
||||
MessageQueueIF* PlocMemoryDumper::getCommandQueuePtr() { return commandQueue; }
|
||||
|
||||
void PlocMemoryDumper::readCommandQueue() {
|
||||
CommandMessage message;
|
||||
@ -121,17 +116,12 @@ void PlocMemoryDumper::doStateMachine() {
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMemoryDumper::stepSuccessfulReceived(ActionId_t actionId,
|
||||
uint8_t step) {
|
||||
}
|
||||
void PlocMemoryDumper::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {}
|
||||
|
||||
void PlocMemoryDumper::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
||||
ReturnValue_t returnCode) {
|
||||
}
|
||||
ReturnValue_t returnCode) {}
|
||||
|
||||
void PlocMemoryDumper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
|
||||
|
||||
}
|
||||
void PlocMemoryDumper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {}
|
||||
|
||||
void PlocMemoryDumper::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
switch (pendingCommand) {
|
||||
@ -140,8 +130,7 @@ void PlocMemoryDumper::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
if (mram.endAddress == mram.startAddress) {
|
||||
triggerEvent(MRAM_DUMP_FINISHED);
|
||||
state = State::IDLE;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
state = State::COMMAND_CONSECUTIVE_MRAM_DUMP;
|
||||
}
|
||||
break;
|
||||
@ -153,8 +142,7 @@ void PlocMemoryDumper::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId,
|
||||
ReturnValue_t returnCode) {
|
||||
void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
|
||||
switch (pendingCommand) {
|
||||
case (PLOC_SPV::FIRST_MRAM_DUMP):
|
||||
case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP):
|
||||
@ -179,8 +167,7 @@ void PlocMemoryDumper::commandNextMramDump(ActionId_t dumpCommand) {
|
||||
tempEndAddress = mram.startAddress + MAX_MRAM_DUMP_SIZE;
|
||||
mram.startAddress += MAX_MRAM_DUMP_SIZE;
|
||||
mram.lastStartAddress = tempStartAddress;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
tempStartAddress = mram.startAddress;
|
||||
tempEndAddress = mram.endAddress;
|
||||
mram.startAddress = mram.endAddress;
|
||||
@ -188,8 +175,8 @@ void PlocMemoryDumper::commandNextMramDump(ActionId_t dumpCommand) {
|
||||
|
||||
MemoryParams params(tempStartAddress, tempEndAddress);
|
||||
|
||||
result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER,
|
||||
dumpCommand, ¶ms);
|
||||
result =
|
||||
commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, dumpCommand, ¶ms);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocMemoryDumper::commandNextMramDump: Failed to send mram dump command "
|
||||
<< "with start address " << tempStartAddress << " and end address "
|
||||
@ -203,4 +190,3 @@ void PlocMemoryDumper::commandNextMramDump(ActionId_t dumpCommand) {
|
||||
pendingCommand = dumpCommand;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3,18 +3,18 @@
|
||||
|
||||
#include <bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h>
|
||||
#include <bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "fsfw/action/CommandActionHelper.h"
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "fsfw/action/ActionHelper.h"
|
||||
#include "fsfw/action/HasActionsIF.h"
|
||||
#include "fsfw/action/CommandActionHelper.h"
|
||||
#include "fsfw/action/CommandsActionsIF.h"
|
||||
#include "fsfw/action/HasActionsIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "linux/fsfwconfig/objects/systemObjectList.h"
|
||||
#include "fsfw/tmtcpacket/SpacePacket.h"
|
||||
|
||||
#include "linux/fsfwconfig/objects/systemObjectList.h"
|
||||
|
||||
/**
|
||||
* @brief Because the buffer of the linux tty driver is limited to 2 x 65535 bytes, this class is
|
||||
@ -30,7 +30,6 @@ class PlocMemoryDumper : public SystemObject,
|
||||
public HasReturnvaluesIF,
|
||||
public CommandsActionsIF {
|
||||
public:
|
||||
|
||||
static const ActionId_t NONE = 0;
|
||||
static const ActionId_t DUMP_MRAM = 1;
|
||||
|
||||
@ -50,12 +49,12 @@ public:
|
||||
void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override;
|
||||
|
||||
private:
|
||||
|
||||
static const uint32_t QUEUE_SIZE = 10;
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MEMORY_DUMPER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] The capacity of the MRAM amounts to 512 kB. Thus the maximum address must not be higher than 0x7d000.
|
||||
//! [EXPORT] : [COMMENT] The capacity of the MRAM amounts to 512 kB. Thus the maximum address must
|
||||
//! not be higher than 0x7d000.
|
||||
static const ReturnValue_t MRAM_ADDRESS_TOO_HIGH = MAKE_RETURN_CODE(0xA0);
|
||||
//! [EXPORT] : [COMMENT] The specified end address is lower than the start address
|
||||
static const ReturnValue_t MRAM_INVALID_ADDRESS_COMBINATION = MAKE_RETURN_CODE(0xA1);
|
||||
|
@ -1,26 +1,28 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
#include "PlocSupervisorHandler.h"
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
#include <fsfw/globalfunctions/CRC.h>
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <fsfw/globalfunctions/CRC.h>
|
||||
#include <fsfw/timemanager/Clock.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid,
|
||||
CookieIF * comCookie) :
|
||||
DeviceHandlerBase(objectId, uartComIFid, comCookie), hkset(this), bootStatusReport(this), latchupStatusReport(
|
||||
this) {
|
||||
CookieIF* comCookie)
|
||||
: DeviceHandlerBase(objectId, uartComIFid, comCookie),
|
||||
hkset(this),
|
||||
bootStatusReport(this),
|
||||
latchupStatusReport(this) {
|
||||
if (comCookie == NULL) {
|
||||
sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
PlocSupervisorHandler::~PlocSupervisorHandler() {
|
||||
}
|
||||
PlocSupervisorHandler::~PlocSupervisorHandler() {}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::initialize() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -41,7 +43,6 @@ ReturnValue_t PlocSupervisorHandler::initialize() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void PlocSupervisorHandler::doStartUp() {
|
||||
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
|
||||
setMode(MODE_NORMAL);
|
||||
@ -50,22 +51,18 @@ void PlocSupervisorHandler::doStartUp(){
|
||||
#endif
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::doShutDown(){
|
||||
setMode(_MODE_POWER_DOWN);
|
||||
}
|
||||
void PlocSupervisorHandler::doShutDown() { setMode(_MODE_POWER_DOWN); }
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand(
|
||||
DeviceCommandId_t * id) {
|
||||
ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||
return NOTHING_TO_SEND;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand(
|
||||
DeviceCommandId_t * id){
|
||||
ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
||||
return NOTHING_TO_SEND;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(
|
||||
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
|
||||
ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
switch (deviceCommand) {
|
||||
@ -330,14 +327,12 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
|
||||
PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT);
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t *start,
|
||||
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
||||
DeviceCommandId_t* foundId, size_t* foundLen) {
|
||||
if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP) {
|
||||
*foundId = PLOC_SPV::FIRST_MRAM_DUMP;
|
||||
return parseMramPackets(start, remainingSize, foundLen);
|
||||
}
|
||||
else if (nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) {
|
||||
} else if (nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) {
|
||||
*foundId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP;
|
||||
return parseMramPackets(start, remainingSize, foundLen);
|
||||
}
|
||||
@ -387,7 +382,6 @@ ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t *start,
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
const uint8_t* packet) {
|
||||
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
switch (id) {
|
||||
@ -416,7 +410,8 @@ ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::debug << "PlocSupervisorHandler::interpretDeviceReply: Unknown device reply id" << std::endl;
|
||||
sif::debug << "PlocSupervisorHandler::interpretDeviceReply: Unknown device reply id"
|
||||
<< std::endl;
|
||||
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
|
||||
}
|
||||
}
|
||||
@ -424,17 +419,12 @@ ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
return result;
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::setNormalDatapoolEntriesInvalid(){
|
||||
void PlocSupervisorHandler::setNormalDatapoolEntriesInvalid() {}
|
||||
|
||||
}
|
||||
|
||||
uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){
|
||||
return 500;
|
||||
}
|
||||
uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) {
|
||||
|
||||
localDataPoolMap.emplace(PLOC_SPV::NUM_TMS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(PLOC_SPV::TEMP_PS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(PLOC_SPV::TEMP_PL, new PoolEntry<uint32_t>({0}));
|
||||
@ -478,9 +468,9 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
|
||||
uint8_t expectedReplies, bool useAlternateId,
|
||||
uint8_t expectedReplies,
|
||||
bool useAlternateId,
|
||||
DeviceCommandId_t alternateReplyID) {
|
||||
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
uint8_t enabledReplies = 0;
|
||||
@ -585,15 +575,15 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
|
||||
* Every command causes at least one acknowledgment and one execution report. Therefore both
|
||||
* replies will be enabled here.
|
||||
*/
|
||||
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
|
||||
PLOC_SPV::ACK_REPORT);
|
||||
result =
|
||||
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, PLOC_SPV::ACK_REPORT);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
|
||||
<< PLOC_SPV::ACK_REPORT << " not in replyMap" << std::endl;
|
||||
}
|
||||
|
||||
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
|
||||
PLOC_SPV::EXE_REPORT);
|
||||
result =
|
||||
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, PLOC_SPV::EXE_REPORT);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
|
||||
<< PLOC_SPV::EXE_REPORT << " not in replyMap" << std::endl;
|
||||
@ -603,7 +593,6 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
|
||||
|
||||
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1);
|
||||
|
||||
uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2);
|
||||
@ -616,7 +605,6 @@ ReturnValue_t PlocSupervisorHandler::verifyPacket(const uint8_t* start, size_t f
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
|
||||
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
result = verifyPacket(data, PLOC_SPV::SIZE_ACK_REPORT);
|
||||
@ -635,7 +623,8 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
|
||||
switch (apid) {
|
||||
case PLOC_SPV::APID_ACK_FAILURE: {
|
||||
// TODO: Interpretation of status field in acknowledgment report
|
||||
sif::debug << "PlocSupervisorHandler::handleAckReport: Received Ack failure report" << std::endl;
|
||||
sif::debug << "PlocSupervisorHandler::handleAckReport: Received Ack failure report"
|
||||
<< std::endl;
|
||||
DeviceCommandId_t commandId = getPendingCommand();
|
||||
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
||||
triggerEvent(SUPV_ACK_FAILURE, commandId);
|
||||
@ -651,7 +640,8 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::debug << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report" << std::endl;
|
||||
sif::debug << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report"
|
||||
<< std::endl;
|
||||
result = RETURN_FAILED;
|
||||
break;
|
||||
}
|
||||
@ -661,7 +651,6 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data) {
|
||||
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
result = verifyPacket(data, PLOC_SPV::SIZE_EXE_REPORT);
|
||||
@ -679,14 +668,15 @@ ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data)
|
||||
}
|
||||
case (PLOC_SPV::APID_EXE_FAILURE): {
|
||||
// TODO: Interpretation of status field in execution report
|
||||
sif::error << "PlocSupervisorHandler::handleExecutionReport: Received execution failure report"
|
||||
sif::error
|
||||
<< "PlocSupervisorHandler::handleExecutionReport: Received execution failure report"
|
||||
<< std::endl;
|
||||
DeviceCommandId_t commandId = getPendingCommand();
|
||||
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
||||
triggerEvent(SUPV_EXE_FAILURE, commandId);
|
||||
}
|
||||
else {
|
||||
sif::debug << "PlocSupervisorHandler::handleExecutionReport: Unknown command id" << std::endl;
|
||||
} else {
|
||||
sif::debug << "PlocSupervisorHandler::handleExecutionReport: Unknown command id"
|
||||
<< std::endl;
|
||||
}
|
||||
sendFailureReport(PLOC_SPV::EXE_REPORT, RECEIVED_EXE_FAILURE);
|
||||
disableExeReportReply();
|
||||
@ -706,43 +696,41 @@ ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data)
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
|
||||
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
result = verifyPacket(data, PLOC_SPV::SIZE_HK_REPORT);
|
||||
|
||||
if (result == CRC_FAILURE) {
|
||||
sif::error << "PlocSupervisorHandler::handleHkReport: Hk report has invalid crc"
|
||||
<< std::endl;
|
||||
sif::error << "PlocSupervisorHandler::handleHkReport: Hk report has invalid crc" << std::endl;
|
||||
}
|
||||
|
||||
uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET;
|
||||
hkset.tempPs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
hkset.tempPs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 |
|
||||
*(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.tempPl = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
hkset.tempPl = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 |
|
||||
*(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.tempSup = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
hkset.tempSup = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 |
|
||||
*(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.uptime = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
hkset.uptime = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 |
|
||||
*(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.cpuLoad = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
hkset.cpuLoad = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 |
|
||||
*(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.availableHeap = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
hkset.availableHeap = *(data + offset) << 24 | *(data + offset + 1) << 16 |
|
||||
*(data + offset + 2) << 8 | *(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.numTcs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
hkset.numTcs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 |
|
||||
*(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.numTms = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
hkset.numTms = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 |
|
||||
*(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.socState = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
|
||||
| *(data + offset + 3);
|
||||
hkset.socState = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 |
|
||||
*(data + offset + 3);
|
||||
offset += 4;
|
||||
hkset.nvm0_1_state = *(data + offset);
|
||||
offset += 1;
|
||||
@ -761,7 +749,8 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: temp_sup: " << hkset.tempSup << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: uptime: " << hkset.uptime << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: cpu_load: " << hkset.cpuLoad << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: available_heap: " << hkset.availableHeap << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: available_heap: " << hkset.availableHeap
|
||||
<< std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: num_tcs: " << hkset.numTcs << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: num_tms: " << hkset.numTms << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleHkReport: soc_state: " << hkset.socState << std::endl;
|
||||
@ -780,14 +769,14 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data) {
|
||||
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
result = verifyPacket(data, PLOC_SPV::SIZE_BOOT_STATUS_REPORT);
|
||||
|
||||
if (result == CRC_FAILURE) {
|
||||
sif::error << "PlocSupervisorHandler::handleBootStatusReport: Boot status report has invalid"
|
||||
" crc" << std::endl;
|
||||
" crc"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -835,7 +824,6 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data)
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* data) {
|
||||
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
result = verifyPacket(data, PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT);
|
||||
@ -921,8 +909,8 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da
|
||||
<< latchupStatusReport.timeYear << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Msec: "
|
||||
<< latchupStatusReport.timeMsec << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: isSet: 0x"
|
||||
<< std::hex << latchupStatusReport.timeMsec << std::dec << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: isSet: 0x" << std::hex
|
||||
<< latchupStatusReport.timeMsec << std::dec << std::endl;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
@ -953,15 +941,13 @@ void PlocSupervisorHandler::setNextReplyId() {
|
||||
}
|
||||
|
||||
size_t PlocSupervisorHandler::getNextReplyLength(DeviceCommandId_t commandId) {
|
||||
|
||||
size_t replyLen = 0;
|
||||
|
||||
if (nextReplyId == PLOC_SPV::NONE) {
|
||||
return replyLen;
|
||||
}
|
||||
|
||||
if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP
|
||||
|| nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) {
|
||||
if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP || nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) {
|
||||
/**
|
||||
* Try to read 20 MRAM packets. If reply is larger, the packets will be read with the
|
||||
* next doSendRead call. The command will be as long active as the packet with the sequence
|
||||
@ -978,8 +964,7 @@ size_t PlocSupervisorHandler::getNextReplyLength(DeviceCommandId_t commandId){
|
||||
return replyLen;
|
||||
}
|
||||
replyLen = iter->second.replyLen;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::debug << "PlocSupervisorHandler::getNextReplyLength: No entry for reply with reply id "
|
||||
<< std::hex << nextReplyId << " in deviceReplyMap" << std::endl;
|
||||
}
|
||||
@ -987,8 +972,8 @@ size_t PlocSupervisorHandler::getNextReplyLength(DeviceCommandId_t commandId){
|
||||
return replyLen;
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) {
|
||||
|
||||
void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
|
||||
DeviceCommandId_t replyId) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
if (wiretappingMode == RAW) {
|
||||
@ -1043,8 +1028,8 @@ void PlocSupervisorHandler::prepareDisableHk() {
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t* commandData) {
|
||||
uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8
|
||||
| *(commandData + 3);
|
||||
uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 |
|
||||
*(commandData + 3);
|
||||
PLOC_SPV::SetBootTimeout packet(timeout);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
}
|
||||
@ -1073,8 +1058,8 @@ ReturnValue_t PlocSupervisorHandler::prepareWatchdogsConfigTimeoutCmd(const uint
|
||||
if (watchdog > 2) {
|
||||
return INVALID_WATCHDOG;
|
||||
}
|
||||
uint32_t timeout = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16
|
||||
| *(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
||||
uint32_t timeout = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 |
|
||||
*(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
||||
if (timeout < 1000 || timeout > 360000) {
|
||||
return INVALID_WATCHDOG_TIMEOUT;
|
||||
}
|
||||
@ -1115,8 +1100,8 @@ ReturnValue_t PlocSupervisorHandler::prepareAutoCalibrateAlertCmd(const uint8_t*
|
||||
uint8_t offset = 0;
|
||||
uint8_t latchupId = *commandData;
|
||||
offset += 1;
|
||||
uint32_t mg = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16
|
||||
| *(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
||||
uint32_t mg = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 |
|
||||
*(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
||||
if (latchupId > 6) {
|
||||
return INVALID_LATCHUP_ID;
|
||||
}
|
||||
@ -1141,8 +1126,8 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAlertLimitCmd(const uint8_t* comm
|
||||
uint8_t offset = 0;
|
||||
uint8_t latchupId = *commandData;
|
||||
offset += 1;
|
||||
uint32_t dutycycle = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16
|
||||
| *(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
||||
uint32_t dutycycle = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 |
|
||||
*(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
||||
if (latchupId > 6) {
|
||||
return INVALID_LATCHUP_ID;
|
||||
}
|
||||
@ -1152,8 +1137,8 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAlertLimitCmd(const uint8_t* comm
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::prepareSetAdcSweetPeriodCmd(const uint8_t* commandData) {
|
||||
uint32_t sweepPeriod = *(commandData) << 24 | *(commandData + 1) << 16
|
||||
| *(commandData + 2) << 8 | *(commandData + 3);
|
||||
uint32_t sweepPeriod = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 |
|
||||
*(commandData + 3);
|
||||
if (sweepPeriod < 21) {
|
||||
return SWEEP_PERIOD_TOO_SMALL;
|
||||
}
|
||||
@ -1178,8 +1163,8 @@ void PlocSupervisorHandler::prepareSetAdcWindowAndStrideCmd(const uint8_t* comma
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::prepareSetAdcThresholdCmd(const uint8_t* commandData) {
|
||||
uint32_t threshold = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8
|
||||
| *(commandData + 3);
|
||||
uint32_t threshold = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 |
|
||||
*(commandData + 3);
|
||||
PLOC_SPV::SetAdcThreshold packet(threshold);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
}
|
||||
@ -1275,7 +1260,6 @@ void PlocSupervisorHandler::packetToOutBuffer(uint8_t* packetData, size_t fullSi
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::disableAllReplies() {
|
||||
|
||||
DeviceReplyMap::iterator iter;
|
||||
|
||||
/* Disable ack reply */
|
||||
@ -1305,7 +1289,6 @@ void PlocSupervisorHandler::disableAllReplies() {
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) {
|
||||
|
||||
DeviceReplyIter iter = deviceReplyMap.find(replyId);
|
||||
|
||||
if (iter == deviceReplyMap.end()) {
|
||||
@ -1316,7 +1299,8 @@ void PlocSupervisorHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnV
|
||||
DeviceCommandInfo* info = &(iter->second.command->second);
|
||||
|
||||
if (info == nullptr) {
|
||||
sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply has no active command" << std::endl;
|
||||
sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply has no active command"
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1367,7 +1351,6 @@ ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t *packet, siz
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket(DeviceCommandId_t id) {
|
||||
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
|
||||
// Prepare packet for downlink
|
||||
@ -1380,8 +1363,7 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket(DeviceCommandId_t id)
|
||||
}
|
||||
handleMramDumpFile(id);
|
||||
if (downlinkMramDump == true) {
|
||||
handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1,
|
||||
id);
|
||||
handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1, id);
|
||||
}
|
||||
packetInBuffer = false;
|
||||
receivedMramDumpPackets++;
|
||||
@ -1426,16 +1408,15 @@ void PlocSupervisorHandler::increaseExpectedMramReplies(DeviceCommandId_t id) {
|
||||
return;
|
||||
}
|
||||
uint8_t sequenceFlags = spacePacketBuffer[2] >> 6;
|
||||
if (sequenceFlags != static_cast<uint8_t>(PLOC_SPV::SequenceFlags::LAST_PKT)
|
||||
&& (sequenceFlags != static_cast<uint8_t>(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) {
|
||||
if (sequenceFlags != static_cast<uint8_t>(PLOC_SPV::SequenceFlags::LAST_PKT) &&
|
||||
(sequenceFlags != static_cast<uint8_t>(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) {
|
||||
// Command expects at least one MRAM packet more and the execution report
|
||||
info->expectedReplies = 2;
|
||||
// Wait maximum of 2 cycles for next MRAM packet
|
||||
mramReplyInfo->delayCycles = 2;
|
||||
// Also adapting delay cycles for execution report
|
||||
exeReplyInfo->delayCycles = 3;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Command expects the execution report
|
||||
info->expectedReplies = 1;
|
||||
mramReplyInfo->delayCycles = 0;
|
||||
@ -1456,8 +1437,8 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) {
|
||||
uint16_t packetLen = readSpacePacketLength(spacePacketBuffer);
|
||||
uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer);
|
||||
if (id == PLOC_SPV::FIRST_MRAM_DUMP) {
|
||||
if (sequenceFlags == static_cast<uint8_t>(PLOC_SPV::SequenceFlags::FIRST_PKT)
|
||||
|| (sequenceFlags == static_cast<uint8_t>(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) {
|
||||
if (sequenceFlags == static_cast<uint8_t>(PLOC_SPV::SequenceFlags::FIRST_PKT) ||
|
||||
(sequenceFlags == static_cast<uint8_t>(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) {
|
||||
result = createMramDumpFile();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
@ -1523,8 +1504,8 @@ ReturnValue_t PlocSupervisorHandler::getTimeStampString(std::string& timeStamp)
|
||||
<< std::endl;
|
||||
return GET_TIME_FAILURE;
|
||||
}
|
||||
timeStamp = std::to_string(time.year) + "-" + std::to_string(time.month) + "-"
|
||||
+ std::to_string(time.day) + "--" + std::to_string(time.hour) + "-"
|
||||
+ std::to_string(time.minute) + "-" + std::to_string(time.second);
|
||||
timeStamp = std::to_string(time.year) + "-" + std::to_string(time.month) + "-" +
|
||||
std::to_string(time.day) + "--" + std::to_string(time.hour) + "-" +
|
||||
std::to_string(time.minute) + "-" + std::to_string(time.second);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
#ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
|
||||
#define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
|
||||
|
||||
#include "devicedefinitions/PlocSupervisorDefinitions.h"
|
||||
#include <bsp_q7s/memory/SdCardManager.h>
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||
#include <fsfw_hal/linux/uart/UartComIF.h>
|
||||
|
||||
#include "devicedefinitions/PlocSupervisorDefinitions.h"
|
||||
|
||||
/**
|
||||
* @brief This is the device handler for the supervisor of the PLOC which is programmed by
|
||||
* Thales.
|
||||
@ -21,7 +21,6 @@
|
||||
*/
|
||||
class PlocSupervisorHandler : public DeviceHandlerBase {
|
||||
public:
|
||||
|
||||
PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie);
|
||||
virtual ~PlocSupervisorHandler();
|
||||
|
||||
@ -33,12 +32,11 @@ protected:
|
||||
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
|
||||
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
|
||||
void fillCommandAndReplyMap() override;
|
||||
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t * commandData,size_t commandDataLen) override;
|
||||
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize,
|
||||
DeviceCommandId_t *foundId, size_t *foundLen) override;
|
||||
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
|
||||
const uint8_t *packet) override;
|
||||
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
|
||||
size_t commandDataLen) override;
|
||||
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
|
||||
size_t* foundLen) override;
|
||||
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
|
||||
void setNormalDatapoolEntriesInvalid() override;
|
||||
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
@ -49,7 +47,6 @@ protected:
|
||||
size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
|
||||
|
||||
private:
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_SUPERVISOR_HANDLER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Space Packet received from PLOC supervisor has invalid CRC
|
||||
@ -64,25 +61,32 @@ private:
|
||||
static const ReturnValue_t GET_TIME_FAILURE = MAKE_RETURN_CODE(0xA4);
|
||||
//! [EXPORT] : [COMMENT] Invalid communication interface specified
|
||||
static const ReturnValue_t INVALID_UART_COM_IF = MAKE_RETURN_CODE(0xA5);
|
||||
//! [EXPORT] : [COMMENT] Received command with invalid watchdog parameter. Valid watchdogs are 0 for PS, 1 for PL and 2 for INT
|
||||
//! [EXPORT] : [COMMENT] Received command with invalid watchdog parameter. Valid watchdogs are 0
|
||||
//! for PS, 1 for PL and 2 for INT
|
||||
static const ReturnValue_t INVALID_WATCHDOG = MAKE_RETURN_CODE(0xA6);
|
||||
//! [EXPORT] : [COMMENT] Received watchdog timeout config command with invalid timeout. Valid timeouts must be in the range between 1000 and 360000 ms.
|
||||
//! [EXPORT] : [COMMENT] Received watchdog timeout config command with invalid timeout. Valid
|
||||
//! timeouts must be in the range between 1000 and 360000 ms.
|
||||
static const ReturnValue_t INVALID_WATCHDOG_TIMEOUT = MAKE_RETURN_CODE(0xA7);
|
||||
//! [EXPORT] : [COMMENT] Received latchup config command with invalid latchup ID
|
||||
static const ReturnValue_t INVALID_LATCHUP_ID = MAKE_RETURN_CODE(0xA8);
|
||||
//! [EXPORT] : [COMMENT] Received set adc sweep period command with invalid sweep period. Must be larger than 21.
|
||||
//! [EXPORT] : [COMMENT] Received set adc sweep period command with invalid sweep period. Must be
|
||||
//! larger than 21.
|
||||
static const ReturnValue_t SWEEP_PERIOD_TOO_SMALL = MAKE_RETURN_CODE(0xA9);
|
||||
//! [EXPORT] : [COMMENT] Receive auto EM test command with invalid test param. Valid params are 1 and 2.
|
||||
//! [EXPORT] : [COMMENT] Receive auto EM test command with invalid test param. Valid params are 1
|
||||
//! and 2.
|
||||
static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xAA);
|
||||
//! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed.
|
||||
static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAB);
|
||||
//! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe commands are invalid (e.g. start address bigger than stop address)
|
||||
//! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe
|
||||
//! commands are invalid (e.g. start address bigger than stop address)
|
||||
static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAC);
|
||||
//! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with other apid.
|
||||
//! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with
|
||||
//! other apid.
|
||||
static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAD);
|
||||
//! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist
|
||||
static const ReturnValue_t PATH_DOES_NOT_EXIST = MAKE_RETURN_CODE(0xAE);
|
||||
//! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have been created with the reception of the first dump packet.
|
||||
//! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have
|
||||
//! been created with the reception of the first dump packet.
|
||||
static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAF);
|
||||
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPERVISOR_HANDLER;
|
||||
@ -258,7 +262,6 @@ private:
|
||||
void prepareSetGpioCmd(const uint8_t* commandData);
|
||||
void prepareReadGpioCmd(const uint8_t* commandData);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Copies the content of a space packet to the command buffer.
|
||||
*/
|
||||
|
@ -1,17 +1,17 @@
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "PlocUpdater.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
PlocUpdater::PlocUpdater(object_id_t objectId) :
|
||||
SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) {
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
|
||||
PlocUpdater::PlocUpdater(object_id_t objectId)
|
||||
: SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE);
|
||||
}
|
||||
|
||||
PlocUpdater::~PlocUpdater() {
|
||||
}
|
||||
PlocUpdater::~PlocUpdater() {}
|
||||
|
||||
ReturnValue_t PlocUpdater::initialize() {
|
||||
#if BOARD_TE0720 == 0
|
||||
@ -39,8 +39,8 @@ ReturnValue_t PlocUpdater::performOperation(uint8_t operationCode) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy, const uint8_t* data, size_t size) {
|
||||
ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size) {
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
|
||||
if (state != State::IDLE) {
|
||||
@ -99,13 +99,9 @@ ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId,
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
|
||||
MessageQueueId_t PlocUpdater::getCommandQueue() const {
|
||||
return commandQueue->getId();
|
||||
}
|
||||
MessageQueueId_t PlocUpdater::getCommandQueue() const { return commandQueue->getId(); }
|
||||
|
||||
MessageQueueIF* PlocUpdater::getCommandQueuePtr() {
|
||||
return commandQueue;
|
||||
}
|
||||
MessageQueueIF* PlocUpdater::getCommandQueuePtr() { return commandQueue; }
|
||||
|
||||
void PlocUpdater::readCommandQueue() {
|
||||
CommandMessage message;
|
||||
@ -167,19 +163,19 @@ ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) {
|
||||
|
||||
#if BOARD_TE0720 == 0
|
||||
// Check if file is stored on SD card and if associated SD card is mounted
|
||||
if (std::string(reinterpret_cast<const char*>(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_0_MOUNT_POINT)) {
|
||||
if (std::string(reinterpret_cast<const char*>(data), SD_PREFIX_LENGTH) ==
|
||||
std::string(SdCardManager::SD_0_MOUNT_POINT)) {
|
||||
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
|
||||
sif::warning << "PlocUpdater::getImageLocation: SD card 0 not mounted" << std::endl;
|
||||
return SD_NOT_MOUNTED;
|
||||
}
|
||||
}
|
||||
else if (std::string(reinterpret_cast<const char*>(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_1_MOUNT_POINT)) {
|
||||
} else if (std::string(reinterpret_cast<const char*>(data), SD_PREFIX_LENGTH) ==
|
||||
std::string(SdCardManager::SD_1_MOUNT_POINT)) {
|
||||
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
|
||||
sif::warning << "PlocUpdater::getImageLocation: SD card 1 not mounted" << std::endl;
|
||||
return SD_NOT_MOUNTED;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// update image not stored on SD card
|
||||
}
|
||||
#endif /* BOARD_TE0720 == 0 */
|
||||
@ -193,17 +189,11 @@ ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId,
|
||||
uint8_t step) {
|
||||
}
|
||||
void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {}
|
||||
|
||||
void PlocUpdater::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
||||
ReturnValue_t returnCode) {
|
||||
}
|
||||
void PlocUpdater::stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) {}
|
||||
|
||||
void PlocUpdater::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
|
||||
|
||||
}
|
||||
void PlocUpdater::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {}
|
||||
|
||||
void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
switch (pendingCommand) {
|
||||
@ -214,8 +204,7 @@ void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
if (remainingPackets == 0) {
|
||||
packetsSent = 0; // Reset packets sent variable for next update sequence
|
||||
state = State::UPDATE_VERIFY;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
state = State::UPDATE_TRANSFER;
|
||||
}
|
||||
break;
|
||||
@ -232,8 +221,7 @@ void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
}
|
||||
}
|
||||
|
||||
void PlocUpdater::completionFailedReceived(ActionId_t actionId,
|
||||
ReturnValue_t returnCode) {
|
||||
void PlocUpdater::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
|
||||
switch (pendingCommand) {
|
||||
case (PLOC_SPV::UPDATE_AVAILABLE): {
|
||||
triggerEvent(UPDATE_AVAILABLE_FAILED);
|
||||
@ -248,8 +236,7 @@ void PlocUpdater::completionFailedReceived(ActionId_t actionId,
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "PlocUpdater::completionFailedReceived: Invalid pending command "
|
||||
<< std::endl;
|
||||
sif::debug << "PlocUpdater::completionFailedReceived: Invalid pending command " << std::endl;
|
||||
break;
|
||||
}
|
||||
state = State::IDLE;
|
||||
@ -280,10 +267,12 @@ void PlocUpdater::commandUpdateAvailable() {
|
||||
calcImageCrc();
|
||||
|
||||
PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast<uint8_t>(image),
|
||||
static_cast<uint8_t>(partition), imageSize, imageCrc, numOfUpdatePackets);
|
||||
static_cast<uint8_t>(partition), imageSize, imageCrc,
|
||||
numOfUpdatePackets);
|
||||
|
||||
result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER,
|
||||
PLOC_SPV::UPDATE_AVAILABLE, packet.getWholeData(), packet.getFullSize());
|
||||
PLOC_SPV::UPDATE_AVAILABLE, packet.getWholeData(),
|
||||
packet.getFullSize());
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available"
|
||||
<< " packet to supervisor handler" << std::endl;
|
||||
@ -313,8 +302,7 @@ void PlocUpdater::commandUpdatePacket() {
|
||||
|
||||
if (remainingPackets == 1) {
|
||||
payloadLength = imageSize - static_cast<uint16_t>(file.tellg());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
payloadLength = MAX_SP_DATA;
|
||||
}
|
||||
|
||||
@ -329,7 +317,8 @@ void PlocUpdater::commandUpdatePacket() {
|
||||
packet.makeCrc();
|
||||
|
||||
result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER,
|
||||
PLOC_SPV::UPDATE_IMAGE_DATA, packet.getWholeData(), packet.getFullSize());
|
||||
PLOC_SPV::UPDATE_IMAGE_DATA, packet.getWholeData(),
|
||||
packet.getFullSize());
|
||||
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update"
|
||||
@ -351,10 +340,12 @@ void PlocUpdater::commandUpdateVerify() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast<uint8_t>(image),
|
||||
static_cast<uint8_t>(partition), imageSize, imageCrc, numOfUpdatePackets);
|
||||
static_cast<uint8_t>(partition), imageSize, imageCrc,
|
||||
numOfUpdatePackets);
|
||||
|
||||
result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER,
|
||||
PLOC_SPV::UPDATE_VERIFY, packet.getWholeData(), packet.getFullSize());
|
||||
result =
|
||||
commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, PLOC_SPV::UPDATE_VERIFY,
|
||||
packet.getWholeData(), packet.getFullSize());
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available"
|
||||
<< " packet to supervisor handler" << std::endl;
|
||||
@ -394,12 +385,9 @@ void PlocUpdater::calcImageCrc() {
|
||||
void PlocUpdater::adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet) {
|
||||
if (packetsSent == 0) {
|
||||
packet.setSequenceFlags(static_cast<uint8_t>(PLOC_SPV::SequenceFlags::FIRST_PKT));
|
||||
}
|
||||
else if (remainingPackets == 1) {
|
||||
} else if (remainingPackets == 1) {
|
||||
packet.setSequenceFlags(static_cast<uint8_t>(PLOC_SPV::SequenceFlags::LAST_PKT));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
packet.setSequenceFlags(static_cast<uint8_t>(PLOC_SPV::SequenceFlags::CONTINUED_PKT));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,27 +2,25 @@
|
||||
#define MISSION_DEVICES_PLOCUPDATER_H_
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "devicedefinitions/PlocSupervisorDefinitions.h"
|
||||
|
||||
#include "fsfw/action/CommandActionHelper.h"
|
||||
#include "fsfw/action/ActionHelper.h"
|
||||
#include "fsfw/action/HasActionsIF.h"
|
||||
#include "fsfw/action/CommandActionHelper.h"
|
||||
#include "fsfw/action/CommandsActionsIF.h"
|
||||
#include "fsfw/action/HasActionsIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "linux/fsfwconfig/objects/systemObjectList.h"
|
||||
#include "fsfw/tmtcpacket/SpacePacket.h"
|
||||
|
||||
#include "linux/fsfwconfig/objects/systemObjectList.h"
|
||||
|
||||
/**
|
||||
* @brief An object of this class can be used to perform the software updates of the PLOC. The
|
||||
* software update will be read from one of the SD cards, split into multiple space
|
||||
* packets and sent to the PlocSupervisorHandler.
|
||||
*
|
||||
* @details The MPSoC has two boot memories (NVM0 and NVM1) where each stores two images (Partition A
|
||||
* and Partition B)
|
||||
* @details The MPSoC has two boot memories (NVM0 and NVM1) where each stores two images (Partition
|
||||
* A and Partition B)
|
||||
*
|
||||
* @author J. Meier
|
||||
*/
|
||||
@ -32,7 +30,6 @@ class PlocUpdater : public SystemObject,
|
||||
public HasReturnvaluesIF,
|
||||
public CommandsActionsIF {
|
||||
public:
|
||||
|
||||
static const ActionId_t UPDATE_A_UBOOT = 0;
|
||||
static const ActionId_t UPDATE_A_BITSTREAM = 1;
|
||||
static const ActionId_t UPDATE_A_LINUX = 2;
|
||||
@ -58,14 +55,14 @@ public:
|
||||
void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override;
|
||||
|
||||
private:
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_UPDATER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Updater is already performing an update
|
||||
static const ReturnValue_t UPDATER_BUSY = MAKE_RETURN_CODE(0xA0);
|
||||
//! [EXPORT] : [COMMENT] Received update command with invalid path string (too long).
|
||||
static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA1);
|
||||
//! [EXPORT] : [COMMENT] Received command to initiate update but SD card with update image not mounted.
|
||||
//! [EXPORT] : [COMMENT] Received command to initiate update but SD card with update image not
|
||||
//! mounted.
|
||||
static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA2);
|
||||
//! [EXPORT] : [COMMENT] Update file received with update command does not exist.
|
||||
static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA3);
|
||||
@ -74,13 +71,15 @@ private:
|
||||
|
||||
//! [EXPORT] : [COMMENT] Try to read update file but the file does not exist.
|
||||
//! P1: Indicates in which state the file read fails
|
||||
//! P2: During the update transfer the second parameter gives information about the number of already sent packets
|
||||
//! P2: During the update transfer the second parameter gives information about the number of
|
||||
//! already sent packets
|
||||
static const Event UPDATE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Failed to send command to supervisor handler
|
||||
//! P1: Return value of CommandActionHelper::commandAction
|
||||
//! P2: Action ID of command to send
|
||||
static const Event ACTION_COMMANDING_FAILED = MAKE_EVENT(1, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Supervisor handler replied action message indicating a command execution failure of the update available command
|
||||
//! [EXPORT] : [COMMENT] Supervisor handler replied action message indicating a command execution
|
||||
//! failure of the update available command
|
||||
static const Event UPDATE_AVAILABLE_FAILED = MAKE_EVENT(2, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Supervisor handler failed to transfer an update space packet.
|
||||
//! P1: Parameter holds the number of update packets already sent (inclusive the failed packet)
|
||||
@ -122,21 +121,11 @@ private:
|
||||
|
||||
ActionId_t pendingCommand = PLOC_SPV::NONE;
|
||||
|
||||
enum class Image: uint8_t {
|
||||
NONE,
|
||||
A,
|
||||
B
|
||||
};
|
||||
enum class Image : uint8_t { NONE, A, B };
|
||||
|
||||
Image image = Image::NONE;
|
||||
|
||||
enum class Partition: uint8_t {
|
||||
NONE,
|
||||
UBOOT,
|
||||
BITSTREAM,
|
||||
LINUX_OS,
|
||||
APP_SW
|
||||
};
|
||||
enum class Partition : uint8_t { NONE, UBOOT, BITSTREAM, LINUX_OS, APP_SW };
|
||||
|
||||
Partition partition = Partition::NONE;
|
||||
|
||||
|
@ -5,18 +5,17 @@
|
||||
|
||||
class MemoryParams : public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param startAddress Start of address range to dump
|
||||
* @param endAddress End of address range to dump
|
||||
*/
|
||||
MemoryParams(uint32_t startAddress, uint32_t endAddress) :
|
||||
startAddress(startAddress), endAddress(endAddress) {
|
||||
MemoryParams(uint32_t startAddress, uint32_t endAddress)
|
||||
: startAddress(startAddress), endAddress(endAddress) {
|
||||
setLinks();
|
||||
}
|
||||
private:
|
||||
|
||||
private:
|
||||
void setLinks() {
|
||||
setStart(&startAddress);
|
||||
startAddress.setNext(&endAddress);
|
||||
@ -24,10 +23,6 @@ private:
|
||||
|
||||
SerializeElement<uint32_t> startAddress;
|
||||
SerializeElement<uint32_t> endAddress;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_PLOCMEMDUMPDEFINITIONS_H_ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,8 @@
|
||||
#include "ArcsecDatalinkLayer.h"
|
||||
|
||||
ArcsecDatalinkLayer::ArcsecDatalinkLayer() {
|
||||
slipInit();
|
||||
}
|
||||
ArcsecDatalinkLayer::ArcsecDatalinkLayer() { slipInit(); }
|
||||
|
||||
ArcsecDatalinkLayer::~ArcsecDatalinkLayer() {
|
||||
}
|
||||
ArcsecDatalinkLayer::~ArcsecDatalinkLayer() {}
|
||||
|
||||
void ArcsecDatalinkLayer::slipInit() {
|
||||
slipInfo.buffer = rxBuffer;
|
||||
@ -19,8 +16,8 @@ ReturnValue_t ArcsecDatalinkLayer::decodeFrame(const uint8_t* rawData, size_t ra
|
||||
size_t* bytesLeft) {
|
||||
size_t bytePos = 0;
|
||||
for (bytePos = 0; bytePos < rawDataSize; bytePos++) {
|
||||
enum arc_dec_result decResult = arc_transport_decode_body(*(rawData + bytePos), &slipInfo,
|
||||
decodedFrame, &decFrameSize);
|
||||
enum arc_dec_result decResult =
|
||||
arc_transport_decode_body(*(rawData + bytePos), &slipInfo, decodedFrame, &decFrameSize);
|
||||
*bytesLeft = rawDataSize - bytePos - 1;
|
||||
switch (decResult) {
|
||||
case ARC_DEC_INPROGRESS: {
|
||||
@ -48,31 +45,18 @@ ReturnValue_t ArcsecDatalinkLayer::decodeFrame(const uint8_t* rawData, size_t ra
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
uint8_t ArcsecDatalinkLayer::getReplyFrameType() {
|
||||
return decodedFrame[0];
|
||||
}
|
||||
uint8_t ArcsecDatalinkLayer::getReplyFrameType() { return decodedFrame[0]; }
|
||||
|
||||
const uint8_t* ArcsecDatalinkLayer::getReply() {
|
||||
return &decodedFrame[1];
|
||||
}
|
||||
const uint8_t* ArcsecDatalinkLayer::getReply() { return &decodedFrame[1]; }
|
||||
|
||||
void ArcsecDatalinkLayer::encodeFrame(const uint8_t* data, uint32_t length) {
|
||||
arc_transport_encode_body(data, length, encBuffer, &encFrameSize);
|
||||
}
|
||||
|
||||
uint8_t* ArcsecDatalinkLayer::getEncodedFrame() {
|
||||
return encBuffer;
|
||||
}
|
||||
uint8_t* ArcsecDatalinkLayer::getEncodedFrame() { return encBuffer; }
|
||||
|
||||
uint32_t ArcsecDatalinkLayer::getEncodedLength() {
|
||||
return encFrameSize;
|
||||
}
|
||||
uint32_t ArcsecDatalinkLayer::getEncodedLength() { return encFrameSize; }
|
||||
|
||||
uint8_t ArcsecDatalinkLayer::getStatusField() {
|
||||
return *(decodedFrame + STATUS_OFFSET);
|
||||
}
|
||||
|
||||
uint8_t ArcsecDatalinkLayer::getId() {
|
||||
return *(decodedFrame + ID_OFFSET);
|
||||
}
|
||||
uint8_t ArcsecDatalinkLayer::getStatusField() { return *(decodedFrame + STATUS_OFFSET); }
|
||||
|
||||
uint8_t ArcsecDatalinkLayer::getId() { return *(decodedFrame + ID_OFFSET); }
|
||||
|
@ -13,7 +13,6 @@ extern "C" {
|
||||
*/
|
||||
class ArcsecDatalinkLayer : public HasReturnvaluesIF {
|
||||
public:
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] More data required to complete frame
|
||||
@ -76,7 +75,6 @@ public:
|
||||
uint8_t getId();
|
||||
|
||||
private:
|
||||
|
||||
static const uint8_t ID_OFFSET = 1;
|
||||
static const uint8_t STATUS_OFFSET = 2;
|
||||
|
||||
|
@ -121,6 +121,6 @@ namespace arcseckeys {
|
||||
static const char L2T_MIN_MATCHED[] = "l2t_minConfidence";
|
||||
static const char T2L_MIN_CONFIDENCE[] = "t2l_minConfidence";
|
||||
static const char T2L_MIN_MATCHED[] = "t2l_minMatched";
|
||||
}
|
||||
} // namespace arcseckeys
|
||||
|
||||
#endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_ARCSECJSONKEYS_H_ */
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "ArcsecJsonParamBase.h"
|
||||
|
||||
#include "ArcsecJsonKeys.h"
|
||||
|
||||
ArcsecJsonParamBase::ArcsecJsonParamBase(std::string setName) : setName(setName) {}
|
||||
|
@ -1,12 +1,12 @@
|
||||
#ifndef BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_
|
||||
#define BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_
|
||||
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "StarTrackerDefinitions.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
extern "C" {
|
||||
#include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h"
|
||||
@ -24,7 +24,6 @@ using json = nlohmann::json;
|
||||
*/
|
||||
class ArcsecJsonParamBase : public HasReturnvaluesIF {
|
||||
public:
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::ARCSEC_JSON_BASE;
|
||||
//! [EXPORT] : [COMMENT] Specified json file does not exist
|
||||
static const ReturnValue_t JSON_FILE_NOT_EXISTS = MAKE_RETURN_CODE(1);
|
||||
@ -55,7 +54,6 @@ public:
|
||||
virtual size_t getSize() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief Reads the value of a parameter from a json set
|
||||
*
|
||||
@ -114,7 +112,6 @@ protected:
|
||||
void addSetParamHeader(uint8_t* buffer, uint8_t setId);
|
||||
|
||||
private:
|
||||
|
||||
json properties;
|
||||
json set;
|
||||
std::string setName;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,26 +1,43 @@
|
||||
#include <fstream>
|
||||
#include "StarTrackerHandler.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "StarTrackerJsonCommands.h"
|
||||
|
||||
#include <fsfw/globalfunctions/CRC.h>
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <mission/memory/NVMParameterBase.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "StarTrackerJsonCommands.h"
|
||||
extern "C" {
|
||||
#include <thirdparty/arcsec_star_tracker/client/generated/telemetry.h>
|
||||
#include <thirdparty/arcsec_star_tracker/client/generated/actionreq.h>
|
||||
#include <thirdparty/arcsec_star_tracker/client/generated/parameter.h>
|
||||
#include <thirdparty/arcsec_star_tracker/client/generated/telemetry.h>
|
||||
|
||||
#include "common/misc.h"
|
||||
}
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
|
||||
CookieIF * comCookie, StrHelper* strHelper) :
|
||||
DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet(
|
||||
this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), contrastSet(
|
||||
this), checksumSet(this), downloadCentroidSet(this), downloadMatchedStar(this), downloadDbImage(
|
||||
this), downloadBlobPixel(this), cameraSet(this), limitsSet(this), blobSet(this), strHelper(
|
||||
strHelper) {
|
||||
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
||||
StrHelper* strHelper)
|
||||
: DeviceHandlerBase(objectId, comIF, comCookie),
|
||||
temperatureSet(this),
|
||||
versionSet(this),
|
||||
powerSet(this),
|
||||
interfaceSet(this),
|
||||
timeSet(this),
|
||||
solutionSet(this),
|
||||
histogramSet(this),
|
||||
contrastSet(this),
|
||||
checksumSet(this),
|
||||
downloadCentroidSet(this),
|
||||
downloadMatchedStar(this),
|
||||
downloadDbImage(this),
|
||||
downloadBlobPixel(this),
|
||||
cameraSet(this),
|
||||
limitsSet(this),
|
||||
blobSet(this),
|
||||
strHelper(strHelper) {
|
||||
if (comCookie == nullptr) {
|
||||
sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl;
|
||||
}
|
||||
@ -30,8 +47,7 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
|
||||
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
||||
}
|
||||
|
||||
StarTrackerHandler::~StarTrackerHandler() {
|
||||
}
|
||||
StarTrackerHandler::~StarTrackerHandler() {}
|
||||
|
||||
ReturnValue_t StarTrackerHandler::initialize() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -40,13 +56,13 @@ ReturnValue_t StarTrackerHandler::initialize() {
|
||||
return result;
|
||||
}
|
||||
|
||||
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(
|
||||
objects::EVENT_MANAGER);
|
||||
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||
if (manager == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "StarTrackerHandler::initialize: Invalid event manager" << std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
;
|
||||
}
|
||||
result = manager->registerListener(eventQueue->getId());
|
||||
if (result != RETURN_OK) {
|
||||
@ -58,7 +74,8 @@ ReturnValue_t StarTrackerHandler::initialize() {
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from "
|
||||
" str helper" << std::endl;
|
||||
" str helper"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
@ -73,7 +90,6 @@ ReturnValue_t StarTrackerHandler::initialize() {
|
||||
|
||||
ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size) {
|
||||
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
switch (actionId) {
|
||||
@ -111,8 +127,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
|
||||
if (size > MAX_PATH_SIZE + MAX_FILE_NAME) {
|
||||
return FILE_PATH_TOO_LONG;
|
||||
}
|
||||
result = strHelper->startImageUpload(
|
||||
std::string(reinterpret_cast<const char*>(data), size));
|
||||
result = strHelper->startImageUpload(std::string(reinterpret_cast<const char*>(data), size));
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
@ -127,8 +142,8 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
|
||||
if (size > MAX_PATH_SIZE) {
|
||||
return FILE_PATH_TOO_LONG;
|
||||
}
|
||||
result = strHelper->startImageDownload(
|
||||
std::string(reinterpret_cast<const char*>(data), size));
|
||||
result =
|
||||
strHelper->startImageDownload(std::string(reinterpret_cast<const char*>(data), size));
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
@ -164,8 +179,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
|
||||
if (size > MAX_FILE_NAME) {
|
||||
return FILENAME_TOO_LONG;
|
||||
}
|
||||
strHelper->setDownloadImageName(
|
||||
std::string(reinterpret_cast<const char*>(data), size));
|
||||
strHelper->setDownloadImageName(std::string(reinterpret_cast<const char*>(data), size));
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
case (StarTracker::CHANGE_FPGA_DOWNLOAD_FILE): {
|
||||
@ -179,8 +193,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
|
||||
if (size > MAX_FILE_NAME) {
|
||||
return FILENAME_TOO_LONG;
|
||||
}
|
||||
strHelper->setDownloadImageName(
|
||||
std::string(reinterpret_cast<const char*>(data), size));
|
||||
strHelper->setDownloadImageName(std::string(reinterpret_cast<const char*>(data), size));
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
case (StarTracker::DOWNLOAD_FPGA_IMAGE): {
|
||||
@ -221,8 +234,8 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
|
||||
|
||||
void StarTrackerHandler::performOperationHook() {
|
||||
EventMessage event;
|
||||
for (ReturnValue_t result = eventQueue->receiveMessage(&event);
|
||||
result == RETURN_OK; result = eventQueue->receiveMessage(&event)) {
|
||||
for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK;
|
||||
result = eventQueue->receiveMessage(&event)) {
|
||||
switch (event.getMessageId()) {
|
||||
case EventMessage::EVENT_MESSAGE:
|
||||
handleEvent(&event);
|
||||
@ -259,9 +272,7 @@ void StarTrackerHandler::doShutDown() {
|
||||
setMode(_MODE_POWER_DOWN);
|
||||
}
|
||||
|
||||
void StarTrackerHandler::doOffActivity() {
|
||||
startupState = StartupState::IDLE;
|
||||
}
|
||||
void StarTrackerHandler::doOffActivity() { startupState = StartupState::IDLE; }
|
||||
|
||||
ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||
switch (internalState) {
|
||||
@ -347,7 +358,8 @@ ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t
|
||||
}
|
||||
|
||||
ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t * commandData, size_t commandDataLen) {
|
||||
const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
switch (deviceCommand) {
|
||||
case (StarTracker::PING_REQUEST): {
|
||||
@ -596,7 +608,6 @@ void StarTrackerHandler::fillCommandAndReplyMap() {
|
||||
|
||||
ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
||||
DeviceCommandId_t* foundId, size_t* foundLen) {
|
||||
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
size_t bytesLeft = 0;
|
||||
|
||||
@ -648,8 +659,8 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) {
|
||||
|
||||
ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
const uint8_t* packet) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
switch (id) {
|
||||
@ -772,18 +783,12 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con
|
||||
return result;
|
||||
}
|
||||
|
||||
void StarTrackerHandler::setNormalDatapoolEntriesInvalid() {}
|
||||
|
||||
void StarTrackerHandler::setNormalDatapoolEntriesInvalid() {
|
||||
|
||||
}
|
||||
|
||||
uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
|
||||
return 20000;
|
||||
}
|
||||
uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 20000; }
|
||||
|
||||
ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) {
|
||||
|
||||
localDataPoolMap.emplace(StarTracker::TICKS_TIME_SET, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(StarTracker::TIME_TIME_SET, new PoolEntry<uint64_t>({0}));
|
||||
localDataPoolMap.emplace(StarTracker::RUN_TIME, new PoolEntry<uint32_t>({0}));
|
||||
@ -1250,8 +1255,7 @@ void StarTrackerHandler::handleEvent(EventMessage* eventMessage) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event"
|
||||
<< std::endl;
|
||||
sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1267,8 +1271,7 @@ ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData
|
||||
uint32_t address;
|
||||
size_t size = sizeof(address);
|
||||
const uint8_t* addressPtr = commandData + WriteCmd::ADDRESS_OFFSET;
|
||||
result = SerializeAdapter::deSerialize(&address, addressPtr, &size,
|
||||
SerializeIF::Endianness::BIG);
|
||||
result = SerializeAdapter::deSerialize(&address, addressPtr, &size, SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed"
|
||||
<< std::endl;
|
||||
@ -1299,8 +1302,8 @@ ReturnValue_t StarTrackerHandler::executeFpgaDownloadCommand(const uint8_t* comm
|
||||
}
|
||||
uint32_t position;
|
||||
size_t size = sizeof(position);
|
||||
result = SerializeAdapter::deSerialize(&position, &commandData, &size,
|
||||
SerializeIF::Endianness::BIG);
|
||||
result =
|
||||
SerializeAdapter::deSerialize(&position, &commandData, &size, SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of position failed"
|
||||
<< std::endl;
|
||||
@ -1308,8 +1311,8 @@ ReturnValue_t StarTrackerHandler::executeFpgaDownloadCommand(const uint8_t* comm
|
||||
}
|
||||
uint32_t length;
|
||||
size = sizeof(length);
|
||||
result = SerializeAdapter::deSerialize(&length, &commandData, &size,
|
||||
SerializeIF::Endianness::BIG);
|
||||
result =
|
||||
SerializeAdapter::deSerialize(&length, &commandData, &size, SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of length failed"
|
||||
<< std::endl;
|
||||
@ -1317,7 +1320,8 @@ ReturnValue_t StarTrackerHandler::executeFpgaDownloadCommand(const uint8_t* comm
|
||||
}
|
||||
if (commandDataLen - sizeof(position) - sizeof(length) > MAX_PATH_SIZE) {
|
||||
sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Received command with "
|
||||
" invalid path and filename" << std::endl;
|
||||
" invalid path and filename"
|
||||
<< std::endl;
|
||||
return FILE_PATH_TOO_LONG;
|
||||
}
|
||||
std::string fullname = std::string(reinterpret_cast<const char*>(commandData),
|
||||
@ -1340,8 +1344,7 @@ ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData,
|
||||
uint32_t address;
|
||||
size_t size = sizeof(address);
|
||||
const uint8_t* addressPtr = commandData + ReadCmd::ADDRESS_OFFSET;
|
||||
result = SerializeAdapter::deSerialize(&address, addressPtr, &size,
|
||||
SerializeIF::Endianness::BIG);
|
||||
result = SerializeAdapter::deSerialize(&address, addressPtr, &size, SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed"
|
||||
<< std::endl;
|
||||
@ -1350,8 +1353,7 @@ ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData,
|
||||
uint32_t length;
|
||||
size = sizeof(length);
|
||||
const uint8_t* lengthPtr = commandData + ReadCmd::LENGTH_OFFSET;
|
||||
result = SerializeAdapter::deSerialize(&length, lengthPtr, &size,
|
||||
SerializeIF::Endianness::BIG);
|
||||
result = SerializeAdapter::deSerialize(&length, lengthPtr, &size, SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of length failed"
|
||||
<< std::endl;
|
||||
@ -1363,7 +1365,8 @@ ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData,
|
||||
return FILE_PATH_TOO_LONG;
|
||||
}
|
||||
const uint8_t* filePtr = commandData + ReadCmd::FILE_OFFSET;
|
||||
std::string fullname = std::string(reinterpret_cast<const char*>(filePtr),
|
||||
std::string fullname =
|
||||
std::string(reinterpret_cast<const char*>(filePtr),
|
||||
commandDataLen - sizeof(address) - sizeof(region) - sizeof(length));
|
||||
result = strHelper->startFlashRead(fullname, region, address, length);
|
||||
if (result != RETURN_OK) {
|
||||
@ -1406,8 +1409,7 @@ ReturnValue_t StarTrackerHandler::prepareUnlockCommand(const uint8_t* commandDat
|
||||
req.region = *commandData;
|
||||
size_t size = sizeof(req.code);
|
||||
const uint8_t* codePtr = commandData + UnlockCmd::CODE_OFFSET;
|
||||
result = SerializeAdapter::deSerialize(&req.code, &codePtr, &size,
|
||||
SerializeIF::Endianness::BIG);
|
||||
result = SerializeAdapter::deSerialize(&req.code, &codePtr, &size, SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
@ -1429,8 +1431,8 @@ ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandD
|
||||
req.region = *(commandData);
|
||||
size_t size = sizeof(req.address);
|
||||
const uint8_t* addressPtr = commandData + ChecksumCmd::ADDRESS_OFFSET;
|
||||
result = SerializeAdapter::deSerialize(&req.address, addressPtr, &size,
|
||||
SerializeIF::Endianness::BIG);
|
||||
result =
|
||||
SerializeAdapter::deSerialize(&req.address, addressPtr, &size, SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of address "
|
||||
<< "failed" << std::endl;
|
||||
@ -1438,8 +1440,8 @@ ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandD
|
||||
}
|
||||
size = sizeof(req.length);
|
||||
const uint8_t* lengthPtr = commandData + ChecksumCmd::LENGTH_OFFSET;
|
||||
result = SerializeAdapter::deSerialize(&req.length, lengthPtr, &size,
|
||||
SerializeIF::Endianness::BIG);
|
||||
result =
|
||||
SerializeAdapter::deSerialize(&req.length, lengthPtr, &size, SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed"
|
||||
<< std::endl;
|
||||
@ -1456,7 +1458,6 @@ ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandD
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t StarTrackerHandler::prepareSetTimeCommand(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -1469,8 +1470,7 @@ ReturnValue_t StarTrackerHandler::prepareSetTimeCommand(const uint8_t* commandDa
|
||||
result = SerializeAdapter::deSerialize(&req.unixTime, commandData, &size,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed"
|
||||
<< std::endl;
|
||||
sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed" << std::endl;
|
||||
return result;
|
||||
}
|
||||
uint32_t length = 0;
|
||||
@ -1506,8 +1506,8 @@ ReturnValue_t StarTrackerHandler::prepareUploadCentroidCommand(const uint8_t* co
|
||||
}
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
struct UploadCentroidActionRequest req;
|
||||
std::string jsonFileName = std::string(reinterpret_cast<const char*>(commandData),
|
||||
commandDataLen);
|
||||
std::string jsonFileName =
|
||||
std::string(reinterpret_cast<const char*>(commandData), commandDataLen);
|
||||
NVMParameterBase j(jsonFileName);
|
||||
result = j.readJsonFile();
|
||||
if (result != RETURN_OK) {
|
||||
@ -1536,13 +1536,15 @@ ReturnValue_t StarTrackerHandler::prepareUploadCentroidCommand(const uint8_t* co
|
||||
result = j.getValue(StarTracker::UploadCentroidKeys::x_uncorrected, &req.x_uncorrected);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key "
|
||||
<< StarTracker::UploadCentroidKeys::x_uncorrected << " does not exist" << std::endl;
|
||||
<< StarTracker::UploadCentroidKeys::x_uncorrected << " does not exist"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
result = j.getValue(StarTracker::UploadCentroidKeys::y_uncorrected, &req.y_uncorrected);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key "
|
||||
<< StarTracker::UploadCentroidKeys::y_uncorrected << " does not exist" << std::endl;
|
||||
<< StarTracker::UploadCentroidKeys::y_uncorrected << " does not exist"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
result = j.getValue(StarTracker::UploadCentroidKeys::x_corrected, &req.x_corrected);
|
||||
@ -1718,7 +1720,8 @@ void StarTrackerHandler::prepareErrorResetRequest() {
|
||||
}
|
||||
|
||||
ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData,
|
||||
size_t commandDataLen, ArcsecJsonParamBase& paramSet) {
|
||||
size_t commandDataLen,
|
||||
ArcsecJsonParamBase& paramSet) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
if (commandDataLen > MAX_PATH_SIZE) {
|
||||
return FILE_PATH_TOO_LONG;
|
||||
@ -1728,7 +1731,8 @@ ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData
|
||||
result = paramSet.create(fullName, commandBuffer);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "StarTrackerHandler::prepareParamCommand: Failed to create parameter "
|
||||
"command" << std::endl;
|
||||
"command"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
dataLinkLayer.encodeFrame(commandBuffer, paramSet.getSize());
|
||||
@ -1836,8 +1840,8 @@ ReturnValue_t StarTrackerHandler::handleSetParamReply() {
|
||||
uint8_t status = *(reply + STATUS_OFFSET);
|
||||
if (status != StarTracker::STATUS_OK) {
|
||||
sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set "
|
||||
" command with parameter ID" <<
|
||||
static_cast<unsigned int>(*(reply + PARAMETER_ID_OFFSET)) << std::endl;
|
||||
" command with parameter ID"
|
||||
<< static_cast<unsigned int>(*(reply + PARAMETER_ID_OFFSET)) << std::endl;
|
||||
if (startupState != StartupState::IDLE) {
|
||||
startupState = StartupState::IDLE;
|
||||
}
|
||||
@ -1855,8 +1859,8 @@ ReturnValue_t StarTrackerHandler::handleActionReply() {
|
||||
if (status != StarTracker::STATUS_OK) {
|
||||
sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action "
|
||||
<< "command with action ID "
|
||||
<< static_cast<unsigned int>(*(reply + ACTION_ID_OFFSET))
|
||||
<< " and status "<< static_cast<unsigned int>(status) << std::endl;
|
||||
<< static_cast<unsigned int>(*(reply + ACTION_ID_OFFSET)) << " and status "
|
||||
<< static_cast<unsigned int>(status) << std::endl;
|
||||
return ACTION_FAILED;
|
||||
}
|
||||
return RETURN_OK;
|
||||
@ -1929,8 +1933,7 @@ ReturnValue_t StarTrackerHandler::handleParamRequest(LocalPoolDataSetBase& datas
|
||||
dataset.setValidityBufferGeneration(false);
|
||||
result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "StarTrackerHandler::handleParamRequest Deserialization failed"
|
||||
<< std::endl;
|
||||
sif::warning << "StarTrackerHandler::handleParamRequest Deserialization failed" << std::endl;
|
||||
}
|
||||
dataset.setValidityBufferGeneration(true);
|
||||
dataset.setValidity(true, true);
|
||||
@ -1959,8 +1962,7 @@ ReturnValue_t StarTrackerHandler::handlePingReply() {
|
||||
if (status != StarTracker::STATUS_OK || pingId != PING_ID) {
|
||||
sif::warning << "StarTrackerHandler::handlePingReply: Ping failed" << std::endl;
|
||||
result = PING_FAILED;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1
|
||||
sif::info << "StarTracker: Ping successful" << std::endl;
|
||||
#endif
|
||||
@ -2008,8 +2010,7 @@ ReturnValue_t StarTrackerHandler::handleTm(LocalPoolDataSetBase& dataset, size_t
|
||||
dataset.setValidityBufferGeneration(false);
|
||||
result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "StarTrackerHandler::handleTm: Deserialization failed"
|
||||
<< std::endl;
|
||||
sif::warning << "StarTrackerHandler::handleTm: Deserialization failed" << std::endl;
|
||||
}
|
||||
dataset.setValidityBufferGeneration(true);
|
||||
dataset.setValidity(true, true);
|
||||
@ -2039,8 +2040,7 @@ ReturnValue_t StarTrackerHandler::handleActionReplySet(LocalPoolDataSetBase& dat
|
||||
dataset.setValidityBufferGeneration(false);
|
||||
result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed"
|
||||
<< std::endl;
|
||||
sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed" << std::endl;
|
||||
}
|
||||
dataset.setValidityBufferGeneration(true);
|
||||
dataset.setValidity(true, true);
|
||||
|
@ -1,15 +1,16 @@
|
||||
#ifndef MISSION_DEVICES_STARTRACKERHANDLER_H_
|
||||
#define MISSION_DEVICES_STARTRACKERHANDLER_H_
|
||||
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
|
||||
#include "ArcsecDatalinkLayer.h"
|
||||
#include "ArcsecJsonParamBase.h"
|
||||
#include "StarTrackerDefinitions.h"
|
||||
#include "StrHelper.h"
|
||||
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||
#include "fsfw/src/fsfw/serialize/SerializeAdapter.h"
|
||||
#include "fsfw/timemanager/Countdown.h"
|
||||
#include "thirdparty/arcsec_star_tracker/common/SLIP.h"
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include "ArcsecDatalinkLayer.h"
|
||||
#include "StarTrackerDefinitions.h"
|
||||
#include "ArcsecJsonParamBase.h"
|
||||
#include "StrHelper.h"
|
||||
|
||||
/**
|
||||
* @brief This is the device handler for the star tracker from arcsec.
|
||||
@ -21,7 +22,6 @@
|
||||
*/
|
||||
class StarTrackerHandler : public DeviceHandlerBase {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
@ -54,12 +54,11 @@ protected:
|
||||
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
|
||||
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
|
||||
void fillCommandAndReplyMap() override;
|
||||
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t * commandData,size_t commandDataLen) override;
|
||||
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize,
|
||||
DeviceCommandId_t *foundId, size_t *foundLen) override;
|
||||
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
|
||||
const uint8_t *packet) override;
|
||||
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
|
||||
size_t commandDataLen) override;
|
||||
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
|
||||
size_t* foundLen) override;
|
||||
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
|
||||
void setNormalDatapoolEntriesInvalid() override;
|
||||
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
@ -71,7 +70,6 @@ protected:
|
||||
virtual ReturnValue_t doSendReadHook() override;
|
||||
|
||||
private:
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Received reply is too short
|
||||
@ -115,7 +113,8 @@ private:
|
||||
static const ReturnValue_t REPLY_ERROR = MAKE_RETURN_CODE(0xAE);
|
||||
//! [EXPORT] : [COMMENT] Status field of contrast reply signals error
|
||||
static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE);
|
||||
//! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper execution)
|
||||
//! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper
|
||||
//! execution)
|
||||
static const ReturnValue_t COMMAND_TOO_SHORT = MAKE_RETURN_CODE(0xAF);
|
||||
//! [EXPORT] : [COMMENT] Received command with invalid length (too few or too many parameters)
|
||||
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xB0);
|
||||
@ -275,9 +274,7 @@ private:
|
||||
|
||||
std::string paramJsonFile = "/mnt/sd0/startracker/full.json";
|
||||
|
||||
enum class InternalState {
|
||||
TEMPERATURE_REQUEST
|
||||
};
|
||||
enum class InternalState { TEMPERATURE_REQUEST };
|
||||
|
||||
InternalState internalState = InternalState::TEMPERATURE_REQUEST;
|
||||
|
||||
@ -483,14 +480,12 @@ private:
|
||||
/**
|
||||
* @brief Fills command buffer with data to request matched star coordinates.
|
||||
*/
|
||||
ReturnValue_t prepareDownloadDbImageCommand(const uint8_t* commandData,
|
||||
size_t commandDataLen);
|
||||
ReturnValue_t prepareDownloadDbImageCommand(const uint8_t* commandData, size_t commandDataLen);
|
||||
|
||||
/**
|
||||
* @brief Fills command buffer with data to request output of the blob filter algorithm.
|
||||
*/
|
||||
ReturnValue_t prepareDownloadBlobPixelCommand(const uint8_t* commandData,
|
||||
size_t commandDataLen);
|
||||
ReturnValue_t prepareDownloadBlobPixelCommand(const uint8_t* commandData, size_t commandDataLen);
|
||||
|
||||
/**
|
||||
* @brief With this command the FPGA update will be applied to the star tracker
|
||||
|
@ -1,11 +1,10 @@
|
||||
#include "StarTrackerJsonCommands.h"
|
||||
|
||||
#include "ArcsecJsonKeys.h"
|
||||
|
||||
Limits::Limits() : ArcsecJsonParamBase(arcseckeys::LIMITS) {}
|
||||
|
||||
size_t Limits::getSize() {
|
||||
return COMMAND_SIZE;
|
||||
}
|
||||
size_t Limits::getSize() { return COMMAND_SIZE; }
|
||||
|
||||
ReturnValue_t Limits::createCommand(uint8_t* buffer) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -81,12 +80,9 @@ ReturnValue_t Limits::createCommand(uint8_t* buffer) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
Tracking::Tracking() : ArcsecJsonParamBase(arcseckeys::TRACKING) {}
|
||||
|
||||
size_t Tracking::getSize() {
|
||||
return COMMAND_SIZE;
|
||||
}
|
||||
size_t Tracking::getSize() { return COMMAND_SIZE; }
|
||||
|
||||
ReturnValue_t Tracking::createCommand(uint8_t* buffer) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -120,12 +116,9 @@ ReturnValue_t Tracking::createCommand(uint8_t* buffer) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
Mounting::Mounting() : ArcsecJsonParamBase(arcseckeys::MOUNTING) {}
|
||||
|
||||
size_t Mounting::getSize() {
|
||||
return COMMAND_SIZE;
|
||||
}
|
||||
size_t Mounting::getSize() { return COMMAND_SIZE; }
|
||||
|
||||
ReturnValue_t Mounting::createCommand(uint8_t* buffer) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -159,12 +152,9 @@ ReturnValue_t Mounting::createCommand(uint8_t* buffer) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
Camera::Camera() : ArcsecJsonParamBase(arcseckeys::CAMERA) {}
|
||||
|
||||
size_t Camera::getSize() {
|
||||
return COMMAND_SIZE;
|
||||
}
|
||||
size_t Camera::getSize() { return COMMAND_SIZE; }
|
||||
|
||||
ReturnValue_t Camera::createCommand(uint8_t* buffer) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -324,12 +314,9 @@ ReturnValue_t Camera::createCommand(uint8_t* buffer) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
Blob::Blob() : ArcsecJsonParamBase(arcseckeys::BLOB) {}
|
||||
|
||||
size_t Blob::getSize() {
|
||||
return COMMAND_SIZE;
|
||||
}
|
||||
size_t Blob::getSize() { return COMMAND_SIZE; }
|
||||
|
||||
ReturnValue_t Blob::createCommand(uint8_t* buffer) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -430,12 +417,9 @@ ReturnValue_t Blob::createCommand(uint8_t* buffer) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
Centroiding::Centroiding() : ArcsecJsonParamBase(arcseckeys::CENTROIDING) {}
|
||||
|
||||
size_t Centroiding::getSize() {
|
||||
return COMMAND_SIZE;
|
||||
}
|
||||
size_t Centroiding::getSize() { return COMMAND_SIZE; }
|
||||
|
||||
ReturnValue_t Centroiding::createCommand(uint8_t* buffer) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -517,12 +501,9 @@ ReturnValue_t Centroiding::createCommand(uint8_t* buffer) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
Lisa::Lisa() : ArcsecJsonParamBase(arcseckeys::LISA) {}
|
||||
|
||||
size_t Lisa::getSize() {
|
||||
return COMMAND_SIZE;
|
||||
}
|
||||
size_t Lisa::getSize() { return COMMAND_SIZE; }
|
||||
|
||||
ReturnValue_t Lisa::createCommand(uint8_t* buffer) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -605,12 +586,9 @@ ReturnValue_t Lisa::createCommand(uint8_t* buffer) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
Matching::Matching() : ArcsecJsonParamBase(arcseckeys::MATCHING) {}
|
||||
|
||||
size_t Matching::getSize() {
|
||||
return COMMAND_SIZE;
|
||||
}
|
||||
size_t Matching::getSize() { return COMMAND_SIZE; }
|
||||
|
||||
ReturnValue_t Matching::createCommand(uint8_t* buffer) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -632,12 +610,9 @@ ReturnValue_t Matching::createCommand(uint8_t* buffer) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
Validation::Validation() : ArcsecJsonParamBase(arcseckeys::VALIDATION) {}
|
||||
|
||||
size_t Validation::getSize() {
|
||||
return COMMAND_SIZE;
|
||||
}
|
||||
size_t Validation::getSize() { return COMMAND_SIZE; }
|
||||
|
||||
ReturnValue_t Validation::createCommand(uint8_t* buffer) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -673,9 +648,7 @@ ReturnValue_t Validation::createCommand(uint8_t* buffer) {
|
||||
|
||||
Algo::Algo() : ArcsecJsonParamBase(arcseckeys::ALGO) {}
|
||||
|
||||
size_t Algo::getSize() {
|
||||
return COMMAND_SIZE;
|
||||
}
|
||||
size_t Algo::getSize() { return COMMAND_SIZE; }
|
||||
|
||||
ReturnValue_t Algo::createCommand(uint8_t* buffer) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
@ -9,9 +9,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "ArcsecJsonParamBase.h"
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
/**
|
||||
* @brief Generates command to set the limit parameters
|
||||
@ -19,179 +18,144 @@
|
||||
*/
|
||||
class Limits : public ArcsecJsonParamBase {
|
||||
public:
|
||||
|
||||
Limits();
|
||||
|
||||
size_t getSize();
|
||||
|
||||
private:
|
||||
|
||||
static const size_t COMMAND_SIZE = 43;
|
||||
|
||||
virtual ReturnValue_t createCommand(uint8_t* buffer) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates the command to configure the tracking algorithm.
|
||||
*
|
||||
*/
|
||||
class Tracking : public ArcsecJsonParamBase {
|
||||
public:
|
||||
|
||||
Tracking();
|
||||
|
||||
size_t getSize();
|
||||
|
||||
private:
|
||||
|
||||
static const size_t COMMAND_SIZE = 15;
|
||||
|
||||
ReturnValue_t createCommand(uint8_t* buffer) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates the command to set the mounting quaternion
|
||||
*
|
||||
*/
|
||||
class Mounting : public ArcsecJsonParamBase {
|
||||
public:
|
||||
|
||||
Mounting();
|
||||
|
||||
size_t getSize();
|
||||
|
||||
private:
|
||||
|
||||
static const size_t COMMAND_SIZE = 18;
|
||||
|
||||
ReturnValue_t createCommand(uint8_t* buffer) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates the command to set the mounting quaternion
|
||||
*
|
||||
*/
|
||||
class Camera : public ArcsecJsonParamBase {
|
||||
public:
|
||||
|
||||
Camera();
|
||||
|
||||
size_t getSize();
|
||||
|
||||
private:
|
||||
|
||||
static const size_t COMMAND_SIZE = 43;
|
||||
|
||||
ReturnValue_t createCommand(uint8_t* buffer) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates the command to configure the blob algorithm
|
||||
*
|
||||
*/
|
||||
class Blob : public ArcsecJsonParamBase {
|
||||
public:
|
||||
|
||||
Blob();
|
||||
|
||||
size_t getSize();
|
||||
|
||||
private:
|
||||
|
||||
static const size_t COMMAND_SIZE = 24;
|
||||
|
||||
ReturnValue_t createCommand(uint8_t* buffer) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates the command to configure the centroiding algorithm
|
||||
*
|
||||
*/
|
||||
class Centroiding : public ArcsecJsonParamBase {
|
||||
public:
|
||||
|
||||
Centroiding();
|
||||
|
||||
size_t getSize();
|
||||
|
||||
private:
|
||||
|
||||
static const size_t COMMAND_SIZE = 47;
|
||||
|
||||
ReturnValue_t createCommand(uint8_t* buffer) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates the command to configure the LISA (lost in space algorithm)
|
||||
*
|
||||
*/
|
||||
class Lisa : public ArcsecJsonParamBase {
|
||||
public:
|
||||
|
||||
Lisa();
|
||||
|
||||
size_t getSize();
|
||||
|
||||
private:
|
||||
|
||||
static const size_t COMMAND_SIZE = 48;
|
||||
|
||||
ReturnValue_t createCommand(uint8_t* buffer) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates the command to configure the matching algorithm
|
||||
*
|
||||
*/
|
||||
class Matching : public ArcsecJsonParamBase {
|
||||
public:
|
||||
|
||||
Matching();
|
||||
|
||||
size_t getSize();
|
||||
|
||||
private:
|
||||
|
||||
static const size_t COMMAND_SIZE = 10;
|
||||
|
||||
ReturnValue_t createCommand(uint8_t* buffer) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates the command to configure the validation parameters
|
||||
*
|
||||
*/
|
||||
class Validation : public ArcsecJsonParamBase {
|
||||
public:
|
||||
|
||||
Validation();
|
||||
|
||||
size_t getSize();
|
||||
|
||||
private:
|
||||
|
||||
static const size_t COMMAND_SIZE = 12;
|
||||
|
||||
ReturnValue_t createCommand(uint8_t* buffer) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates command to configure the mechanism of automatically switching between the
|
||||
* LISA and other algorithms.
|
||||
@ -199,17 +163,14 @@ private:
|
||||
*/
|
||||
class Algo : public ArcsecJsonParamBase {
|
||||
public:
|
||||
|
||||
Algo();
|
||||
|
||||
size_t getSize();
|
||||
|
||||
private:
|
||||
|
||||
static const size_t COMMAND_SIZE = 13;
|
||||
|
||||
ReturnValue_t createCommand(uint8_t* buffer) override;
|
||||
|
||||
};
|
||||
|
||||
#endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ */
|
||||
|
@ -1,16 +1,13 @@
|
||||
#include "StrHelper.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
#include "mission/utility/Timestamp.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId) {}
|
||||
|
||||
StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId){
|
||||
|
||||
}
|
||||
|
||||
StrHelper::~StrHelper() {
|
||||
}
|
||||
StrHelper::~StrHelper() {}
|
||||
|
||||
ReturnValue_t StrHelper::initialize() {
|
||||
sdcMan = SdCardManager::instance();
|
||||
@ -34,8 +31,7 @@ ReturnValue_t StrHelper::performOperation(uint8_t operationCode) {
|
||||
result = performImageUpload();
|
||||
if (result == RETURN_OK) {
|
||||
triggerEvent(IMAGE_UPLOAD_SUCCESSFUL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
triggerEvent(IMAGE_UPLOAD_FAILED);
|
||||
}
|
||||
internalState = InternalState::IDLE;
|
||||
@ -45,8 +41,7 @@ ReturnValue_t StrHelper::performOperation(uint8_t operationCode) {
|
||||
result = performImageDownload();
|
||||
if (result == RETURN_OK) {
|
||||
triggerEvent(IMAGE_DOWNLOAD_SUCCESSFUL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
triggerEvent(IMAGE_DOWNLOAD_FAILED);
|
||||
}
|
||||
internalState = InternalState::IDLE;
|
||||
@ -56,8 +51,7 @@ ReturnValue_t StrHelper::performOperation(uint8_t operationCode) {
|
||||
result = performFlashWrite();
|
||||
if (result == RETURN_OK) {
|
||||
triggerEvent(FLASH_WRITE_SUCCESSFUL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
triggerEvent(FLASH_WRITE_FAILED);
|
||||
}
|
||||
internalState = InternalState::IDLE;
|
||||
@ -67,8 +61,7 @@ ReturnValue_t StrHelper::performOperation(uint8_t operationCode) {
|
||||
result = performFlashRead();
|
||||
if (result == RETURN_OK) {
|
||||
triggerEvent(FLASH_READ_SUCCESSFUL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
triggerEvent(FLASH_READ_FAILED);
|
||||
}
|
||||
internalState = InternalState::IDLE;
|
||||
@ -78,8 +71,7 @@ ReturnValue_t StrHelper::performOperation(uint8_t operationCode) {
|
||||
result = performFpgaDownload();
|
||||
if (result == RETURN_OK) {
|
||||
triggerEvent(FPGA_DOWNLOAD_SUCCESSFUL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
triggerEvent(FPGA_DOWNLOAD_FAILED);
|
||||
}
|
||||
internalState = InternalState::IDLE;
|
||||
@ -89,8 +81,7 @@ ReturnValue_t StrHelper::performOperation(uint8_t operationCode) {
|
||||
result = performFpgaUpload();
|
||||
if (result == RETURN_OK) {
|
||||
triggerEvent(FPGA_UPLOAD_SUCCESSFUL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
triggerEvent(FPGA_UPLOAD_FAILED);
|
||||
}
|
||||
internalState = InternalState::IDLE;
|
||||
@ -112,9 +103,7 @@ ReturnValue_t StrHelper::setComIF(DeviceCommunicationIF* communicationInterface_
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void StrHelper::setComCookie(CookieIF* comCookie_) {
|
||||
comCookie = comCookie_;
|
||||
}
|
||||
void StrHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; }
|
||||
|
||||
ReturnValue_t StrHelper::startImageUpload(std::string fullname) {
|
||||
ReturnValue_t result = checkPath(fullname);
|
||||
@ -146,24 +135,15 @@ ReturnValue_t StrHelper::startImageDownload(std::string path) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void StrHelper::stopProcess() {
|
||||
terminate = true;
|
||||
}
|
||||
void StrHelper::stopProcess() { terminate = true; }
|
||||
|
||||
void StrHelper::setDownloadImageName(std::string filename) {
|
||||
downloadImage.filename = filename;
|
||||
}
|
||||
void StrHelper::setDownloadImageName(std::string filename) { downloadImage.filename = filename; }
|
||||
|
||||
void StrHelper::setFlashReadFilename(std::string filename) {
|
||||
flashRead.filename = filename;
|
||||
}
|
||||
void StrHelper::setFlashReadFilename(std::string filename) { flashRead.filename = filename; }
|
||||
|
||||
void StrHelper::setDownloadFpgaImage(std::string filename) {
|
||||
fpgaDownload.fileName = filename;
|
||||
}
|
||||
void StrHelper::setDownloadFpgaImage(std::string filename) { fpgaDownload.fileName = filename; }
|
||||
|
||||
ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region,
|
||||
uint32_t address) {
|
||||
ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region, uint32_t address) {
|
||||
ReturnValue_t result = checkPath(fullname);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
@ -180,8 +160,8 @@ ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region,
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t region,
|
||||
uint32_t address, uint32_t length) {
|
||||
ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t region, uint32_t address,
|
||||
uint32_t length) {
|
||||
ReturnValue_t result = checkPath(path);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
@ -395,8 +375,7 @@ ReturnValue_t StrHelper::performFlashRead() {
|
||||
}
|
||||
if ((flashRead.size - bytesRead) < MAX_FLASH_DATA) {
|
||||
req.length = flashRead.size - bytesRead;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
req.length = MAX_FLASH_DATA;
|
||||
}
|
||||
req.address = flashRead.address + bytesRead;
|
||||
@ -458,8 +437,7 @@ ReturnValue_t StrHelper::performFpgaDownload() {
|
||||
}
|
||||
if (fpgaDownload.length - req.pos >= FpgaDownload::MAX_DATA) {
|
||||
req.length = FpgaDownload::MAX_DATA;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
req.length = fpgaDownload.length - req.pos;
|
||||
}
|
||||
arc_pack_downloadfpgaimage_action_req(&req, commandBuffer, &size);
|
||||
@ -513,8 +491,7 @@ ReturnValue_t StrHelper::performFpgaUpload() {
|
||||
}
|
||||
if (fileSize - bytesUploaded > FpgaUpload::MAX_DATA) {
|
||||
req.length = FpgaUpload::MAX_DATA;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
req.length = fileSize - bytesUploaded;
|
||||
}
|
||||
file.seekg(bytesUploaded, file.beg);
|
||||
@ -550,8 +527,7 @@ ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) {
|
||||
}
|
||||
decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS;
|
||||
while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) {
|
||||
result = uartComIF->requestReceiveMessage(comCookie,
|
||||
StarTracker::MAX_FRAME_SIZE * 2 + 2);
|
||||
result = uartComIF->requestReceiveMessage(comCookie, StarTracker::MAX_FRAME_SIZE * 2 + 2);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl;
|
||||
triggerEvent(STR_HELPER_REQUESTING_MSG_FAILED, result, parameter);
|
||||
@ -566,12 +542,10 @@ ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) {
|
||||
if (receivedDataLen == 0 && missedReplies < MAX_POLLS) {
|
||||
missedReplies++;
|
||||
continue;
|
||||
}
|
||||
else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) {
|
||||
} else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) {
|
||||
triggerEvent(STR_HELPER_NO_REPLY, parameter);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
missedReplies = 0;
|
||||
}
|
||||
decResult = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft);
|
||||
@ -592,8 +566,7 @@ ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) {
|
||||
ReturnValue_t StrHelper::checkActionReply() {
|
||||
uint8_t type = datalinkLayer.getReplyFrameType();
|
||||
if (type != TMTC_ACTIONREPLY) {
|
||||
sif::warning << "StrHelper::checkActionReply: Received reply with invalid type ID"
|
||||
<< std::endl;
|
||||
sif::warning << "StrHelper::checkActionReply: Received reply with invalid type ID" << std::endl;
|
||||
return INVALID_TYPE_ID;
|
||||
}
|
||||
uint8_t status = datalinkLayer.getStatusField();
|
||||
@ -627,8 +600,8 @@ ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address
|
||||
uint32_t address;
|
||||
const uint8_t* addressData = data + ADDRESS_OFFSET;
|
||||
size_t size = sizeof(address);
|
||||
result = SerializeAdapter::deSerialize(&address, &addressData, &size,
|
||||
SerializeIF::Endianness::LITTLE);
|
||||
result =
|
||||
SerializeAdapter::deSerialize(&address, &addressData, &size, SerializeIF::Endianness::LITTLE);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed"
|
||||
<< std::endl;
|
||||
@ -637,8 +610,8 @@ ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address
|
||||
uint16_t length = 0;
|
||||
size = sizeof(length);
|
||||
const uint8_t* lengthData = data + LENGTH_OFFSET;
|
||||
result = SerializeAdapter::deSerialize(&length, lengthData, &size,
|
||||
SerializeIF::Endianness::LITTLE);
|
||||
result =
|
||||
SerializeAdapter::deSerialize(&length, lengthData, &size, SerializeIF::Endianness::LITTLE);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "StrHelper::checkFlashActionReply: Deserialization of length failed"
|
||||
<< std::endl;
|
||||
@ -655,8 +628,7 @@ ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition,
|
||||
uint32_t expectedLength) {
|
||||
ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
result = checkActionReply();
|
||||
if (result != RETURN_OK) {
|
||||
@ -665,8 +637,7 @@ ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition,
|
||||
const uint8_t* data = datalinkLayer.getReply() + ACTION_DATA_OFFSET;
|
||||
uint32_t position;
|
||||
size_t size = sizeof(position);
|
||||
result = SerializeAdapter::deSerialize(&position, &data, &size,
|
||||
SerializeIF::Endianness::LITTLE);
|
||||
result = SerializeAdapter::deSerialize(&position, &data, &size, SerializeIF::Endianness::LITTLE);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of position failed"
|
||||
<< std::endl;
|
||||
@ -674,8 +645,7 @@ ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition,
|
||||
}
|
||||
uint32_t length;
|
||||
size = sizeof(length);
|
||||
result = SerializeAdapter::deSerialize(&length, &data, &size,
|
||||
SerializeIF::Endianness::LITTLE);
|
||||
result = SerializeAdapter::deSerialize(&length, &data, &size, SerializeIF::Endianness::LITTLE);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of length failed"
|
||||
<< std::endl;
|
||||
@ -685,14 +655,14 @@ ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition,
|
||||
}
|
||||
|
||||
ReturnValue_t StrHelper::checkPath(std::string name) {
|
||||
if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT))
|
||||
== std::string(SdCardManager::SD_0_MOUNT_POINT)) {
|
||||
if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) ==
|
||||
std::string(SdCardManager::SD_0_MOUNT_POINT)) {
|
||||
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
|
||||
sif::warning << "StrHelper::checkPath: SD card 0 not mounted" << std::endl;
|
||||
return SD_NOT_MOUNTED;
|
||||
}
|
||||
} else if (name.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT))
|
||||
== std::string(SdCardManager::SD_1_MOUNT_POINT)) {
|
||||
} else if (name.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT)) ==
|
||||
std::string(SdCardManager::SD_1_MOUNT_POINT)) {
|
||||
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
|
||||
sif::warning << "StrHelper::checkPath: SD card 1 not mounted" << std::endl;
|
||||
return SD_NOT_MOUNTED;
|
||||
|
@ -2,18 +2,19 @@
|
||||
#define BSP_Q7S_DEVICES_STRHELPER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ArcsecDatalinkLayer.h"
|
||||
#include "fsfw/osal/linux/BinarySemaphore.h"
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/devicehandlers/CookieIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/osal/linux/BinarySemaphore.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||
#include "fsfw_hal/linux/uart/UartComIF.h"
|
||||
#include "fsfw/devicehandlers/CookieIF.h"
|
||||
|
||||
extern "C" {
|
||||
#include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h"
|
||||
#include "thirdparty/arcsec_star_tracker/client/generated/actionreq.h"
|
||||
#include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h"
|
||||
}
|
||||
|
||||
/**
|
||||
@ -21,7 +22,6 @@ extern "C" {
|
||||
*/
|
||||
class StrHelper : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF {
|
||||
public:
|
||||
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HELPER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Image upload failed
|
||||
@ -71,11 +71,13 @@ public:
|
||||
static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(17, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Sending packet to star tracker failed
|
||||
//! P1: Return code of communication interface sendMessage function
|
||||
//!P2: Position of upload/download packet, or address of flash write/read request for which sending failed
|
||||
//! P2: Position of upload/download packet, or address of flash write/read request for which
|
||||
//! sending failed
|
||||
static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(18, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Communication interface requesting reply failed
|
||||
//! P1: Return code of failed request
|
||||
//!P1: Upload/download position, or address of flash write/read request for which transmission failed
|
||||
//! P1: Upload/download position, or address of flash write/read request for which transmission
|
||||
//! failed
|
||||
static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW);
|
||||
|
||||
StrHelper(object_id_t objectId);
|
||||
@ -119,8 +121,7 @@ public:
|
||||
* @param address Start address of flash section to read
|
||||
* @param length Number of bytes to read from flash
|
||||
*/
|
||||
ReturnValue_t startFlashRead(std::string path, uint8_t region, uint32_t address,
|
||||
uint32_t length);
|
||||
ReturnValue_t startFlashRead(std::string path, uint8_t region, uint32_t address, uint32_t length);
|
||||
|
||||
/**
|
||||
* @brief Starts the download of the FPGA image
|
||||
@ -160,7 +161,6 @@ public:
|
||||
void setDownloadFpgaImage(std::string filename);
|
||||
|
||||
private:
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::STR_HELPER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] SD card specified in path string not mounted
|
||||
|
@ -1,18 +1,17 @@
|
||||
#include "gpioCallbacks.h"
|
||||
#include "busConf.h"
|
||||
|
||||
#include <devices/gpioIds.h>
|
||||
|
||||
#include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h>
|
||||
#include <fsfw_hal/common/gpio/GpioCookie.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw_hal/common/gpio/GpioCookie.h>
|
||||
#include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h>
|
||||
|
||||
#include "busConf.h"
|
||||
|
||||
namespace gpioCallbacks {
|
||||
|
||||
GpioIF* gpioComInterface;
|
||||
|
||||
void initSpiCsDecoder(GpioIF* gpioComIF) {
|
||||
|
||||
ReturnValue_t result;
|
||||
|
||||
if (gpioComIF == nullptr) {
|
||||
@ -42,11 +41,11 @@ void initSpiCsDecoder(GpioIF* gpioComIF) {
|
||||
// gpio::OUT, gpio::LOW);
|
||||
// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit);
|
||||
// /** Setting mux bit 2 to low disables IC1 on the TCS board */
|
||||
// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", gpio::OUT, gpio::HIGH);
|
||||
// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit);
|
||||
// /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */
|
||||
// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", gpio::OUT, gpio::LOW);
|
||||
// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit);
|
||||
// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2",
|
||||
// gpio::OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit);
|
||||
// /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board
|
||||
// */ spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit
|
||||
// 3", gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit);
|
||||
|
||||
/** The following gpios can take arbitrary initial values */
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4",
|
||||
@ -58,8 +57,8 @@ void initSpiCsDecoder(GpioIF* gpioComIF) {
|
||||
spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_6_PIN, "SPI Mux Bit 6",
|
||||
gpio::DIR_OUT, gpio::LOW);
|
||||
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit);
|
||||
GpiodRegularByLineName* enRwDecoder = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_CS,
|
||||
"EN_RW_CS", gpio::DIR_OUT, gpio::HIGH);
|
||||
GpiodRegularByLineName* enRwDecoder =
|
||||
new GpiodRegularByLineName(q7s::gpioNames::EN_RW_CS, "EN_RW_CS", gpio::DIR_OUT, gpio::HIGH);
|
||||
spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder);
|
||||
|
||||
result = gpioComInterface->addGpios(spiMuxGpios);
|
||||
@ -71,7 +70,6 @@ void initSpiCsDecoder(GpioIF* gpioComIF) {
|
||||
|
||||
void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels value,
|
||||
void* args) {
|
||||
|
||||
if (gpioComInterface == nullptr) {
|
||||
sif::debug << "spiCsDecoderCallback: No gpioComIF specified. Call initSpiCsDecoder "
|
||||
<< "to specify gpioComIF" << std::endl;
|
||||
@ -220,8 +218,7 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Lev
|
||||
default:
|
||||
sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl;
|
||||
}
|
||||
}
|
||||
else if (value == gpio::LOW) {
|
||||
} else if (value == gpio::LOW) {
|
||||
switch (gpioId) {
|
||||
case (gpioIds::RTD_IC_3): {
|
||||
selectY7();
|
||||
@ -391,8 +388,7 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Lev
|
||||
default:
|
||||
sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::debug << "spiCsDecoderCallback: Invalid value. Must be 0 or 1" << std::endl;
|
||||
}
|
||||
}
|
||||
@ -446,13 +442,9 @@ void disableDecoderInterfaceBoardIc2() {
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
}
|
||||
|
||||
void enableRwDecoder() {
|
||||
gpioComInterface->pullHigh(gpioIds::EN_RW_CS);
|
||||
}
|
||||
void enableRwDecoder() { gpioComInterface->pullHigh(gpioIds::EN_RW_CS); }
|
||||
|
||||
void disableRwDecoder() {
|
||||
gpioComInterface->pullLow(gpioIds::EN_RW_CS);
|
||||
}
|
||||
void disableRwDecoder() { gpioComInterface->pullLow(gpioIds::EN_RW_CS); }
|
||||
|
||||
void selectY0() {
|
||||
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||
@ -509,4 +501,4 @@ void disableAllDecoder() {
|
||||
gpioComInterface->pullLow(gpioIds::EN_RW_CS);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gpioCallbacks
|
||||
|
@ -1,9 +1,8 @@
|
||||
#ifndef LINUX_GPIO_GPIOCALLBACKS_H_
|
||||
#define LINUX_GPIO_GPIOCALLBACKS_H_
|
||||
|
||||
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
|
||||
#include <fsfw_hal/common/gpio/GpioIF.h>
|
||||
|
||||
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
|
||||
|
||||
namespace gpioCallbacks {
|
||||
|
||||
@ -17,8 +16,8 @@ namespace gpioCallbacks {
|
||||
* @brief This function implements the decoding to multiply gpios by using the decoder
|
||||
* chips SN74LVC138APWR on the TCS board and the interface board.
|
||||
*/
|
||||
void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp,
|
||||
gpio::Levels value, void* args);
|
||||
void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels value,
|
||||
void* args);
|
||||
|
||||
/**
|
||||
* @brief This function sets mux bits 1-3 to a state which will only enable the decoder
|
||||
@ -69,6 +68,6 @@ namespace gpioCallbacks {
|
||||
void selectY5();
|
||||
void selectY6();
|
||||
void selectY7();
|
||||
}
|
||||
} // namespace gpioCallbacks
|
||||
|
||||
#endif /* LINUX_GPIO_GPIOCALLBACKS_H_ */
|
||||
|
@ -12,8 +12,7 @@
|
||||
* @brief This is the main program for the target hardware.
|
||||
* @return
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
int main(void) {
|
||||
using namespace std;
|
||||
#if Q7S_SIMPLE_MODE == 0
|
||||
return obsw::obsw();
|
||||
|
@ -1,33 +1,29 @@
|
||||
#include "FileSystemHandler.h"
|
||||
|
||||
#include "bsp_q7s/core/CoreController.h"
|
||||
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
#include "fsfw/memory/GenericFileSystemMessage.h"
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler):
|
||||
SystemObject(fileSystemHandler) {
|
||||
#include "bsp_q7s/core/CoreController.h"
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "fsfw/memory/GenericFileSystemMessage.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
|
||||
FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler)
|
||||
: SystemObject(fileSystemHandler) {
|
||||
mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE);
|
||||
}
|
||||
|
||||
FileSystemHandler::~FileSystemHandler() {
|
||||
QueueFactory::instance()->deleteMessageQueue(mq);
|
||||
}
|
||||
FileSystemHandler::~FileSystemHandler() { QueueFactory::instance()->deleteMessageQueue(mq); }
|
||||
|
||||
ReturnValue_t FileSystemHandler::performOperation(uint8_t unsignedChar) {
|
||||
while (true) {
|
||||
try {
|
||||
fileSystemHandlerLoop();
|
||||
}
|
||||
catch(std::bad_alloc& e) {
|
||||
} catch (std::bad_alloc& e) {
|
||||
// Restart OBSW, hints at a memory leak
|
||||
sif::error << "Allocation error in FileSystemHandler::performOperation"
|
||||
<< e.what() << std::endl;
|
||||
sif::error << "Allocation error in FileSystemHandler::performOperation" << e.what()
|
||||
<< std::endl;
|
||||
// Set up an error file or a special flag in the scratch buffer for these cases
|
||||
triggerEvent(CoreController::ALLOC_FAILURE, 0, 0);
|
||||
CoreController::incrementAllocationFailureCount();
|
||||
@ -35,7 +31,6 @@ ReturnValue_t FileSystemHandler::performOperation(uint8_t unsignedChar) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FileSystemHandler::fileSystemHandlerLoop() {
|
||||
CommandMessage filemsg;
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
@ -48,10 +43,8 @@ void FileSystemHandler::fileSystemHandlerLoop() {
|
||||
result = mq->receiveMessage(&filemsg);
|
||||
if (result == MessageQueueIF::EMPTY) {
|
||||
break;
|
||||
}
|
||||
else if(result != HasReturnvaluesIF::RETURN_FAILED) {
|
||||
sif::warning << "FileSystemHandler::performOperation: Message reception failed!"
|
||||
<< std::endl;
|
||||
} else if (result != HasReturnvaluesIF::RETURN_FAILED) {
|
||||
sif::warning << "FileSystemHandler::performOperation: Message reception failed!" << std::endl;
|
||||
break;
|
||||
}
|
||||
Command_t command = filemsg.getCommand();
|
||||
@ -78,26 +71,23 @@ void FileSystemHandler::fileSystemCheckup() {
|
||||
sdcMan->getSdCardActiveStatus(statusPair);
|
||||
sd::SdCard preferredSdCard;
|
||||
sdcMan->getPreferredSdCard(preferredSdCard);
|
||||
if((preferredSdCard == sd::SdCard::SLOT_0) and
|
||||
(statusPair.first == sd::SdState::MOUNTED)) {
|
||||
if ((preferredSdCard == sd::SdCard::SLOT_0) and (statusPair.first == sd::SdState::MOUNTED)) {
|
||||
currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT;
|
||||
}
|
||||
else if((preferredSdCard == sd::SdCard::SLOT_1) and
|
||||
} else if ((preferredSdCard == sd::SdCard::SLOT_1) and
|
||||
(statusPair.second == sd::SdState::MOUNTED)) {
|
||||
currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
std::string sdString;
|
||||
if (preferredSdCard == sd::SdCard::SLOT_0) {
|
||||
sdString = "0";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sdString = "1";
|
||||
}
|
||||
sif::warning << "FileSystemHandler::performOperation: "
|
||||
"Inconsistent state detected" << std::endl;
|
||||
sif::warning << "Preferred SD card is " << sdString <<
|
||||
" but does not appear to be mounted. Attempting fix.." << std::endl;
|
||||
"Inconsistent state detected"
|
||||
<< std::endl;
|
||||
sif::warning << "Preferred SD card is " << sdString
|
||||
<< " but does not appear to be mounted. Attempting fix.." << std::endl;
|
||||
// This function will appear to fix the inconsistent state
|
||||
ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@ -108,15 +98,13 @@ void FileSystemHandler::fileSystemCheckup() {
|
||||
}
|
||||
}
|
||||
|
||||
MessageQueueId_t FileSystemHandler::getCommandQueue() const {
|
||||
return mq->getId();
|
||||
}
|
||||
MessageQueueId_t FileSystemHandler::getCommandQueue() const { return mq->getId(); }
|
||||
|
||||
ReturnValue_t FileSystemHandler::initialize() {
|
||||
coreCtrl = ObjectManager::instance()->get<CoreController>(objects::CORE_CONTROLLER);
|
||||
if (coreCtrl == nullptr) {
|
||||
sif::error << "FileSystemHandler::initialize: Could not retrieve core controller handle" <<
|
||||
std::endl;
|
||||
sif::error << "FileSystemHandler::initialize: Could not retrieve core controller handle"
|
||||
<< std::endl;
|
||||
}
|
||||
sdcMan = SdCardManager::instance();
|
||||
sd::SdCard preferredSdCard;
|
||||
@ -126,15 +114,14 @@ ReturnValue_t FileSystemHandler::initialize() {
|
||||
}
|
||||
if (preferredSdCard == sd::SdCard::SLOT_0) {
|
||||
currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT;
|
||||
}
|
||||
else if(preferredSdCard == sd::SdCard::SLOT_1) {
|
||||
} else if (preferredSdCard == sd::SdCard::SLOT_1) {
|
||||
currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath,
|
||||
const char* filename, const uint8_t* data, size_t size,
|
||||
ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath, const char* filename,
|
||||
const uint8_t* data, size_t size,
|
||||
uint16_t packetNumber, FileSystemArgsIF* args) {
|
||||
auto path = getInitPath(args) / repositoryPath / filename;
|
||||
if (not std::filesystem::exists(path)) {
|
||||
@ -148,8 +135,9 @@ ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath,
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath,
|
||||
const char* filename, const uint8_t* data, size_t size, FileSystemArgsIF* args) {
|
||||
ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath, const char* filename,
|
||||
const uint8_t* data, size_t size,
|
||||
FileSystemArgsIF* args) {
|
||||
auto path = getInitPath(args) / filename;
|
||||
if (std::filesystem::exists(path)) {
|
||||
return FILE_ALREADY_EXISTS;
|
||||
@ -162,8 +150,8 @@ ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath,
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t FileSystemHandler::removeFile(const char* repositoryPath,
|
||||
const char* filename, FileSystemArgsIF* args) {
|
||||
ReturnValue_t FileSystemHandler::removeFile(const char* repositoryPath, const char* filename,
|
||||
FileSystemArgsIF* args) {
|
||||
auto path = getInitPath(args) / repositoryPath / filename;
|
||||
if (not std::filesystem::exists(path)) {
|
||||
return FILE_DOES_NOT_EXIST;
|
||||
@ -199,32 +187,28 @@ ReturnValue_t FileSystemHandler::removeDirectory(const char* repositoryPath, con
|
||||
if (not deleteRecurively) {
|
||||
if (std::filesystem::remove(path, err)) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Check error code. Most probably denied permissions because folder is not empty
|
||||
sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with "
|
||||
"code " << err.value() << ": " << strerror(err.value()) << std::endl;
|
||||
"code "
|
||||
<< err.value() << ": " << strerror(err.value()) << std::endl;
|
||||
if (err.value() == ENOTEMPTY) {
|
||||
return DIRECTORY_NOT_EMPTY;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return GENERIC_FILE_ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (std::filesystem::remove_all(path, err)) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with "
|
||||
"code " << err.value() << ": " << strerror(err.value()) << std::endl;
|
||||
"code "
|
||||
<< err.value() << ": " << strerror(err.value()) << std::endl;
|
||||
// Check error code
|
||||
if (err.value() == ENOTEMPTY) {
|
||||
return DIRECTORY_NOT_EMPTY;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return GENERIC_FILE_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,19 @@
|
||||
#ifndef BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_
|
||||
#define BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_
|
||||
|
||||
#include "SdCardManager.h"
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
#include "fsfw/ipc/MessageQueueIF.h"
|
||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/memory/HasFileSystemIF.h"
|
||||
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "SdCardManager.h"
|
||||
#include "fsfw/ipc/MessageQueueIF.h"
|
||||
#include "fsfw/memory/HasFileSystemIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||
|
||||
class CoreController;
|
||||
|
||||
class FileSystemHandler: public SystemObject,
|
||||
public ExecutableObjectIF,
|
||||
public HasFileSystemIF {
|
||||
class FileSystemHandler : public SystemObject, public ExecutableObjectIF, public HasFileSystemIF {
|
||||
public:
|
||||
struct FsCommandCfg : public FileSystemArgsIF {
|
||||
// Can be used to automatically use mount prefix of active SD card.
|
||||
@ -36,18 +33,19 @@ public:
|
||||
* @return MessageQueueId_t of the object
|
||||
*/
|
||||
MessageQueueId_t getCommandQueue() const override;
|
||||
ReturnValue_t appendToFile(const char* repositoryPath,
|
||||
const char* filename, const uint8_t* data, size_t size,
|
||||
uint16_t packetNumber, FileSystemArgsIF* args = nullptr) override;
|
||||
ReturnValue_t createFile(const char* repositoryPath,
|
||||
const char* filename, const uint8_t* data = nullptr,
|
||||
size_t size = 0, FileSystemArgsIF* args = nullptr) override;
|
||||
ReturnValue_t removeFile(const char* repositoryPath,
|
||||
const char* filename, FileSystemArgsIF* args = nullptr) override;
|
||||
ReturnValue_t appendToFile(const char* repositoryPath, const char* filename, const uint8_t* data,
|
||||
size_t size, uint16_t packetNumber,
|
||||
FileSystemArgsIF* args = nullptr) override;
|
||||
ReturnValue_t createFile(const char* repositoryPath, const char* filename,
|
||||
const uint8_t* data = nullptr, size_t size = 0,
|
||||
FileSystemArgsIF* args = nullptr) override;
|
||||
ReturnValue_t removeFile(const char* repositoryPath, const char* filename,
|
||||
FileSystemArgsIF* args = nullptr) override;
|
||||
ReturnValue_t createDirectory(const char* repositoryPath, const char* dirname,
|
||||
bool createParentDirs, FileSystemArgsIF* args = nullptr) override;
|
||||
ReturnValue_t removeDirectory(const char* repositoryPath, const char* dirname,
|
||||
bool deleteRecurively = false, FileSystemArgsIF* args = nullptr) override;
|
||||
bool deleteRecurively = false,
|
||||
FileSystemArgsIF* args = nullptr) override;
|
||||
ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename,
|
||||
const char* newFilename, FileSystemArgsIF* args = nullptr) override;
|
||||
|
||||
@ -66,6 +64,4 @@ private:
|
||||
void parseCfg(FsCommandCfg* cfg, bool& useMountPrefix);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* BSP_Q7S_MEMORY_FILESYSTEMMANAGER_H_ */
|
||||
|
@ -1,25 +1,22 @@
|
||||
#include "SdCardManager.h"
|
||||
#include "scratchApi.h"
|
||||
|
||||
#include "linux/utility/utility.h"
|
||||
|
||||
#include "fsfw/ipc/MutexFactory.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <filesystem>
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/ipc/MutexFactory.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "linux/utility/utility.h"
|
||||
#include "scratchApi.h"
|
||||
|
||||
SdCardManager* SdCardManager::factoryInstance = nullptr;
|
||||
|
||||
SdCardManager::SdCardManager(): cmdExecutor(256) {
|
||||
}
|
||||
SdCardManager::SdCardManager() : cmdExecutor(256) {}
|
||||
|
||||
SdCardManager::~SdCardManager() {
|
||||
}
|
||||
SdCardManager::~SdCardManager() {}
|
||||
|
||||
void SdCardManager::create() {
|
||||
if (factoryInstance == nullptr) {
|
||||
@ -39,7 +36,8 @@ ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCar
|
||||
if (not blocking) {
|
||||
sif::warning << "SdCardManager::switchOnSdCard: Two-step command but manager is"
|
||||
" not configured for blocking operation. "
|
||||
"Forcing blocking mode.." << std::endl;
|
||||
"Forcing blocking mode.."
|
||||
<< std::endl;
|
||||
blocking = true;
|
||||
}
|
||||
}
|
||||
@ -63,11 +61,9 @@ ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCar
|
||||
sd::SdState currentState;
|
||||
if (sdCard == sd::SdCard::SLOT_0) {
|
||||
currentState = statusPair->first;
|
||||
}
|
||||
else if(sdCard == sd::SdCard::SLOT_1) {
|
||||
} else if (sdCard == sd::SdCard::SLOT_1) {
|
||||
currentState = statusPair->second;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Should not happen
|
||||
currentState = sd::SdState::OFF;
|
||||
}
|
||||
@ -75,18 +71,14 @@ ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCar
|
||||
if (currentState == sd::SdState::ON) {
|
||||
if (not doMountSdCard) {
|
||||
return ALREADY_ON;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return mountSdCard(sdCard);
|
||||
}
|
||||
}
|
||||
else if(currentState == sd::SdState::MOUNTED) {
|
||||
} else if (currentState == sd::SdState::MOUNTED) {
|
||||
result = ALREADY_MOUNTED;
|
||||
}
|
||||
else if(currentState == sd::SdState::OFF) {
|
||||
} else if (currentState == sd::SdState::OFF) {
|
||||
result = setSdCardState(sdCard, true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -107,7 +99,8 @@ ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard, bool doUnmountSd
|
||||
if (doUnmountSdCard) {
|
||||
if (not blocking) {
|
||||
sif::warning << "SdCardManager::switchOffSdCard: Two-step command but manager is"
|
||||
" not configured for blocking operation. Forcing blocking mode.." << std::endl;
|
||||
" not configured for blocking operation. Forcing blocking mode.."
|
||||
<< std::endl;
|
||||
blocking = true;
|
||||
}
|
||||
}
|
||||
@ -121,8 +114,7 @@ ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard, bool doUnmountSd
|
||||
if (active.first == sd::SdState::OFF) {
|
||||
return ALREADY_OFF;
|
||||
}
|
||||
}
|
||||
else if(sdCard == sd::SdCard::SLOT_1) {
|
||||
} else if (sdCard == sd::SdCard::SLOT_1) {
|
||||
if (active.second == sd::SdState::OFF) {
|
||||
return ALREADY_OFF;
|
||||
}
|
||||
@ -147,15 +139,13 @@ ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) {
|
||||
string statestring = "";
|
||||
if (sdCard == sd::SdCard::SLOT_0) {
|
||||
sdstring = "0";
|
||||
}
|
||||
else if(sdCard == sd::SdCard::SLOT_1) {
|
||||
} else if (sdCard == sd::SdCard::SLOT_1) {
|
||||
sdstring = "1";
|
||||
}
|
||||
if (on) {
|
||||
currentOp = Operations::SWITCHING_ON;
|
||||
statestring = "on";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
currentOp = Operations::SWITCHING_OFF;
|
||||
statestring = "off";
|
||||
}
|
||||
@ -205,14 +195,14 @@ ReturnValue_t SdCardManager::mountSdCard(sd::SdCard sdCard) {
|
||||
if (sdCard == sd::SdCard::SLOT_0) {
|
||||
mountDev = SD_0_DEV_NAME;
|
||||
mountPoint = SD_0_MOUNT_POINT;
|
||||
}
|
||||
else if(sdCard == sd::SdCard::SLOT_1) {
|
||||
} else if (sdCard == sd::SdCard::SLOT_1) {
|
||||
mountDev = SD_1_DEV_NAME;
|
||||
mountPoint = SD_1_MOUNT_POINT;
|
||||
}
|
||||
if (not filesystem::exists(mountDev)) {
|
||||
sif::warning << "SdCardManager::mountSdCard: Device file does not exists. Make sure to"
|
||||
" turn on the SD card" << std::endl;
|
||||
" turn on the SD card"
|
||||
<< std::endl;
|
||||
return MOUNT_ERROR;
|
||||
}
|
||||
|
||||
@ -241,13 +231,12 @@ ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) {
|
||||
string mountPoint;
|
||||
if (sdCard == sd::SdCard::SLOT_0) {
|
||||
mountPoint = SD_0_MOUNT_POINT;
|
||||
}
|
||||
else if(sdCard == sd::SdCard::SLOT_1) {
|
||||
} else if (sdCard == sd::SdCard::SLOT_1) {
|
||||
mountPoint = SD_1_MOUNT_POINT;
|
||||
}
|
||||
if (not filesystem::exists(mountPoint)) {
|
||||
sif::error << "SdCardManager::unmountSdCard: Default mount point " << mountPoint <<
|
||||
"does not exist" << std::endl;
|
||||
sif::error << "SdCardManager::unmountSdCard: Default mount point " << mountPoint
|
||||
<< "does not exist" << std::endl;
|
||||
return UNMOUNT_ERROR;
|
||||
}
|
||||
if (filesystem::is_empty(mountPoint)) {
|
||||
@ -278,7 +267,8 @@ ReturnValue_t SdCardManager::sanitizeState(SdStatePair* statusPair, sd::SdCard p
|
||||
}
|
||||
if (prefSdCard == sd::SdCard::NONE) {
|
||||
result = getPreferredSdCard(prefSdCard);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {}
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
}
|
||||
}
|
||||
if (statusPair == nullptr) {
|
||||
sdStatusPtr = std::make_unique<SdStatePair>();
|
||||
@ -325,16 +315,13 @@ void SdCardManager::processSdStatusLine(std::pair<sd::SdState, sd::SdState> &act
|
||||
if (word == "on") {
|
||||
if (currentSd == sd::SdCard::SLOT_0) {
|
||||
active.first = sd::SdState::ON;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
active.second = sd::SdState::ON;
|
||||
}
|
||||
}
|
||||
else if (word == "off") {
|
||||
} else if (word == "off") {
|
||||
if (currentSd == sd::SdCard::SLOT_0) {
|
||||
active.first = sd::SdState::OFF;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
active.second = sd::SdState::OFF;
|
||||
}
|
||||
}
|
||||
@ -343,15 +330,15 @@ void SdCardManager::processSdStatusLine(std::pair<sd::SdState, sd::SdState> &act
|
||||
if (mountLine) {
|
||||
if (currentSd == sd::SdCard::SLOT_0) {
|
||||
active.first = sd::SdState::MOUNTED;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
active.second = sd::SdState::MOUNTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (idx > 5) {
|
||||
sif::warning << "SdCardManager::sdCardActive: /tmp/sd_status.txt has more than 6 "
|
||||
"lines and might be invalid!" << std::endl;
|
||||
"lines and might be invalid!"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
idx++;
|
||||
@ -397,8 +384,7 @@ std::string SdCardManager::getCurrentMountPrefix(sd::SdCard prefSdCard) {
|
||||
}
|
||||
if (prefSdCard == sd::SdCard::SLOT_0) {
|
||||
return SD_0_MOUNT_POINT;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return SD_1_MOUNT_POINT;
|
||||
}
|
||||
}
|
||||
@ -446,14 +432,9 @@ SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations ¤tOp) {
|
||||
}
|
||||
}
|
||||
|
||||
void SdCardManager::setBlocking(bool blocking) {
|
||||
this->blocking = blocking;
|
||||
}
|
||||
void SdCardManager::setBlocking(bool blocking) { this->blocking = blocking; }
|
||||
|
||||
void SdCardManager::setPrintCommandOutput(bool print) {
|
||||
this->printCmdOutput = print;
|
||||
|
||||
}
|
||||
void SdCardManager::setPrintCommandOutput(bool print) { this->printCmdOutput = print; }
|
||||
|
||||
bool SdCardManager::isSdCardMounted(sd::SdCard sdCard) {
|
||||
SdCardManager::SdStatePair active;
|
||||
@ -465,23 +446,17 @@ bool SdCardManager::isSdCardMounted(sd::SdCard sdCard) {
|
||||
if (sdCard == sd::SLOT_0) {
|
||||
if (active.first == sd::MOUNTED) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (sdCard == sd::SLOT_1) {
|
||||
} else if (sdCard == sd::SLOT_1) {
|
||||
if (active.second == sd::MOUNTED) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::debug << "SdCardManager::isSdCardMounted: Unknown SD card specified" << std::endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,21 +1,20 @@
|
||||
#ifndef BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_
|
||||
#define BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_
|
||||
|
||||
#include "fsfw_hal/linux/CommandExecutor.h"
|
||||
#include "definitions.h"
|
||||
#include "returnvalues/classIds.h"
|
||||
#include "events/subsystemIdRanges.h"
|
||||
|
||||
#include "fsfw/events/Event.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
#include <poll.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "definitions.h"
|
||||
#include "events/subsystemIdRanges.h"
|
||||
#include "fsfw/events/Event.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw_hal/linux/CommandExecutor.h"
|
||||
#include "returnvalues/classIds.h"
|
||||
|
||||
class MutexIF;
|
||||
|
||||
@ -25,41 +24,26 @@ class MutexIF;
|
||||
*/
|
||||
class SdCardManager {
|
||||
friend class SdCardAccess;
|
||||
public:
|
||||
enum class Operations {
|
||||
SWITCHING_ON,
|
||||
SWITCHING_OFF,
|
||||
MOUNTING,
|
||||
UNMOUNTING,
|
||||
IDLE
|
||||
};
|
||||
|
||||
enum class OpStatus {
|
||||
IDLE,
|
||||
TIMEOUT,
|
||||
ONGOING,
|
||||
SUCCESS,
|
||||
FAIL
|
||||
};
|
||||
public:
|
||||
enum class Operations { SWITCHING_ON, SWITCHING_OFF, MOUNTING, UNMOUNTING, IDLE };
|
||||
|
||||
enum class OpStatus { IDLE, TIMEOUT, ONGOING, SUCCESS, FAIL };
|
||||
|
||||
using SdStatePair = std::pair<sd::SdState, sd::SdState>;
|
||||
|
||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::SD_CARD_MANAGER;
|
||||
|
||||
static constexpr ReturnValue_t OP_ONGOING =
|
||||
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0);
|
||||
static constexpr ReturnValue_t ALREADY_ON =
|
||||
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1);
|
||||
static constexpr ReturnValue_t OP_ONGOING = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0);
|
||||
static constexpr ReturnValue_t ALREADY_ON = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1);
|
||||
static constexpr ReturnValue_t ALREADY_MOUNTED =
|
||||
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2);
|
||||
static constexpr ReturnValue_t ALREADY_OFF =
|
||||
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3);
|
||||
static constexpr ReturnValue_t ALREADY_OFF = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3);
|
||||
static constexpr ReturnValue_t STATUS_FILE_NEXISTS =
|
||||
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 10);
|
||||
static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID =
|
||||
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 11);
|
||||
static constexpr ReturnValue_t MOUNT_ERROR =
|
||||
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 12);
|
||||
static constexpr ReturnValue_t MOUNT_ERROR = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 12);
|
||||
static constexpr ReturnValue_t UNMOUNT_ERROR =
|
||||
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 13);
|
||||
static constexpr ReturnValue_t SYSTEM_CALL_ERROR =
|
||||
@ -204,6 +188,7 @@ public:
|
||||
* @return true if mounted, otherwise false
|
||||
*/
|
||||
bool isSdCardMounted(sd::SdCard sdCard);
|
||||
|
||||
private:
|
||||
CommandExecutor cmdExecutor;
|
||||
Operations currentOp = Operations::IDLE;
|
||||
|
@ -12,15 +12,8 @@ enum SdState: uint8_t {
|
||||
MOUNTED = 2
|
||||
};
|
||||
|
||||
enum SdCard: uint8_t {
|
||||
SLOT_0 = 0,
|
||||
SLOT_1 = 1,
|
||||
BOTH,
|
||||
NONE
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
enum SdCard : uint8_t { SLOT_0 = 0, SLOT_1 = 1, BOTH, NONE };
|
||||
|
||||
} // namespace sd
|
||||
|
||||
#endif /* BSP_Q7S_MEMORY_DEFINITIONS_H_ */
|
||||
|
@ -28,7 +28,8 @@ ReturnValue_t scratch::readString(std::string key, std::string &string) {
|
||||
size_t pos = line.find("=");
|
||||
if (pos == std::string::npos) {
|
||||
sif::warning << "scratch::readNumber: Output file format invalid, "
|
||||
"no \"=\" found" << std::endl;
|
||||
"no \"=\" found"
|
||||
<< std::endl;
|
||||
// Could not find value
|
||||
std::remove(filename.c_str());
|
||||
return KEY_NOT_FOUND;
|
||||
|
@ -1,17 +1,17 @@
|
||||
#ifndef BSP_Q7S_MEMORY_SCRATCHAPI_H_
|
||||
#define BSP_Q7S_MEMORY_SCRATCHAPI_H_
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "linux/utility/utility.h"
|
||||
#include "returnvalues/classIds.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
#include <cstdlib>
|
||||
|
||||
/**
|
||||
* @brief API for the scratch buffer
|
||||
*/
|
||||
@ -62,7 +62,6 @@ inline ReturnValue_t writeNumber(std::string key, T num) noexcept;
|
||||
template <typename T, class = typename std::enable_if<std::is_integral<T>::value>::type>
|
||||
inline ReturnValue_t readNumber(std::string key, T& num) noexcept;
|
||||
|
||||
|
||||
// Anonymous namespace
|
||||
namespace {
|
||||
|
||||
@ -81,8 +80,7 @@ ReturnValue_t readToFile(std::string name, std::ifstream& file, std::string& fil
|
||||
// Could not find value
|
||||
std::remove(filename.c_str());
|
||||
return KEY_NOT_FOUND;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
utility::handleSystemError(result, "scratch::readNumber");
|
||||
std::remove(filename.c_str());
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
@ -126,7 +124,8 @@ inline ReturnValue_t readNumber(std::string key, T& num) noexcept {
|
||||
size_t pos = line.find("=");
|
||||
if (pos == string::npos) {
|
||||
sif::warning << "scratch::readNumber: Output file format invalid, "
|
||||
"no \"=\" found" << std::endl;
|
||||
"no \"=\" found"
|
||||
<< std::endl;
|
||||
// Could not find value
|
||||
std::remove(filename.c_str());
|
||||
return KEY_NOT_FOUND;
|
||||
@ -134,8 +133,7 @@ inline ReturnValue_t readNumber(std::string key, T& num) noexcept {
|
||||
std::string valueAsString = line.substr(pos + 1);
|
||||
try {
|
||||
num = std::stoi(valueAsString);
|
||||
}
|
||||
catch(std::invalid_argument& e) {
|
||||
} catch (std::invalid_argument& e) {
|
||||
sif::warning << "scratch::readNumber: stoi call failed with " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
@ -143,6 +141,6 @@ inline ReturnValue_t readNumber(std::string key, T& num) noexcept {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace scratch
|
||||
|
||||
#endif /* BSP_Q7S_MEMORY_SCRATCHAPI_H_ */
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "simple.h"
|
||||
|
||||
#include "q7sConfig.h"
|
||||
|
||||
#if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1
|
||||
@ -8,9 +9,7 @@
|
||||
int simple::simple() {
|
||||
cout << "-- Q7S Simple Application --" << endl;
|
||||
#if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1
|
||||
{
|
||||
FileSystemTest fileSystemTest;
|
||||
}
|
||||
{ FileSystemTest fileSystemTest; }
|
||||
#endif
|
||||
|
||||
#if TE0720_GPIO_TEST
|
||||
@ -18,4 +17,3 @@ int simple::simple() {
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#include <bsp_q7s/spi/Q7sSpiComIF.h>
|
||||
|
||||
Q7sSpiComIF::Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF) :
|
||||
SpiComIF(objectId, gpioComIF) {
|
||||
}
|
||||
|
||||
Q7sSpiComIF::~Q7sSpiComIF() {
|
||||
}
|
||||
Q7sSpiComIF::Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF) : SpiComIF(objectId, gpioComIF) {}
|
||||
|
||||
Q7sSpiComIF::~Q7sSpiComIF() {}
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <fsfw_hal/linux/spi/SpiComIF.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief This additional communication interface is required because the SPI busses behind the
|
||||
* devices "/dev/spi2.0" and "dev/spidev3.0" are multiplexed to one SPI interface.
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "GpioCookie.h"
|
||||
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
|
||||
GpioCookie::GpioCookie() {
|
||||
}
|
||||
GpioCookie::GpioCookie() {}
|
||||
|
||||
ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) {
|
||||
if (gpioConfig == nullptr) {
|
||||
@ -14,8 +14,8 @@ ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig){
|
||||
auto statusPair = gpioMap.emplace(gpioId, gpioConfig);
|
||||
if (statusPair.second == false) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
sif::error << "GpioCookie::addGpio: Failed to add GPIO " << gpioId <<
|
||||
" to GPIO map" << std::endl;
|
||||
sif::error << "GpioCookie::addGpio: Failed to add GPIO " << gpioId << " to GPIO map"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
@ -27,8 +27,6 @@ ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
GpioMap GpioCookie::getGpioMap() const {
|
||||
return gpioMap;
|
||||
}
|
||||
GpioMap GpioCookie::getGpioMap() const { return gpioMap; }
|
||||
|
||||
GpioCookie::~GpioCookie() {}
|
||||
|
@ -1,11 +1,12 @@
|
||||
#ifndef LINUX_GPIO_GPIOCOOKIE_H_
|
||||
#define LINUX_GPIO_GPIOCOOKIE_H_
|
||||
|
||||
#include "GpioIF.h"
|
||||
#include "gpioDefinitions.h"
|
||||
#include <fsfw/devicehandlers/CookieIF.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
|
||||
#include "GpioIF.h"
|
||||
#include "gpioDefinitions.h"
|
||||
|
||||
/**
|
||||
* @brief Cookie for the GpioIF. Allows the GpioIF to determine which
|
||||
* GPIOs to initialize and whether they should be configured as in- or
|
||||
@ -18,7 +19,6 @@
|
||||
*/
|
||||
class GpioCookie : public CookieIF {
|
||||
public:
|
||||
|
||||
GpioCookie();
|
||||
|
||||
virtual ~GpioCookie();
|
||||
|
@ -1,9 +1,10 @@
|
||||
#ifndef LINUX_GPIO_GPIOIF_H_
|
||||
#define LINUX_GPIO_GPIOIF_H_
|
||||
|
||||
#include "gpioDefinitions.h"
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <fsfw/devicehandlers/CookieIF.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
|
||||
#include "gpioDefinitions.h"
|
||||
|
||||
class GpioCookie;
|
||||
|
||||
@ -14,7 +15,6 @@ class GpioCookie;
|
||||
*/
|
||||
class GpioIF : public HasReturnvaluesIF {
|
||||
public:
|
||||
|
||||
virtual ~GpioIF(){};
|
||||
|
||||
/**
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "LinuxLibgpioIF.h"
|
||||
#include "GpioCookie.h"
|
||||
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <gpiod.h>
|
||||
#include <linux/gpio/gpioDefinitions.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <utility>
|
||||
#include <unistd.h>
|
||||
#include <gpiod.h>
|
||||
|
||||
#include "GpioCookie.h"
|
||||
|
||||
LinuxLibgpioIF::LinuxLibgpioIF(object_id_t objectId) : SystemObject(objectId) {
|
||||
struct gpiod_chip* chip = gpiod_chip_open_by_label("/amba_pl/gpio@42030000");
|
||||
@ -15,8 +15,7 @@ LinuxLibgpioIF::LinuxLibgpioIF(object_id_t objectId) : SystemObject(objectId) {
|
||||
sif::debug << chip->name << std::endl;
|
||||
}
|
||||
|
||||
LinuxLibgpioIF::~LinuxLibgpioIF() {
|
||||
}
|
||||
LinuxLibgpioIF::~LinuxLibgpioIF() {}
|
||||
|
||||
ReturnValue_t LinuxLibgpioIF::addGpios(GpioCookie* gpioCookie) {
|
||||
ReturnValue_t result;
|
||||
@ -83,16 +82,16 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular
|
||||
chipname = regularGpio->chipname;
|
||||
chip = gpiod_chip_open_by_name(chipname.c_str());
|
||||
if (!chip) {
|
||||
sif::error << "LinuxLibgpioIF::configureGpios: Failed to open chip "
|
||||
<< chipname << ". Gpio ID: " << gpioId << std::endl;
|
||||
sif::error << "LinuxLibgpioIF::configureGpios: Failed to open chip " << chipname
|
||||
<< ". Gpio ID: " << gpioId << std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
lineNum = regularGpio->lineNum;
|
||||
lineHandle = gpiod_chip_get_line(chip, lineNum);
|
||||
if (!lineHandle) {
|
||||
sif::error << "LinuxLibgpioIF::configureGpios: Failed to open line for GPIO with id "
|
||||
<< gpioId << std::endl;
|
||||
sif::error << "LinuxLibgpioIF::configureGpios: Failed to open line for GPIO with id " << gpioId
|
||||
<< std::endl;
|
||||
gpiod_chip_close(chip);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
@ -102,11 +101,10 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular
|
||||
/* Configure direction and add a description to the GPIO */
|
||||
switch (direction) {
|
||||
case (gpio::OUT): {
|
||||
result = gpiod_line_request_output(lineHandle, consumer.c_str(),
|
||||
regularGpio->initValue);
|
||||
result = gpiod_line_request_output(lineHandle, consumer.c_str(), regularGpio->initValue);
|
||||
if (result < 0) {
|
||||
sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " << lineNum <<
|
||||
" from GPIO instance with ID: " << gpioId << std::endl;
|
||||
sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " << lineNum
|
||||
<< " from GPIO instance with ID: " << gpioId << std::endl;
|
||||
gpiod_line_release(lineHandle);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
@ -115,19 +113,17 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular
|
||||
case (gpio::IN): {
|
||||
result = gpiod_line_request_input(lineHandle, consumer.c_str());
|
||||
if (result < 0) {
|
||||
sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line "
|
||||
<< lineNum << " from GPIO instance with ID: " << gpioId << std::endl;
|
||||
sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " << lineNum
|
||||
<< " from GPIO instance with ID: " << gpioId << std::endl;
|
||||
gpiod_line_release(lineHandle);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified"
|
||||
<< std::endl;
|
||||
sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified" << std::endl;
|
||||
return GPIO_INVALID_INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Write line handle to GPIO configuration instance so it can later be used to set or
|
||||
@ -146,14 +142,13 @@ ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) {
|
||||
|
||||
if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) {
|
||||
return driveGpio(gpioId, dynamic_cast<GpiodRegular*>(gpioMapIter->second), 1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
auto gpioCallback = dynamic_cast<GpioCallback*>(gpioMapIter->second);
|
||||
if (gpioCallback->callback == nullptr) {
|
||||
return GPIO_INVALID_INSTANCE;
|
||||
}
|
||||
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE,
|
||||
1, gpioCallback->callbackArgs);
|
||||
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, 1,
|
||||
gpioCallback->callbackArgs);
|
||||
}
|
||||
return GPIO_TYPE_FAILURE;
|
||||
}
|
||||
@ -167,28 +162,27 @@ ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) {
|
||||
|
||||
if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) {
|
||||
return driveGpio(gpioId, dynamic_cast<GpiodRegular*>(gpioMapIter->second), 0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
auto gpioCallback = dynamic_cast<GpioCallback*>(gpioMapIter->second);
|
||||
if (gpioCallback->callback == nullptr) {
|
||||
return GPIO_INVALID_INSTANCE;
|
||||
}
|
||||
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE,
|
||||
0, gpioCallback->callbackArgs);
|
||||
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, 0,
|
||||
gpioCallback->callbackArgs);
|
||||
}
|
||||
return GPIO_TYPE_FAILURE;
|
||||
}
|
||||
|
||||
ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId,
|
||||
GpiodRegular* regularGpio, unsigned int logicLevel) {
|
||||
ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, GpiodRegular* regularGpio,
|
||||
unsigned int logicLevel) {
|
||||
if (regularGpio == nullptr) {
|
||||
return GPIO_TYPE_FAILURE;
|
||||
}
|
||||
|
||||
int result = gpiod_line_set_value(regularGpio->lineHandle, logicLevel);
|
||||
if (result < 0) {
|
||||
sif::warning << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID " << gpioId <<
|
||||
" to logic level " << logicLevel << std::endl;
|
||||
sif::warning << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID " << gpioId
|
||||
<< " to logic level " << logicLevel << std::endl;
|
||||
return DRIVE_GPIO_FAILURE;
|
||||
}
|
||||
|
||||
@ -208,11 +202,8 @@ ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) {
|
||||
return GPIO_TYPE_FAILURE;
|
||||
}
|
||||
*gpioState = gpiod_line_get_value(regularGpio->lineHandle);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
|
||||
return RETURN_OK;
|
||||
}
|
||||
@ -247,22 +238,22 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd){
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t LinuxLibgpioIF::checkForConflictsRegularGpio(gpioId_t gpioIdToCheck,
|
||||
GpiodRegular* gpioToCheck, GpioMap& mapToAdd) {
|
||||
GpiodRegular* gpioToCheck,
|
||||
GpioMap& mapToAdd) {
|
||||
/* Cross check with private map */
|
||||
gpioMapIter = gpioMap.find(gpioIdToCheck);
|
||||
if (gpioMapIter != gpioMap.end()) {
|
||||
if (gpioMapIter->second->gpioType != gpio::GpioTypes::GPIOD_REGULAR) {
|
||||
sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different "
|
||||
"GPIO type" << gpioIdToCheck << ". Removing duplicate." << std::endl;
|
||||
"GPIO type"
|
||||
<< gpioIdToCheck << ". Removing duplicate." << std::endl;
|
||||
mapToAdd.erase(gpioIdToCheck);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
@ -281,13 +272,15 @@ ReturnValue_t LinuxLibgpioIF::checkForConflictsRegularGpio(gpioId_t gpioIdToChec
|
||||
}
|
||||
|
||||
ReturnValue_t LinuxLibgpioIF::checkForConflictsCallbackGpio(gpioId_t gpioIdToCheck,
|
||||
GpioCallback *callbackGpio, GpioMap& mapToAdd) {
|
||||
GpioCallback* callbackGpio,
|
||||
GpioMap& mapToAdd) {
|
||||
/* Cross check with private map */
|
||||
gpioMapIter = gpioMap.find(gpioIdToCheck);
|
||||
if (gpioMapIter != gpioMap.end()) {
|
||||
if (gpioMapIter->second->gpioType != gpio::GpioTypes::CALLBACK) {
|
||||
sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different "
|
||||
"GPIO type" << gpioIdToCheck << ". Removing duplicate." << std::endl;
|
||||
"GPIO type"
|
||||
<< gpioIdToCheck << ". Removing duplicate." << std::endl;
|
||||
mapToAdd.erase(gpioIdToCheck);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
#ifndef LINUX_GPIO_LINUXLIBGPIOIF_H_
|
||||
#define LINUX_GPIO_LINUXLIBGPIOIF_H_
|
||||
|
||||
#include <linux/gpio/GpioIF.h>
|
||||
#include <fsfwconfig/returnvalues/classIds.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfwconfig/returnvalues/classIds.h>
|
||||
#include <linux/gpio/GpioIF.h>
|
||||
|
||||
class GpioCookie;
|
||||
|
||||
@ -16,7 +16,6 @@ class GpioCookie;
|
||||
*/
|
||||
class LinuxLibgpioIF : public GpioIF, public SystemObject {
|
||||
public:
|
||||
|
||||
static const uint8_t gpioRetvalId = CLASS_ID::LINUX_LIBGPIO_IF;
|
||||
|
||||
static constexpr ReturnValue_t UNKNOWN_GPIO_ID =
|
||||
@ -71,7 +70,6 @@ private:
|
||||
* @brief Performs the initial configuration of all GPIOs specified in the GpioMap mapToAdd.
|
||||
*/
|
||||
ReturnValue_t configureGpios(GpioMap& mapToAdd);
|
||||
|
||||
};
|
||||
|
||||
#endif /* LINUX_GPIO_LINUXLIBGPIOIF_H_ */
|
||||
|
@ -8,29 +8,16 @@ using gpioId_t = uint16_t;
|
||||
|
||||
namespace gpio {
|
||||
|
||||
enum Levels {
|
||||
LOW = 0,
|
||||
HIGH = 1
|
||||
};
|
||||
enum Levels { LOW = 0, HIGH = 1 };
|
||||
|
||||
enum Direction {
|
||||
IN = 0,
|
||||
OUT = 1
|
||||
};
|
||||
enum Direction { IN = 0, OUT = 1 };
|
||||
|
||||
enum GpioOperation {
|
||||
READ,
|
||||
WRITE
|
||||
};
|
||||
enum GpioOperation { READ, WRITE };
|
||||
|
||||
enum GpioTypes {
|
||||
NONE,
|
||||
GPIOD_REGULAR,
|
||||
CALLBACK
|
||||
};
|
||||
enum GpioTypes { NONE, GPIOD_REGULAR, CALLBACK };
|
||||
|
||||
static constexpr gpioId_t NO_GPIO = -1;
|
||||
}
|
||||
} // namespace gpio
|
||||
|
||||
/**
|
||||
* @brief Struct containing information about the GPIO to use. This is
|
||||
@ -48,12 +35,10 @@ static constexpr gpioId_t NO_GPIO = -1;
|
||||
*/
|
||||
class GpioBase {
|
||||
public:
|
||||
|
||||
GpioBase() = default;
|
||||
|
||||
GpioBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction,
|
||||
int initValue):
|
||||
gpioType(gpioType), consumer(consumer),direction(direction), initValue(initValue) {}
|
||||
GpioBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction, int initValue)
|
||||
: gpioType(gpioType), consumer(consumer), direction(direction), initValue(initValue) {}
|
||||
|
||||
virtual ~GpioBase(){};
|
||||
|
||||
@ -66,13 +51,14 @@ public:
|
||||
|
||||
class GpiodRegular : public GpioBase {
|
||||
public:
|
||||
GpiodRegular(): GpioBase(gpio::GpioTypes::GPIOD_REGULAR, std::string(),
|
||||
gpio::Direction::IN, 0) {};
|
||||
GpiodRegular()
|
||||
: GpioBase(gpio::GpioTypes::GPIOD_REGULAR, std::string(), gpio::Direction::IN, 0){};
|
||||
|
||||
GpiodRegular(std::string chipname_, int lineNum_, std::string consumer_,
|
||||
gpio::Direction direction_, int initValue_):
|
||||
GpioBase(gpio::GpioTypes::GPIOD_REGULAR, consumer_, direction_, initValue_),
|
||||
chipname(chipname_), lineNum(lineNum_) {}
|
||||
gpio::Direction direction_, int initValue_)
|
||||
: GpioBase(gpio::GpioTypes::GPIOD_REGULAR, consumer_, direction_, initValue_),
|
||||
chipname(chipname_),
|
||||
lineNum(lineNum_) {}
|
||||
std::string chipname;
|
||||
int lineNum = 0;
|
||||
struct gpiod_line* lineHandle = nullptr;
|
||||
@ -82,16 +68,15 @@ class GpioCallback: public GpioBase {
|
||||
public:
|
||||
GpioCallback(std::string consumer, gpio::Direction direction_, int initValue_,
|
||||
void (*callback)(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args),
|
||||
void* callbackArgs):
|
||||
GpioBase(gpio::GpioTypes::CALLBACK, consumer, direction_, initValue_),
|
||||
callback(callback), callbackArgs(callbackArgs) {}
|
||||
void* callbackArgs)
|
||||
: GpioBase(gpio::GpioTypes::CALLBACK, consumer, direction_, initValue_),
|
||||
callback(callback),
|
||||
callbackArgs(callbackArgs) {}
|
||||
|
||||
void (* callback) (gpioId_t gpioId, gpio::GpioOperation gpioOp,
|
||||
int value, void* args) = nullptr;
|
||||
void (*callback)(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args) = nullptr;
|
||||
void* callbackArgs = nullptr;
|
||||
};
|
||||
|
||||
|
||||
using GpioMap = std::unordered_map<gpioId_t, GpioBase*>;
|
||||
using GpioMapIter = GpioMap::iterator;
|
||||
|
||||
|
@ -1,17 +1,18 @@
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <linux/obc/Ptme.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
CCSDSIPCoreBridge::CCSDSIPCoreBridge(object_id_t objectId, object_id_t tcDestination,
|
||||
object_id_t tmStoreId, object_id_t tcStoreId, LinuxLibgpioIF* gpioComIF,
|
||||
std::string uioPtme, gpioId_t papbBusyId, gpioId_t papbEmptyId) :
|
||||
TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId), gpioComIF(gpioComIF), uioPtme(
|
||||
uioPtme), papbBusyId(papbBusyId), papbEmptyId(papbEmptyId) {
|
||||
}
|
||||
object_id_t tmStoreId, object_id_t tcStoreId,
|
||||
LinuxLibgpioIF* gpioComIF, std::string uioPtme,
|
||||
gpioId_t papbBusyId, gpioId_t papbEmptyId)
|
||||
: TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId),
|
||||
gpioComIF(gpioComIF),
|
||||
uioPtme(uioPtme),
|
||||
papbBusyId(papbBusyId),
|
||||
papbEmptyId(papbEmptyId) {}
|
||||
|
||||
CCSDSIPCoreBridge::~CCSDSIPCoreBridge() {
|
||||
}
|
||||
CCSDSIPCoreBridge::~CCSDSIPCoreBridge() {}
|
||||
|
||||
ReturnValue_t CCSDSIPCoreBridge::initialize() {
|
||||
ReturnValue_t result = TmTcBridge::initialize();
|
||||
@ -26,8 +27,8 @@ ReturnValue_t CCSDSIPCoreBridge::initialize() {
|
||||
* Map uio device in virtual address space
|
||||
* PROT_WRITE: Map uio device in writable only mode
|
||||
*/
|
||||
ptmeBaseAddress = static_cast<uint32_t*>(mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, fd, 0));
|
||||
ptmeBaseAddress =
|
||||
static_cast<uint32_t*>(mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0));
|
||||
|
||||
if (ptmeBaseAddress == MAP_FAILED) {
|
||||
sif::error << "CCSDSIPCoreBridge::initialize: Failed to map uio address" << std::endl;
|
||||
@ -38,17 +39,14 @@ ReturnValue_t CCSDSIPCoreBridge::initialize() {
|
||||
}
|
||||
|
||||
ReturnValue_t CCSDSIPCoreBridge::handleTm() {
|
||||
|
||||
#if OBSW_TEST_CCSDS_PTME == 1
|
||||
return sendTestFrame();
|
||||
#else
|
||||
return TmTcBridge::handleTm();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t* data, size_t dataLen) {
|
||||
|
||||
if (pollPapbBusySignal() == RETURN_OK) {
|
||||
startPacketTransfer();
|
||||
}
|
||||
@ -56,8 +54,7 @@ ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t * data, size_t dataLen) {
|
||||
for (size_t idx = 0; idx < dataLen; idx++) {
|
||||
if (pollPapbBusySignal() == RETURN_OK) {
|
||||
*(ptmeBaseAddress + PTME_DATA_REG_OFFSET) = static_cast<uint32_t>(*(data + idx));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::debug << "CCSDSIPCoreBridge::sendTm: Only written " << idx - 1 << " of " << dataLen
|
||||
<< " data" << std::endl;
|
||||
return RETURN_FAILED;
|
||||
@ -70,13 +67,9 @@ ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t * data, size_t dataLen) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void CCSDSIPCoreBridge::startPacketTransfer() {
|
||||
*ptmeBaseAddress = PTME_CONFIG_START;
|
||||
}
|
||||
void CCSDSIPCoreBridge::startPacketTransfer() { *ptmeBaseAddress = PTME_CONFIG_START; }
|
||||
|
||||
void CCSDSIPCoreBridge::endPacketTransfer() {
|
||||
*ptmeBaseAddress = PTME_CONFIG_END;
|
||||
}
|
||||
void CCSDSIPCoreBridge::endPacketTransfer() { *ptmeBaseAddress = PTME_CONFIG_END; }
|
||||
|
||||
ReturnValue_t CCSDSIPCoreBridge::pollPapbBusySignal() {
|
||||
int papbBusyState = 0;
|
||||
@ -111,8 +104,7 @@ void CCSDSIPCoreBridge::isPtmeBufferEmpty() {
|
||||
|
||||
if (papbEmptyState == 1) {
|
||||
sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is empty" << std::endl;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is not empty" << std::endl;
|
||||
}
|
||||
return;
|
||||
|
@ -1,13 +1,14 @@
|
||||
#ifndef MISSION_OBC_CCSDSIPCOREBRIDGE_H_
|
||||
#define MISSION_OBC_CCSDSIPCOREBRIDGE_H_
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include <fsfw/tmtcservices/TmTcBridge.h>
|
||||
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
|
||||
#include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
/**
|
||||
* @brief This class handles the interfacing to the telemetry (PTME) and telecommand (PDEC) IP
|
||||
* cores responsible for the CCSDS encoding and decoding. The IP cores are implemented
|
||||
@ -38,7 +39,6 @@ public:
|
||||
ReturnValue_t initialize() override;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Overwriting this function to provide the capability of testing the PTME IP Core
|
||||
* implementation.
|
||||
@ -48,12 +48,10 @@ protected:
|
||||
virtual ReturnValue_t sendTm(const uint8_t* data, size_t dataLen) override;
|
||||
|
||||
private:
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE;
|
||||
|
||||
static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0);
|
||||
|
||||
|
||||
/** Size of mapped address space. 4k (minimal size of pl device) */
|
||||
// static const int MAP_SIZE = 0xFA0;
|
||||
static const int MAP_SIZE = 0x1000;
|
||||
|
@ -1,8 +1,5 @@
|
||||
#include <linux/boardtest/I2cTestClass.h>
|
||||
|
||||
I2cTestClass::I2cTestClass(object_id_t objectId): TestTask(objectId) {
|
||||
}
|
||||
I2cTestClass::I2cTestClass(object_id_t objectId) : TestTask(objectId) {}
|
||||
|
||||
ReturnValue_t I2cTestClass::performPeriodicAction() {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
ReturnValue_t I2cTestClass::performPeriodicAction() { return HasReturnvaluesIF::RETURN_OK; }
|
||||
|
@ -8,10 +8,8 @@ public:
|
||||
I2cTestClass(object_id_t objectId);
|
||||
|
||||
ReturnValue_t performPeriodicAction() override;
|
||||
private:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* LINUX_BOARDTEST_I2CTESTCLASS_H_ */
|
||||
|
@ -1,15 +1,13 @@
|
||||
#include "LibgpiodTest.h"
|
||||
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
|
||||
#include "devices/gpioIds.h"
|
||||
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
|
||||
LibgpiodTest::LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId,
|
||||
GpioCookie* gpioCookie):
|
||||
TestTask(objectId) {
|
||||
|
||||
LibgpiodTest::LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie)
|
||||
: TestTask(objectId) {
|
||||
gpioInterface = ObjectManager::instance()->get<GpioIF>(gpioIfobjectId);
|
||||
if (gpioInterface == nullptr) {
|
||||
sif::error << "LibgpiodTest::LibgpiodTest: Invalid Gpio interface." << std::endl;
|
||||
@ -18,8 +16,7 @@ LibgpiodTest::LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId,
|
||||
testCase = TestCases::BLINK;
|
||||
}
|
||||
|
||||
LibgpiodTest::~LibgpiodTest() {
|
||||
}
|
||||
LibgpiodTest::~LibgpiodTest() {}
|
||||
|
||||
ReturnValue_t LibgpiodTest::performPeriodicAction() {
|
||||
int gpioState;
|
||||
@ -29,11 +26,9 @@ ReturnValue_t LibgpiodTest::performPeriodicAction() {
|
||||
case (TestCases::READ): {
|
||||
result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio "
|
||||
<< std::endl;
|
||||
sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " << std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::debug << "LibgpiodTest::performPeriodicAction: MIO 0 state = " << gpioState
|
||||
<< std::endl;
|
||||
}
|
||||
@ -45,8 +40,7 @@ ReturnValue_t LibgpiodTest::performPeriodicAction() {
|
||||
case (TestCases::BLINK): {
|
||||
result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio "
|
||||
<< std::endl;
|
||||
sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " << std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
if (gpioState == 1) {
|
||||
@ -56,16 +50,14 @@ ReturnValue_t LibgpiodTest::performPeriodicAction() {
|
||||
<< std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
else if (gpioState == 0) {
|
||||
} else if (gpioState == 0) {
|
||||
result = gpioInterface->pullHigh(gpioIds::TEST_ID_0);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO high!"
|
||||
<< std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sif::warning << "LibgpiodTest::performPeriodicAction: Invalid GPIO state" << std::endl;
|
||||
}
|
||||
|
||||
@ -76,7 +68,6 @@ ReturnValue_t LibgpiodTest::performPeriodicAction() {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
@ -95,9 +86,9 @@ ReturnValue_t LibgpiodTest::performOneShotAction() {
|
||||
result = gpioInterface->pullHigh(gpioIds::TEST_ID_0);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::info << "LibgpiodTest::performOneShotAction: "
|
||||
"GPIO pulled high successfully for loopback test" << std::endl;
|
||||
}
|
||||
else {
|
||||
"GPIO pulled high successfully for loopback test"
|
||||
<< std::endl;
|
||||
} else {
|
||||
sif::warning << "LibgpiodTest::performOneShotAction: Could not pull GPIO high!"
|
||||
<< std::endl;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
@ -105,9 +96,9 @@ ReturnValue_t LibgpiodTest::performOneShotAction() {
|
||||
result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK and gpioState == 1) {
|
||||
sif::info << "LibgpiodTest::performOneShotAction: "
|
||||
"GPIO state read successfully and is high" << std::endl;
|
||||
}
|
||||
else {
|
||||
"GPIO state read successfully and is high"
|
||||
<< std::endl;
|
||||
} else {
|
||||
sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not high!"
|
||||
<< std::endl;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
@ -116,14 +107,15 @@ ReturnValue_t LibgpiodTest::performOneShotAction() {
|
||||
result = gpioInterface->pullLow(gpioIds::TEST_ID_0);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::info << "LibgpiodTest::performOneShotAction: "
|
||||
"GPIO pulled low successfully for loopback test" << std::endl;
|
||||
"GPIO pulled low successfully for loopback test"
|
||||
<< std::endl;
|
||||
}
|
||||
result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK and gpioState == 0) {
|
||||
sif::info << "LibgpiodTest::performOneShotAction: "
|
||||
"GPIO state read successfully and is low" << std::endl;
|
||||
}
|
||||
else {
|
||||
"GPIO state read successfully and is low"
|
||||
<< std::endl;
|
||||
} else {
|
||||
sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not low!"
|
||||
<< std::endl;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
@ -1,10 +1,11 @@
|
||||
#ifndef TEST_TESTTASKS_LIBGPIODTEST_H_
|
||||
#define TEST_TESTTASKS_LIBGPIODTEST_H_
|
||||
|
||||
#include "TestTask.h"
|
||||
#include <fsfw_hal/common/gpio/GpioIF.h>
|
||||
#include <fsfw_hal/common/gpio/GpioCookie.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw_hal/common/gpio/GpioCookie.h>
|
||||
#include <fsfw_hal/common/gpio/GpioIF.h>
|
||||
|
||||
#include "TestTask.h"
|
||||
|
||||
/**
|
||||
* @brief Test for the GPIO read implementation of the LinuxLibgpioIF.
|
||||
@ -12,11 +13,7 @@
|
||||
*/
|
||||
class LibgpiodTest : public TestTask {
|
||||
public:
|
||||
enum TestCases {
|
||||
READ = 0,
|
||||
LOOPBACK = 1,
|
||||
BLINK
|
||||
};
|
||||
enum TestCases { READ = 0, LOOPBACK = 1, BLINK };
|
||||
|
||||
TestCases testCase;
|
||||
|
||||
|
@ -1,26 +1,24 @@
|
||||
#include "SpiTestClass.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <fsfw/globalfunctions/arrayprinter.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
#include <fsfw/timemanager/Stopwatch.h>
|
||||
#include <fsfw_hal/common/gpio/GpioCookie.h>
|
||||
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
|
||||
#include <fsfw_hal/linux/UnixFileGuard.h>
|
||||
#include <fsfw_hal/linux/utility.h>
|
||||
#include <linux/spi/spidev.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <bitset>
|
||||
|
||||
#include "devices/gpioIds.h"
|
||||
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw/globalfunctions/arrayprinter.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
#include <fsfw/timemanager/Stopwatch.h>
|
||||
|
||||
#include <fsfw_hal/linux/utility.h>
|
||||
#include <fsfw_hal/linux/UnixFileGuard.h>
|
||||
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
|
||||
#include <fsfw_hal/common/gpio/GpioCookie.h>
|
||||
|
||||
#include <linux/spi/spidev.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <bitset>
|
||||
|
||||
SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF* gpioIF): TestTask(objectId),
|
||||
gpioIF(gpioIF) {
|
||||
SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF *gpioIF)
|
||||
: TestTask(objectId), gpioIF(gpioIF) {
|
||||
if (gpioIF == nullptr) {
|
||||
sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl;
|
||||
}
|
||||
@ -50,9 +48,7 @@ ReturnValue_t SpiTestClass::performOneShotAction() {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SpiTestClass::performPeriodicAction() {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
ReturnValue_t SpiTestClass::performPeriodicAction() { return HasReturnvaluesIF::RETURN_OK; }
|
||||
|
||||
void SpiTestClass::performRm3100Test(uint8_t mgmId) {
|
||||
/* Configure all SPI chip selects and pull them high */
|
||||
@ -66,8 +62,7 @@ void SpiTestClass::performRm3100Test(uint8_t mgmId) {
|
||||
uint8_t chipSelectPin = mgmId;
|
||||
if (chipSelectPin == mgm1Rm3100ChipSelect) {
|
||||
currentGpioId = gpioIds::MGM_1_RM3100_CS;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
currentGpioId = gpioIds::MGM_3_RM3100_CS;
|
||||
}
|
||||
uint32_t rm3100speed = 976'000;
|
||||
@ -81,9 +76,7 @@ void SpiTestClass::performRm3100Test(uint8_t mgmId) {
|
||||
#endif
|
||||
int fileDescriptor = 0;
|
||||
|
||||
|
||||
UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR,
|
||||
"SpiComIF::initializeInterface");
|
||||
UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface");
|
||||
if (fileHelper.getOpenResult()) {
|
||||
sif::error << "SpiTestClass::performRm3100Test: File descriptor could not be opened!"
|
||||
<< std::endl;
|
||||
@ -92,14 +85,14 @@ void SpiTestClass::performRm3100Test(uint8_t mgmId) {
|
||||
setSpiSpeedAndMode(fileDescriptor, rm3100mode, rm3100speed);
|
||||
|
||||
uint8_t revId = readRegister(fileDescriptor, currentGpioId, rm3100revidReg);
|
||||
sif::info << "SpiTestClass::performRm3100Test: Revision ID 0b" << std::bitset<8>(revId) <<
|
||||
std::endl;
|
||||
sif::info << "SpiTestClass::performRm3100Test: Revision ID 0b" << std::bitset<8>(revId)
|
||||
<< std::endl;
|
||||
|
||||
/* Write configuration to CMM register */
|
||||
writeRegister(fileDescriptor, currentGpioId, 0x01, 0x75);
|
||||
uint8_t cmmRegister = readRm3100Register(fileDescriptor, currentGpioId, 0x01);
|
||||
sif::info << "SpiTestClass::performRm3100Test: CMM register value: " <<
|
||||
std::hex << "0x" << static_cast<int>(cmmRegister) << std::dec << std::endl;
|
||||
sif::info << "SpiTestClass::performRm3100Test: CMM register value: " << std::hex << "0x"
|
||||
<< static_cast<int>(cmmRegister) << std::dec << std::endl;
|
||||
|
||||
/* Read the cycle count registers */
|
||||
uint8_t cycleCountsRaw[6];
|
||||
@ -115,13 +108,13 @@ void SpiTestClass::performRm3100Test(uint8_t mgmId) {
|
||||
|
||||
writeRegister(fileDescriptor, currentGpioId, 0x0B, 0x96);
|
||||
uint8_t tmrcReg = readRm3100Register(fileDescriptor, currentGpioId, 0x0B);
|
||||
sif::info << "SpiTestClass::performRm3100Test: TMRC register value: " <<
|
||||
std::hex << "0x" << static_cast<int>(tmrcReg) << std::dec << std::endl;
|
||||
sif::info << "SpiTestClass::performRm3100Test: TMRC register value: " << std::hex << "0x"
|
||||
<< static_cast<int>(tmrcReg) << std::dec << std::endl;
|
||||
|
||||
TaskFactory::delayTask(10);
|
||||
uint8_t statusReg = readRm3100Register(fileDescriptor, currentGpioId, 0x34);
|
||||
sif::info << "SpiTestClass::performRm3100Test: Status Register 0b" <<
|
||||
std::bitset<8>(statusReg) << std::endl;
|
||||
sif::info << "SpiTestClass::performRm3100Test: Status Register 0b" << std::bitset<8>(statusReg)
|
||||
<< std::endl;
|
||||
/* This means that data is not ready */
|
||||
if ((statusReg & 0b1000'0000) == 0) {
|
||||
sif::warning << "SpiTestClass::performRm3100Test: Data not ready!" << std::endl;
|
||||
@ -168,8 +161,7 @@ void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) {
|
||||
uint8_t whoAmIRegExpectedVal = 0b0011'1101;
|
||||
if (chipSelectPin == mgm0Lis3mdlChipSelect) {
|
||||
currentGpioId = gpioIds::MGM_0_LIS3_CS;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
currentGpioId = gpioIds::MGM_2_LIS3_CS;
|
||||
}
|
||||
uint32_t spiSpeed = 10'000'000;
|
||||
@ -181,8 +173,7 @@ void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) {
|
||||
#endif
|
||||
int fileDescriptor = 0;
|
||||
|
||||
UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR,
|
||||
"SpiComIF::initializeInterface");
|
||||
UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface");
|
||||
if (fileHelper.getOpenResult()) {
|
||||
sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!"
|
||||
<< std::endl;
|
||||
@ -192,16 +183,13 @@ void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) {
|
||||
spiTransferStruct.delay_usecs = 0;
|
||||
|
||||
uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false);
|
||||
sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" <<
|
||||
std::bitset<8>(whoAmIRegVal) << std::endl;
|
||||
sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b"
|
||||
<< std::bitset<8>(whoAmIRegVal) << std::endl;
|
||||
if (whoAmIRegVal != whoAmIRegExpectedVal) {
|
||||
sif::warning << "SpiTestClass::performLis3MdlTest: WHO AM I register invalid!"
|
||||
<< std::endl;
|
||||
sif::warning << "SpiTestClass::performLis3MdlTest: WHO AM I register invalid!" << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SpiTestClass::performL3gTest(uint8_t l3gId) {
|
||||
/* Configure all SPI chip selects and pull them high */
|
||||
acsInit();
|
||||
@ -213,8 +201,7 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) {
|
||||
|
||||
if (chipSelectPin == gyro1L3gd20ChipSelect) {
|
||||
currentGpioId = gpioIds::GYRO_1_L3G_CS;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
currentGpioId = gpioIds::GYRO_3_L3G_CS;
|
||||
}
|
||||
uint32_t spiSpeed = 3'900'000;
|
||||
@ -226,8 +213,7 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) {
|
||||
#endif
|
||||
int fileDescriptor = 0;
|
||||
|
||||
UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR,
|
||||
"SpiComIF::initializeInterface");
|
||||
UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface");
|
||||
if (fileHelper.getOpenResult()) {
|
||||
sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!"
|
||||
<< std::endl;
|
||||
@ -235,11 +221,10 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) {
|
||||
}
|
||||
setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
|
||||
uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false);
|
||||
sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" <<
|
||||
std::bitset<8>(whoAmIRegVal) << std::endl;
|
||||
sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b"
|
||||
<< std::bitset<8>(whoAmIRegVal) << std::endl;
|
||||
if (whoAmIRegVal != whoAmIRegExpectedVal) {
|
||||
sif::warning << "SpiTestClass::performL3gTest: Read WHO AM I register invalid!" <<
|
||||
std::endl;
|
||||
sif::warning << "SpiTestClass::performL3gTest: Read WHO AM I register invalid!" << std::endl;
|
||||
}
|
||||
|
||||
uint8_t ctrlReg1Addr = 0b0010'0000;
|
||||
@ -254,12 +239,11 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) {
|
||||
writeMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, commandRegs,
|
||||
sizeof(commandRegs));
|
||||
uint8_t readRegs[5];
|
||||
readMultipleRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readRegs,
|
||||
sizeof(readRegs));
|
||||
readMultipleRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readRegs, sizeof(readRegs));
|
||||
for (uint8_t idx = 0; idx < sizeof(readRegs); idx++) {
|
||||
if (readRegs[idx] != commandRegs[0]) {
|
||||
sif::warning << "SpiTestClass::performL3gTest: Read control register " <<
|
||||
static_cast<int>(idx + 1) << " not equal to configured value" << std::endl;
|
||||
sif::warning << "SpiTestClass::performL3gTest: Read control register "
|
||||
<< static_cast<int>(idx + 1) << " not equal to configured value" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -269,8 +253,8 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) {
|
||||
sizeof(readOutBuffer));
|
||||
|
||||
uint8_t statusReg = readOutBuffer[7];
|
||||
sif::info << "SpiTestClass::performL3gTest: Status Register 0b" <<
|
||||
std::bitset<8>(statusReg) << std::endl;
|
||||
sif::info << "SpiTestClass::performL3gTest: Status Register 0b" << std::bitset<8>(statusReg)
|
||||
<< std::endl;
|
||||
|
||||
uint16_t l3gRange = 245;
|
||||
float scaleFactor = static_cast<float>(l3gRange) / INT16_MAX;
|
||||
@ -287,7 +271,6 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) {
|
||||
sif::info << "X: " << angVelocX << std::endl;
|
||||
sif::info << "Y: " << angVelocY << std::endl;
|
||||
sif::info << "Z: " << angVelocZ << std::endl;
|
||||
|
||||
}
|
||||
|
||||
void SpiTestClass::acsInit() {
|
||||
@ -296,56 +279,56 @@ void SpiTestClass::acsInit() {
|
||||
#ifdef RASPBERRY_PI
|
||||
GpiodRegularByChip *gpio = nullptr;
|
||||
std::string rpiGpioName = "gpiochip0";
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, mgm0Lis3mdlChipSelect, "MGM_0_LIS3",
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, mgm0Lis3mdlChipSelect, "MGM_0_LIS3", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100",
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS",
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G",
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, gyro3L3gd20ChipSelect, "GYRO_2_L3G",
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, gyro3L3gd20ChipSelect, "GYRO_2_L3G", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3",
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100",
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
gpio = new GpiodRegularByChip(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio);
|
||||
#elif defined(XIPHOS_Q7S)
|
||||
GpiodRegularByLineName *gpio = nullptr;
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, "MGM_0_LIS3", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpio =
|
||||
new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, "MGM_0_LIS3", gpio::DIR_OUT, gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_1_RM3100", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, "MGM_2_LIS3", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpio =
|
||||
new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, "MGM_2_LIS3", gpio::DIR_OUT, gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_3_RM3100", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, "GYRO_0_ADIS",
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, "GYRO_0_ADIS", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, "GYRO_1_L3G", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, "GYRO_2_ADIS",
|
||||
gpio::DIR_OUT, gpio::HIGH);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, "GYRO_2_ADIS", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio);
|
||||
gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, "GYRO_3_L3G", gpio::DIR_OUT,
|
||||
gpio::HIGH);
|
||||
@ -412,11 +395,10 @@ void SpiTestClass::writeMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_
|
||||
/* Clear read mask */
|
||||
reg &= ~STM_READ_MASK;
|
||||
writeMultipleRegisters(fd, chipSelect, reg, values, len);
|
||||
|
||||
}
|
||||
|
||||
void SpiTestClass::writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg,
|
||||
uint8_t *values, size_t len) {
|
||||
void SpiTestClass::writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *values,
|
||||
size_t len) {
|
||||
if (values == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -441,9 +423,8 @@ uint8_t SpiTestClass::readRm3100Register(int fd, gpioId_t chipSelect, uint8_t re
|
||||
return readStmRegister(fd, chipSelect, reg, false);
|
||||
}
|
||||
|
||||
|
||||
void SpiTestClass::readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *reply,
|
||||
size_t len) {
|
||||
void SpiTestClass::readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg,
|
||||
uint8_t *reply, size_t len) {
|
||||
reg |= STM_AUTO_INCR_MASK;
|
||||
readMultipleRegisters(fd, chipSelect, reg, reply, len);
|
||||
}
|
||||
@ -483,7 +464,6 @@ uint8_t SpiTestClass::readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg,
|
||||
return readRegister(fd, chipSelect, reg);
|
||||
}
|
||||
|
||||
|
||||
uint8_t SpiTestClass::readRegister(int fd, gpioId_t chipSelect, uint8_t reg) {
|
||||
spiTransferStruct.len = 2;
|
||||
sendBuffer[0] = reg;
|
||||
|
@ -28,8 +28,8 @@ public:
|
||||
|
||||
ReturnValue_t performOneShotAction() override;
|
||||
ReturnValue_t performPeriodicAction() override;
|
||||
private:
|
||||
|
||||
private:
|
||||
GpioIF* gpioIF;
|
||||
|
||||
std::array<uint8_t, 128> recvBuffer;
|
||||
@ -84,12 +84,7 @@ private:
|
||||
uint8_t readRegister(int fd, gpioId_t chipSelect, uint8_t reg);
|
||||
void readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* reply,
|
||||
size_t len);
|
||||
void readMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg,
|
||||
uint8_t* reply, size_t len);
|
||||
|
||||
void readMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* reply, size_t len);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* LINUX_BOARDTEST_SPITESTCLASS_H_ */
|
||||
|
@ -5,18 +5,16 @@
|
||||
#include "q7sConfig.h"
|
||||
#endif
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include "lwgps/lwgps.h"
|
||||
|
||||
#include <fcntl.h> // Contains file controls like O_RDWR
|
||||
#include <errno.h> // Error integer and strerror() function
|
||||
#include <fcntl.h> // Contains file controls like O_RDWR
|
||||
#include <unistd.h> // write(), read(), close()
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "lwgps/lwgps.h"
|
||||
|
||||
#define GPS_REPLY_WIRETAPPING 0
|
||||
|
||||
UartTestClass::UartTestClass(object_id_t objectId): TestTask(objectId) {
|
||||
}
|
||||
UartTestClass::UartTestClass(object_id_t objectId) : TestTask(objectId) {}
|
||||
|
||||
ReturnValue_t UartTestClass::initialize() {
|
||||
#if RPI_TEST_GPS_DEVICE == 1
|
||||
@ -45,7 +43,8 @@ ReturnValue_t UartTestClass::initialize() {
|
||||
tty.c_lflag &= ~ECHONL; // Disable new-line echo
|
||||
tty.c_lflag &= ~ISIG; // Disable interpretation of INTR, QUIT and SUSP
|
||||
tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl
|
||||
tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL); // Disable any special handling of received bytes
|
||||
tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR |
|
||||
ICRNL); // Disable any special handling of received bytes
|
||||
tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars)
|
||||
tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed
|
||||
|
||||
@ -56,8 +55,9 @@ ReturnValue_t UartTestClass::initialize() {
|
||||
cfsetispeed(&tty, B9600);
|
||||
cfsetospeed(&tty, B9600);
|
||||
if (tcsetattr(serialPort, TCSANOW, &tty) != 0) {
|
||||
sif::warning << "tcsetattr call failed with error [" << errno << ", " <<
|
||||
strerror(errno) << std::endl;;
|
||||
sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno)
|
||||
<< std::endl;
|
||||
;
|
||||
}
|
||||
// Flush received and unread data. Those are old NMEA strings which are not relevant anymore
|
||||
tcflush(serialPort, TCIFLUSH);
|
||||
@ -75,27 +75,24 @@ ReturnValue_t UartTestClass::performPeriodicAction() {
|
||||
#if RPI_TEST_GPS_DEVICE == 1
|
||||
int bytesRead = 0;
|
||||
do {
|
||||
bytesRead = read(serialPort,
|
||||
reinterpret_cast<void*>(recBuf.data()),
|
||||
bytesRead = read(serialPort, reinterpret_cast<void*>(recBuf.data()),
|
||||
static_cast<unsigned int>(recBuf.size()));
|
||||
if (bytesRead < 0) {
|
||||
sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" <<
|
||||
errno << ", " << strerror(errno) << "]" << std::endl;
|
||||
sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno
|
||||
<< ", " << strerror(errno) << "]" << std::endl;
|
||||
break;
|
||||
}
|
||||
else if(bytesRead >= static_cast<int>(recBuf.size())) {
|
||||
} else if (bytesRead >= static_cast<int>(recBuf.size())) {
|
||||
sif::debug << "UartTestClass::performPeriodicAction: "
|
||||
"recv buffer might not be large enough" << std::endl;
|
||||
}
|
||||
else if(bytesRead > 0) {
|
||||
"recv buffer might not be large enough"
|
||||
<< std::endl;
|
||||
} else if (bytesRead > 0) {
|
||||
// pass data to lwgps for processing
|
||||
#if GPS_REPLY_WIRETAPPING == 1
|
||||
sif::info << recBuf.data() << std::endl;
|
||||
#endif
|
||||
int result = lwgps_process(&gpsData, recBuf.data(), bytesRead);
|
||||
if (result == 0) {
|
||||
sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error"
|
||||
<< std::endl;
|
||||
sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" << std::endl;
|
||||
}
|
||||
recvCnt++;
|
||||
if (recvCnt == 6) {
|
||||
|
@ -1,11 +1,12 @@
|
||||
#ifndef LINUX_BOARDTEST_UARTTESTCLASS_H_
|
||||
#define LINUX_BOARDTEST_UARTTESTCLASS_H_
|
||||
|
||||
#include "test/testtasks/TestTask.h"
|
||||
#include "lwgps/lwgps.h"
|
||||
#include <termios.h> // Contains POSIX terminal control definitions
|
||||
|
||||
#include <array>
|
||||
#include <termios.h> // Contains POSIX terminal control definitions
|
||||
|
||||
#include "lwgps/lwgps.h"
|
||||
#include "test/testtasks/TestTask.h"
|
||||
|
||||
class UartTestClass : public TestTask {
|
||||
public:
|
||||
@ -14,14 +15,13 @@ public:
|
||||
ReturnValue_t initialize() override;
|
||||
ReturnValue_t performOneShotAction() override;
|
||||
ReturnValue_t performPeriodicAction() override;
|
||||
private:
|
||||
|
||||
private:
|
||||
lwgps_t gpsData = {};
|
||||
struct termios tty = {};
|
||||
int serialPort = 0;
|
||||
std::array<uint8_t, 512> recBuf;
|
||||
uint8_t recvCnt = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* LINUX_BOARDTEST_UARTTESTCLASS_H_ */
|
||||
|
@ -1,16 +1,14 @@
|
||||
#include "CspComIF.h"
|
||||
#include "CspCookie.h"
|
||||
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <csp/drivers/can_socketcan.h>
|
||||
#include <fsfw/serialize/SerializeAdapter.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
|
||||
CspComIF::CspComIF(object_id_t objectId) :
|
||||
SystemObject(objectId) {
|
||||
}
|
||||
#include "CspCookie.h"
|
||||
|
||||
CspComIF::~CspComIF() {
|
||||
}
|
||||
CspComIF::CspComIF(object_id_t objectId) : SystemObject(objectId) {}
|
||||
|
||||
CspComIF::~CspComIF() {}
|
||||
|
||||
ReturnValue_t CspComIF::initializeInterface(CookieIF* cookie) {
|
||||
if (cookie == nullptr) {
|
||||
@ -30,8 +28,8 @@ ReturnValue_t CspComIF::initializeInterface(CookieIF *cookie) {
|
||||
int buf_count = 10;
|
||||
int buf_size = 300;
|
||||
/* Init CSP and CSP buffer system */
|
||||
if (csp_init(cspOwnAddress) != CSP_ERR_NONE
|
||||
|| csp_buffer_init(buf_count, buf_size) != CSP_ERR_NONE) {
|
||||
if (csp_init(cspOwnAddress) != CSP_ERR_NONE ||
|
||||
csp_buffer_init(buf_count, buf_size) != CSP_ERR_NONE) {
|
||||
sif::error << "Failed to init CSP\r\n" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
@ -46,8 +44,7 @@ ReturnValue_t CspComIF::initializeInterface(CookieIF *cookie) {
|
||||
uint8_t mac = CSP_NODE_MAC;
|
||||
int result = csp_rtable_set(address, netmask, csp_if_ptr, mac);
|
||||
if (result != CSP_ERR_NONE) {
|
||||
sif::error << "Failed to add can interface to router table"
|
||||
<< std::endl;
|
||||
sif::error << "Failed to add can interface to router table" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -72,8 +69,7 @@ ReturnValue_t CspComIF::initializeInterface(CookieIF *cookie) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CspComIF::sendMessage(CookieIF *cookie,
|
||||
const uint8_t * sendData, size_t sendLen) {
|
||||
ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) {
|
||||
int result;
|
||||
if (cookie == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
@ -104,8 +100,7 @@ ReturnValue_t CspComIF::sendMessage(CookieIF *cookie,
|
||||
case (Ports::P60_PORT_RPARAM): {
|
||||
/* No CSP fixed port was selected. Send data to the specified port and
|
||||
* wait for querySize number of bytes */
|
||||
result = cspTransfer(cspAddress, cspPort, sendData, sendLen,
|
||||
querySize);
|
||||
result = cspTransfer(cspAddress, cspPort, sendData, sendLen, querySize);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
@ -119,17 +114,13 @@ ReturnValue_t CspComIF::sendMessage(CookieIF *cookie,
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CspComIF::getSendSuccess(CookieIF *cookie) {
|
||||
ReturnValue_t CspComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; }
|
||||
|
||||
ReturnValue_t CspComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CspComIF::requestReceiveMessage(CookieIF *cookie,
|
||||
size_t requestLen) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CspComIF::readReceivedMessage(CookieIF *cookie,
|
||||
uint8_t** buffer, size_t* size) {
|
||||
ReturnValue_t CspComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
|
||||
if (cookie == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
@ -146,9 +137,8 @@ ReturnValue_t CspComIF::readReceivedMessage(CookieIF *cookie,
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort,
|
||||
const uint8_t* cmdBuffer, int cmdLen, uint16_t querySize) {
|
||||
|
||||
ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, const uint8_t* cmdBuffer,
|
||||
int cmdLen, uint16_t querySize) {
|
||||
uint32_t timeout_ms = 1000;
|
||||
uint16_t bytesRead = 0;
|
||||
int32_t expectedSize = (int32_t)querySize;
|
||||
@ -159,8 +149,7 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort,
|
||||
}
|
||||
uint8_t* replyBuffer = iter->second.data();
|
||||
|
||||
csp_conn_t * conn = csp_connect(CSP_PRIO_HIGH, cspAddress, cspPort, 0,
|
||||
CSP_O_NONE);
|
||||
csp_conn_t* conn = csp_connect(CSP_PRIO_HIGH, cspAddress, cspPort, 0, CSP_O_NONE);
|
||||
|
||||
csp_packet_t* commandPacket = (csp_packet_t*)csp_buffer_get(cmdLen);
|
||||
if (commandPacket == NULL) {
|
||||
@ -227,17 +216,16 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort,
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CspComIF::getPortAndQuerySize(const uint8_t** sendData,
|
||||
size_t* sendLen, uint8_t* cspPort, uint16_t* querySize) {
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(cspPort, sendData,
|
||||
sendLen, SerializeIF::Endianness::BIG);
|
||||
ReturnValue_t CspComIF::getPortAndQuerySize(const uint8_t** sendData, size_t* sendLen,
|
||||
uint8_t* cspPort, uint16_t* querySize) {
|
||||
ReturnValue_t result =
|
||||
SerializeAdapter::deSerialize(cspPort, sendData, sendLen, SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "CspComIF: Failed to deserialize CSP port from command "
|
||||
<< "buffer" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
SerializeAdapter::deSerialize(querySize, sendData, sendLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
SerializeAdapter::deSerialize(querySize, sendData, sendLen, SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "CspComIF: Failed to deserialize querySize from command "
|
||||
<< "buffer" << std::endl;
|
||||
@ -248,10 +236,9 @@ ReturnValue_t CspComIF::getPortAndQuerySize(const uint8_t** sendData,
|
||||
|
||||
void CspComIF::initiatePingRequest(uint8_t cspAddress, uint16_t querySize) {
|
||||
uint32_t timeout_ms = 500;
|
||||
uint32_t replyTime = csp_ping(cspAddress, timeout_ms, querySize,
|
||||
CSP_O_NONE);
|
||||
sif::info << "Ping address: " << cspAddress << ", reply after "
|
||||
<< replyTime << " ms" << std::endl;
|
||||
uint32_t replyTime = csp_ping(cspAddress, timeout_ms, querySize, CSP_O_NONE);
|
||||
sif::info << "Ping address: " << cspAddress << ", reply after " << replyTime << " ms"
|
||||
<< std::endl;
|
||||
/* Store reply time in reply buffer * */
|
||||
uint8_t* replyBuffer = cspDeviceMap[cspAddress].data();
|
||||
memcpy(replyBuffer, &replyTime, sizeof(replyTime));
|
||||
|
@ -1,13 +1,13 @@
|
||||
#ifndef LINUX_CSP_CSPCOMIF_H_
|
||||
#define LINUX_CSP_CSPCOMIF_H_
|
||||
|
||||
#include <csp/csp.h>
|
||||
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <csp/csp.h>
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* @brief This class serves as the communication interface to devices
|
||||
@ -21,16 +21,12 @@ public:
|
||||
virtual ~CspComIF();
|
||||
|
||||
ReturnValue_t initializeInterface(CookieIF *cookie) override;
|
||||
ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData,
|
||||
size_t sendLen) override;
|
||||
ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) override;
|
||||
ReturnValue_t getSendSuccess(CookieIF *cookie) override;
|
||||
ReturnValue_t requestReceiveMessage(CookieIF *cookie,
|
||||
size_t requestLen) override;
|
||||
ReturnValue_t readReceivedMessage(CookieIF *cookie,
|
||||
uint8_t **readData, size_t *readLen) override;
|
||||
ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override;
|
||||
ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **readData, size_t *readLen) override;
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief This function initiates the CSP transfer.
|
||||
*
|
||||
@ -43,16 +39,10 @@ private:
|
||||
* @param cmdLen The number of bytes to send.
|
||||
* @param querySize The size of the requested message.
|
||||
*/
|
||||
ReturnValue_t cspTransfer(uint8_t cspAddress, uint8_t cspPort,
|
||||
const uint8_t* cmdBuffer, int cmdLen, uint16_t querySize);
|
||||
|
||||
enum Ports {
|
||||
CSP_PING = 1,
|
||||
CSP_REBOOT = 4,
|
||||
P60_PORT_RPARAM = 7,
|
||||
P60_PORT_GNDWDT_RESET = 9
|
||||
};
|
||||
ReturnValue_t cspTransfer(uint8_t cspAddress, uint8_t cspPort, const uint8_t *cmdBuffer,
|
||||
int cmdLen, uint16_t querySize);
|
||||
|
||||
enum Ports { CSP_PING = 1, CSP_REBOOT = 4, P60_PORT_RPARAM = 7, P60_PORT_GNDWDT_RESET = 9 };
|
||||
|
||||
typedef uint8_t node_t;
|
||||
using vectorBuffer = std::vector<uint8_t>;
|
||||
@ -77,8 +67,8 @@ private:
|
||||
* @brief Function to extract the csp port and the query size from the
|
||||
* command buffer.
|
||||
*/
|
||||
ReturnValue_t getPortAndQuerySize(const uint8_t** sendData, size_t* sendLen,
|
||||
uint8_t* cspPort, uint16_t* querySize);
|
||||
ReturnValue_t getPortAndQuerySize(const uint8_t **sendData, size_t *sendLen, uint8_t *cspPort,
|
||||
uint16_t *querySize);
|
||||
|
||||
/**
|
||||
* @brief This function initiates the ping request.
|
||||
|
@ -1,16 +1,10 @@
|
||||
#include "CspCookie.h"
|
||||
|
||||
CspCookie::CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_) :
|
||||
maxReplyLength(maxReplyLength_), cspAddress(cspAddress_) {
|
||||
}
|
||||
CspCookie::CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_)
|
||||
: maxReplyLength(maxReplyLength_), cspAddress(cspAddress_) {}
|
||||
|
||||
CspCookie::~CspCookie() {
|
||||
}
|
||||
CspCookie::~CspCookie() {}
|
||||
|
||||
uint16_t CspCookie::getMaxReplyLength(){
|
||||
return maxReplyLength;
|
||||
}
|
||||
uint16_t CspCookie::getMaxReplyLength() { return maxReplyLength; }
|
||||
|
||||
uint8_t CspCookie::getCspAddress(){
|
||||
return cspAddress;
|
||||
}
|
||||
uint8_t CspCookie::getCspAddress() { return cspAddress; }
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define LINUX_CSP_CSPCOOKIE_H_
|
||||
|
||||
#include <fsfw/devicehandlers/CookieIF.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
@ -11,7 +12,6 @@
|
||||
*/
|
||||
class CspCookie : public CookieIF {
|
||||
public:
|
||||
|
||||
CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_);
|
||||
virtual ~CspCookie();
|
||||
|
||||
@ -19,7 +19,6 @@ public:
|
||||
uint8_t getCspAddress();
|
||||
|
||||
private:
|
||||
|
||||
uint16_t maxReplyLength;
|
||||
uint8_t cspAddress;
|
||||
};
|
||||
|
@ -1,28 +1,33 @@
|
||||
#include "SolarArrayDeploymentHandler.h"
|
||||
|
||||
#include <devices/powerSwitcherList.h>
|
||||
#include <devices/gpioIds.h>
|
||||
|
||||
#include <fsfw_hal/common/gpio/GpioCookie.h>
|
||||
#include <devices/powerSwitcherList.h>
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
|
||||
#include <fsfw_hal/common/gpio/GpioCookie.h>
|
||||
|
||||
SolarArrayDeploymentHandler::SolarArrayDeploymentHandler(object_id_t setObjectId_,
|
||||
object_id_t gpioDriverId_, CookieIF * gpioCookie_, object_id_t mainLineSwitcherObjectId_,
|
||||
uint8_t mainLineSwitch_, gpioId_t deplSA1, gpioId_t deplSA2, uint32_t burnTimeMs) :
|
||||
SystemObject(setObjectId_), gpioDriverId(gpioDriverId_), gpioCookie(gpioCookie_),
|
||||
mainLineSwitcherObjectId(mainLineSwitcherObjectId_), mainLineSwitch(mainLineSwitch_),
|
||||
deplSA1(deplSA1), deplSA2(deplSA2), burnTimeMs(burnTimeMs), actionHelper(this, nullptr) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize,
|
||||
MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
object_id_t gpioDriverId_,
|
||||
CookieIF* gpioCookie_,
|
||||
object_id_t mainLineSwitcherObjectId_,
|
||||
uint8_t mainLineSwitch_, gpioId_t deplSA1,
|
||||
gpioId_t deplSA2, uint32_t burnTimeMs)
|
||||
: SystemObject(setObjectId_),
|
||||
gpioDriverId(gpioDriverId_),
|
||||
gpioCookie(gpioCookie_),
|
||||
mainLineSwitcherObjectId(mainLineSwitcherObjectId_),
|
||||
mainLineSwitch(mainLineSwitch_),
|
||||
deplSA1(deplSA1),
|
||||
deplSA2(deplSA2),
|
||||
burnTimeMs(burnTimeMs),
|
||||
actionHelper(this, nullptr) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(
|
||||
cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
}
|
||||
|
||||
SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() {
|
||||
}
|
||||
SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() {}
|
||||
|
||||
ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCode) {
|
||||
|
||||
if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) {
|
||||
handleStateMachine();
|
||||
return RETURN_OK;
|
||||
@ -38,8 +43,7 @@ ReturnValue_t SolarArrayDeploymentHandler::initialize() {
|
||||
|
||||
gpioInterface = ObjectManager::instance()->get<GpioIF>(gpioDriverId);
|
||||
if (gpioInterface == nullptr) {
|
||||
sif::error << "SolarArrayDeploymentHandler::initialize: Invalid Gpio interface."
|
||||
<< std::endl;
|
||||
sif::error << "SolarArrayDeploymentHandler::initialize: Invalid Gpio interface." << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
@ -121,23 +125,23 @@ void SolarArrayDeploymentHandler::switchDeploymentTransistors() {
|
||||
result = gpioInterface->pullHigh(deplSA1);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar"
|
||||
" array deployment switch 1 high " << std::endl;
|
||||
" array deployment switch 1 high "
|
||||
<< std::endl;
|
||||
/* If gpio switch high failed, state machine is reset to wait for a command reinitiating
|
||||
* the deployment sequence. */
|
||||
stateMachine = WAIT_ON_DELOYMENT_COMMAND;
|
||||
triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED);
|
||||
actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS,
|
||||
SWITCHING_DEPL_SA2_FAILED);
|
||||
actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, SWITCHING_DEPL_SA2_FAILED);
|
||||
mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF);
|
||||
}
|
||||
result = gpioInterface->pullHigh(deplSA2);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar"
|
||||
" array deployment switch 2 high " << std::endl;
|
||||
" array deployment switch 2 high "
|
||||
<< std::endl;
|
||||
stateMachine = WAIT_ON_DELOYMENT_COMMAND;
|
||||
triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED);
|
||||
actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS,
|
||||
SWITCHING_DEPL_SA2_FAILED);
|
||||
actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, SWITCHING_DEPL_SA2_FAILED);
|
||||
mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF);
|
||||
}
|
||||
deploymentCountdown.setTimeout(burnTimeMs);
|
||||
@ -151,12 +155,14 @@ void SolarArrayDeploymentHandler::handleDeploymentFinish() {
|
||||
result = gpioInterface->pullLow(deplSA1);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar"
|
||||
" array deployment switch 1 low " << std::endl;
|
||||
" array deployment switch 1 low "
|
||||
<< std::endl;
|
||||
}
|
||||
result = gpioInterface->pullLow(deplSA2);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar"
|
||||
" array deployment switch 2 low " << std::endl;
|
||||
" array deployment switch 2 low "
|
||||
<< std::endl;
|
||||
}
|
||||
mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF);
|
||||
mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs());
|
||||
@ -178,7 +184,8 @@ void SolarArrayDeploymentHandler::readCommandQueue() {
|
||||
}
|
||||
|
||||
ReturnValue_t SolarArrayDeploymentHandler::executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy, const uint8_t* data, size_t size) {
|
||||
MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size) {
|
||||
ReturnValue_t result;
|
||||
if (stateMachine != WAIT_ON_DELOYMENT_COMMAND) {
|
||||
sif::error << "SolarArrayDeploymentHandler::executeAction: Received command while not in"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user